-- TestTestSubject.mesa December 6, 1985 11:23:33 am PST -- Sturgis, January 3, 1986 3:05:08 pm PST DIRECTORY Commander USING[CommandProc, Register], FS USING[StreamOpen], IO USING[Close, STREAM], KipperSupport USING[CreateKipperer, CreateUnKipperer, Kipperer, UnKipperer, KipperRope, UnKipperRope], Rope USING[ROPE, Equal, FromRefText, Substr], TestSubject USING[A, ABody, KipperA, UnKipperA, B, KipperB, UnKipperB, z, s, Kippers, UnKippers, X1, KipperX1, UnKipperX1, Z1, KipperZ1, UnKipperZ1, W1, Item, ItemBody, W2]; TestTestSubject: CEDAR PROGRAM IMPORTS Commander, FS, IO, KipperSupport, Rope, TestSubject = BEGIN CompareA: PROC[old, new: TestSubject.A] = BEGIN oldP: TestSubject.A _ old; newP: TestSubject.A _ new; IF newP.prev # NIL THEN ERROR; WHILE oldP # NIL AND newP # NIL DO IF oldP.x # newP.x OR oldP.y # newP.y THEN ERROR; IF newP.next # NIL THEN {IF newP.next.prev # newP THEN ERROR}; oldP _ oldP.next; newP _ newP.next; ENDLOOP; IF oldP # NIL OR newP # NIL THEN ERROR; END; Compares: PROC[old, new: TestSubject.s] = BEGIN oldCell: TestSubject.s _ old; newCell: TestSubject.s _ new; WHILE oldCell # NIL DO IF oldCell.first # newCell.first THEN ERROR; oldCell _ oldCell.rest; newCell _ newCell.rest; ENDLOOP; IF newCell # NIL THEN ERROR; END; CompareB: PROC[old, new: TestSubject.B] = BEGIN oldCell1: TestSubject.B _ old; newCell1: TestSubject.B _ new; WHILE oldCell1 # NIL DO oldCell2: LIST OF TestSubject.z _ oldCell1.first; newCell2: LIST OF TestSubject.z _ newCell1.first; WHILE oldCell2 # NIL DO IF oldCell2.first # newCell2.first THEN ERROR; oldCell2 _ oldCell2.rest; newCell2 _ newCell2.rest; ENDLOOP; oldCell1 _ oldCell1.rest; newCell1 _ newCell1.rest; ENDLOOP; IF newCell1 # NIL THEN ERROR; END; CompareX1: PROC[old, new: TestSubject.X1] = BEGIN IF NOT Rope.Equal[old^, new^] THEN ERROR; END; CompareW1: PROC[old, new: REF TestSubject.W1] = BEGIN IF old.x # new.x THEN ERROR; IF old.y # new.y THEN ERROR; IF old.nItems # new.nItems THEN ERROR; FOR I: CARDINAL IN [0..old.nItems) DO CompareItem[old.s[I], new.s[I]]; ENDLOOP; END; CompareW2: PROC[old, new: REF TestSubject.W2] = BEGIN IF old.cardinal # new.cardinal THEN ERROR; IF old.int # new.int THEN ERROR; IF old.boolean # new.boolean THEN ERROR; IF NOT Rope.Equal[old.rope, new.rope] THEN ERROR; IF old.bool # new.bool THEN ERROR; IF old.char # new.char THEN ERROR; IF old.character # new.character THEN ERROR; IF old.integer # new.integer THEN ERROR; IF old.nat # new.nat THEN ERROR; IF old.real # new.real THEN ERROR; IF old.word # new.word THEN ERROR; IF old.card # new.card THEN ERROR; END; CompareItem: PROC[old, new: TestSubject.Item] = BEGIN IF old = NIL AND new = NIL THEN RETURN; IF old.z # new.z THEN ERROR; IF old.b # new.b THEN ERROR; END; CompareZ1: PROC[old, new: TestSubject.Z1] = BEGIN oldCell: TestSubject.Z1 _ old; newCell: TestSubject.Z1 _ new; WHILE oldCell # NIL DO CompareRefAny[oldCell.first, newCell.first]; oldCell _ oldCell.rest; newCell _ newCell.rest; ENDLOOP; IF newCell # NIL THEN ERROR; END; CompareRefAny: PROC[old, new: REF ANY] = BEGIN IF old = NIL AND new = NIL THEN RETURN; WITH old SELECT FROM refText: REF TEXT => IF NOT Rope.Equal[Rope.FromRefText[NARROW[old]], Rope.FromRefText[NARROW[new]]] THEN ERROR; rope: Rope.ROPE => IF NOT Rope.Equal[NARROW[old], NARROW[new]] THEN ERROR; oldA: TestSubject.A => CompareA[NARROW[old], NARROW[new]]; olds: TestSubject.s => Compares[NARROW[old], NARROW[new]]; oldB: TestSubject.B => CompareB[NARROW[old], NARROW[new]]; oldX1: TestSubject.X1 => CompareX1[NARROW[old], NARROW[new]]; oldZ1: TestSubject.Z1 => CompareZ1[NARROW[old], NARROW[new]]; oldW1: REF TestSubject.W1 => CompareW1[NARROW[old], NARROW[new]]; oldItem: TestSubject.Item => CompareItem[NARROW[old], NARROW[new]]; oldW2: REF TestSubject.W2 => CompareW2[NARROW[old], NARROW[new]]; ENDCASE => ERROR; END; Test: Commander.CommandProc = TRUSTED BEGIN chain: TestSubject.A _ NIL; s: IO.STREAM _ FS.StreamOpen["testFile", create]; m: KipperSupport.Kipperer _ KipperSupport.CreateKipperer[s]; t: IO.STREAM; um: KipperSupport.UnKipperer; newChain: TestSubject.A _ NIL; list: TestSubject.s _ NIL; newList: TestSubject.s _ NIL; listList: TestSubject.B _ NIL; newListList: TestSubject.B _ NIL; x1: TestSubject.X1; newX1: TestSubject.X1; z1: TestSubject.Z1; newz1: TestSubject.Z1; w11: REF TestSubject.W1; w12: REF TestSubject.W1; rope1, rope2, rope3: Rope.ROPE; newRope1, newRope2, newRope3: Rope.ROPE; FOR I: CARDINAL IN [0..100) DO chain _ NEW[TestSubject.ABody_[I, 2*I, NIL, chain]]; IF chain.next # NIL THEN chain.next.prev _ chain; ENDLOOP; FOR I: CARDINAL IN [0..1000) DO list _ CONS[I, list]; ENDLOOP; listList _ LIST[LIST[b, c, c], LIST[a, b, b, b], LIST[a]]; x1 _ NEW[Rope.ROPE _ "This is a long rope, designed to exceed the text buffer size in the marshall code by a few characters."]; w11 _ NEW[TestSubject.W1[5] _ [27, FALSE, ]]; w11.s[0] _ NIL; w11.s[1] _ NEW[TestSubject.ItemBody_[45, 67]]; w11.s[2] _ NEW[TestSubject.ItemBody_[34, 4]]; w11.s[3] _ NEW[TestSubject.ItemBody_[5, 345]]; w11.s[4] _ NEW[TestSubject.ItemBody_[198, -9]]; w12 _ NEW[TestSubject.W1[1] _ [34, TRUE, ]]; w12.s[0] _ NEW[TestSubject.ItemBody_[45, 5678]]; z1 _ LIST[listList, NIL, "xxy", w11, w12, NEW[TestSubject.W2_[9, -9, FALSE, "xx", TRUE, 'x, 'y, LAST[INTEGER], LAST[NAT], 4.56, 56B, 32345670123B]]]; rope1 _ "abcdefg"; rope2 _ rope1; -- designed so that rope1 EQ rope2 rope3 _ Rope.Substr["abcdefgh", 0, 7]; -- not an EQ, but an EQUAL TestSubject.KipperA[m, chain]; TestSubject.Kippers[m, list]; TestSubject.KipperB[m, listList]; TestSubject.KipperX1[m, x1]; TestSubject.KipperZ1[m, z1]; KipperSupport.KipperRope[m, rope1]; KipperSupport.KipperRope[m, rope2]; KipperSupport.KipperRope[m, rope3]; IO.Close[s]; t _ FS.StreamOpen["testFile"]; um _ KipperSupport.CreateUnKipperer[t]; newChain _ TestSubject.UnKipperA[um]; newList _ TestSubject.UnKippers[um]; newListList _ TestSubject.UnKipperB[um]; newX1 _ TestSubject.UnKipperX1[um]; newz1 _ TestSubject.UnKipperZ1[um]; newRope1 _ KipperSupport.UnKipperRope[um]; newRope2 _ KipperSupport.UnKipperRope[um]; newRope3 _ KipperSupport.UnKipperRope[um]; IO.Close[t]; CompareA[chain, newChain]; Compares[list, newList]; CompareB[listList, newListList]; CompareX1[x1, newX1]; CompareZ1[z1, newz1]; CompareRefAny[rope1, newRope1]; CompareRefAny[rope2, newRope2]; CompareRefAny[rope3, newRope3]; IF newRope1 # newRope2 THEN ERROR; IF newRope1 = newRope3 THEN ERROR; IF NOT Rope.Equal[newRope1, newRope3] THEN ERROR; END; Commander.Register["TestSubject", Test]; END.. Ê6˜J˜8J˜*J˜˜ Jšœ'˜'J˜J˜J˜fJ˜-Jšœ­˜­J˜—šœ\˜\J˜J˜˜)J˜J˜J˜J˜J˜J˜˜"J˜1˜J˜&—J˜J˜J˜—J˜'J˜—J˜˜)J˜J˜J˜J˜˜J˜,J˜J˜J˜—J˜J˜J˜—J˜˜)J˜J˜J˜˜J˜1J˜1˜J˜.J˜J˜J˜—J˜J˜J˜—J˜J˜—J˜˜+J˜J˜)J˜—J˜˜/J˜J˜J˜J˜&˜%J˜ J˜—J˜—J˜˜/J˜J˜*J˜ J˜(J˜1J˜"J˜"J˜,J˜(J˜ J˜"J˜"J˜"J˜—J˜˜/J˜J˜'J˜J˜J˜—J˜˜+J˜J˜J˜J˜˜J˜,J˜J˜J˜—J˜J˜J˜—J˜˜(J˜J˜'˜J˜pJ˜JJ˜:J˜:J˜:J˜=J˜=J˜AJ˜CJ˜AJ˜J˜—J˜J˜—˜%Jšœ˜J˜J˜1Jšœ<˜