-- TestStyle.mesa
-- written by Bill Paxton, August 1981
-- last edit by Bill Paxton, 21-Oct-81 12:36:16
-- This module provides testing for JaM node style interface
DIRECTORY
NodeStyle,
NodeStyleExtra,
NodeProps,
TextNode,
TextEdit,
NameSymbolTable,
TextLooks;
TestStyle: PROGRAM
IMPORTS NodeStyle, NameSymbolTable, TextNode, TextEdit, NodeProps =
BEGIN
OPEN
NodeStyle, NodeStyleExtra, looksI:TextLooks, nsI:NameSymbolTable;
Failure: SIGNAL = CODE;
nullName: nsI.Name = nsI.nullName;
Test: PROC = {
node: TextNode.Ref ← TextNode.NewTextNode[];
style: Ref ← Create[];
copy: Ref ← Create[];
sty: StyleRef ← LOOPHOLE[style];
cpy: StyleRef ← LOOPHOLE[copy];
looks: looksI.Looks ← looksI.noLooks;
type1: nsI.Name ← nsI.MakeName["Type1"];
type2: nsI.Name ← nsI.MakeName["Type2"];
test: nsI.Name ← nsI.MakeName["Test"];
error1: nsI.Name ← nsI.MakeName["TestError1"];
error2: nsI.Name ← nsI.MakeName["TestError2"];
helvetica: nsI.Name ← nsI.MakeName["Helvetica"];
timesroman: nsI.Name ← nsI.MakeName["TimesRoman"];
TextEdit.ChangeStyle[node, "Test"];
IF ~ node.hasprefix THEN { SIGNAL Failure; RETURN };
ApplyObject[style, NodeProps.GetPrefixObject[node]];
IF GetStyleName[style] # test THEN { SIGNAL Failure; RETURN };
ApplyType[style,type1,nullName]; -- loads the style and applies type1
IF GetFontFamily[style] # helvetica THEN { SIGNAL Failure; RETURN };
IF GetFontFace[style] # Regular THEN { SIGNAL Failure; RETURN };
IF GetFontSize[style] # 10.0 THEN { SIGNAL Failure; RETURN };
IF GetFontAlphabets[style] # CapsAndLower THEN { SIGNAL Failure; RETURN };
IF GetLineFormatting[style] # FlushLeft THEN { SIGNAL Failure; RETURN };
IF GetUnderlining[style] # None THEN { SIGNAL Failure; RETURN };
IF GetLeftIndent[style] # 20.0 THEN { SIGNAL Failure; RETURN };
IF GetRightIndent[style] # 21.0 THEN { SIGNAL Failure; RETURN };
IF GetFirstIndent[style] # 12.0 THEN { SIGNAL Failure; RETURN };
IF GetBodyIndent[style] # 0.0 THEN { SIGNAL Failure; RETURN };
IF GetTopIndent[style] # 2.0 THEN { SIGNAL Failure; RETURN };
IF GetBottomIndent[style] # 3.0 THEN { SIGNAL Failure; RETURN };
IF GetLeading[style] # 12.0 THEN { SIGNAL Failure; RETURN };
IF GetTopLeading[style] # 22.0 THEN { SIGNAL Failure; RETURN };
IF GetBottomLeading[style] # 25.0 THEN { SIGNAL Failure; RETURN };
IF GetVShift[style] # 0.0 THEN { SIGNAL Failure; RETURN };
IF GetMinGaps[style] # 1.0 THEN { SIGNAL Failure; RETURN };
sty.name[style] ← test;
ApplyType[style,type2,nullName];
IF GetStyleName[style] # test THEN { SIGNAL Failure; RETURN };
IF GetFontFamily[style] # timesroman THEN { SIGNAL Failure; RETURN };
IF GetFontFace[style] # Bold THEN { SIGNAL Failure; RETURN };
IF GetFontSize[style] # 36.0 THEN { SIGNAL Failure; RETURN };
IF GetFontAlphabets[style] # CapsAndSmallCaps THEN { SIGNAL Failure; RETURN };
IF GetLineFormatting[style] # Centered THEN { SIGNAL Failure; RETURN };
IF GetUnderlining[style] # LettersAndDigits THEN { SIGNAL Failure; RETURN };
IF GetLeftIndent[style] # 50.0 THEN { SIGNAL Failure; RETURN };
IF GetRightIndent[style] # 55.0 THEN { SIGNAL Failure; RETURN };
IF GetFirstIndent[style] # 0.0 THEN { SIGNAL Failure; RETURN };
IF GetBodyIndent[style] # 0.0 THEN { SIGNAL Failure; RETURN };
IF GetTopIndent[style] # 40.0 THEN { SIGNAL Failure; RETURN };
IF GetBottomIndent[style] # 42.0 THEN { SIGNAL Failure; RETURN };
IF GetLeading[style] # 42.0 THEN { SIGNAL Failure; RETURN };
IF GetTopLeading[style] # 45.0 THEN { SIGNAL Failure; RETURN };
IF GetBottomLeading[style] # 48.0 THEN { SIGNAL Failure; RETURN };
IF GetVShift[style] # 0.0 THEN { SIGNAL Failure; RETURN };
IF GetMinGaps[style] # 5.0 THEN { SIGNAL Failure; RETURN };
cpy↑ ← sty↑;
looks['b] ← TRUE;
ApplyLooks[style, looks];
IF GetFontFace[style] # Bold THEN { SIGNAL Failure; RETURN };
sty.fontFace ← cpy.fontFace;
IF sty↑ # cpy↑ THEN { SIGNAL Failure; RETURN }; -- look.b changed something else
cpy↑ ← sty↑;
looks['i] ← TRUE;
ApplyLooks[style, looks];
IF GetFontFace[style] # BoldItalic THEN { SIGNAL Failure; RETURN };
sty.fontFace ← cpy.fontFace;
IF sty↑ # cpy↑ THEN { SIGNAL Failure; RETURN }; -- looks changed something else
-- Apply[style, error1];
-- Apply[style, error2];
};
Test;
END.