DIRECTORY IO USING[card, PutF, rope, STREAM], Process USING[CheckForAbort], RMTWTestSubject USING[], Rope USING[ActionType, Equal, Index, Length, Map, ROPE, Substr], StackCirio USING[InterpretTextLine, Stack, WalkStack]; RMTWTestSubjectImpl: CEDAR PROGRAM IMPORTS IO, Process, StackCirio, Rope EXPORTS RMTWTestSubject = BEGIN TestDescriptor: TYPE = RECORD[ expression: Rope.ROPE, expectedResult: Rope.ROPE, compareNCharsOnly: CARD _ 0, validity: Validity _ valid]; Validity: TYPE = {valid, proc, uninitializedVar, WRONG}; ExamineSubjectStack: PUBLIC PROC[stack: StackCirio.Stack, local: BOOLEAN, reports: IO.STREAM] = BEGIN nUnexpectedResults: CARD _ 0; BEGIN frame2Tests: LIST OF TestDescriptor _ LIST[ ["c", "'a"], ["quit", "FALSE"], ["bool1", "FALSE"], ["bool2", "TRUE"], ["charA", "'A"], ["charB", "'b"], ["array1", "(7)[6, 8, 10, 12, 14, 16, 18]"], ["array2", "(6)[11, 13, 15, 17, 19, 21]"], ["refR", "^[a:7, b:8]"], ["bb", "[ref:^[ref:NIL, a:45, b:46], a:47, b:48]"], ["refSeq", "^[x:10, (5)[3, 7, 11, 15, 19]]"], ["refSeq2", "^[y:45, (7)[TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE]]"], ["ref2Seq2", "^[y:77, (32)[TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ...]]"], ["b", "[a:6, b:7]"], ["w", "[x:[a:4, b:5], y:[u:6, v:7]]"], ["y", "failure due to illegal operation: y undefined"], ["action", "RMTWTestSubjectImpl.bar.action(pc=137CE78h, descr at 2BF10Ch, src=8557)", 29, proc], ["foo", "RMTWTestSubjectImpl.(no name)(pc=137CCE0h, descr at 139B880h, src=8208)", 28, proc], ["bar", "RMTWTestSubjectImpl.bar(pc=137CCF4h, descr at 139B878h, src=8228)", 24, proc], ["x", "10", 6, proc], ["veryBad", "RMTWTestSubjectImpl(pc=1379868h, descr at 139B898h, src=372)", 18, proc], ["CallDebugger", "failure due to illegal operation: CallDebugger undefined"]]; nUnexpectedResults _ ExamineOneFrame[stack, frame2Tests, reports] + nUnexpectedResults; END; [] _ StackCirio.WalkStack[stack, 2, reports]; BEGIN frame3Tests: LIST OF TestDescriptor _ LIST[ ["deep", "1606016"], ["rope", "^[(text)[..., (3)[[...]]]]"], ["arg1", "1234"], ["arg2", "5678"], ["res1", "2468"], ["res2", "22712"], ["z", "8518320"], ["yy", "3807"], ["ll", "x"], ["mm", "f"], ["q", "RMTWTestSubjectImpl.bar.q(pc=137D8F0h, descr at 2BF104h, src=9735)", 24, proc], ["b", "[a:6, b:7]"], ["w", "[x:[a:4, b:5], y:[u:6, v:7]]"], ["y", "failure due to illegal operation: y undefined"], ["action", "RMTWTestSubjectImpl.bar.action(pc=137CE78h, descr at 2BF10Ch, src=8557)", 29, proc], ["foo", "RMTWTestSubjectImpl.(no name)(pc=137CCE0h, descr at 139B880h, src=8208)", 28, proc], ["bar", "RMTWTestSubjectImpl.bar(pc=137CCF4h, descr at 139B878h, src=8228)", 22, proc], ["x", "10"], ["veryBad", "RMTWTestSubjectImpl(pc=1379868h, descr at 139B898h, src=372)", 18, proc], ["CallDebugger", "failure due to illegal operation: CallDebugger undefined"], ["r", ""], ["rData", "3456"], ["rData _ 34", "34"], ["rData", "34"]]; frame3LocalTests: LIST OF TestDescriptor _ LIST[ ["rData", "34"], ["r[4567]", "34"], ["rData", "4567"]]; nUnexpectedResults _ ExamineOneFrame[stack, frame3Tests, reports] + nUnexpectedResults; IF local THEN nUnexpectedResults _ ExamineOneFrame[stack, frame3LocalTests, reports] + nUnexpectedResults; END; IF nUnexpectedResults = 0 THEN IO.PutF[reports, "\N\NThere were NO unexpected results\N\N"] ELSE IO.PutF[reports, "\N\NThere were %g unexpected results\N\N", IO.card[nUnexpectedResults]]; END; ExamineOneFrame: PROC[stack: StackCirio.Stack, tryThis: LIST OF TestDescriptor, reports: IO.STREAM] RETURNS[--nUnexpectedResults-- CARD] = BEGIN ResultDescriptor: TYPE = RECORD[ expression: Rope.ROPE, expectedResult: Rope.ROPE, actualResult: Rope.ROPE]; deltas: LIST OF ResultDescriptor _ NIL; lastDelta: LIST OF ResultDescriptor _ NIL; news: LIST OF TestDescriptor _ NIL; lastNew: LIST OF TestDescriptor _ NIL; nUnexpectedResults: CARD _ 0; FOR tests: LIST OF TestDescriptor _ tryThis, tests.rest WHILE tests # NIL DO result: Rope.ROPE _ StackCirio.InterpretTextLine[stack, tests.first.expression, reports]; new: LIST OF TestDescriptor _ LIST[[tests.first.expression, result, tests.first.compareNCharsOnly, tests.first.validity]]; nChars: CARD _ IF tests.first.compareNCharsOnly > 0 THEN tests.first.compareNCharsOnly ELSE Rope.Length[tests.first.expectedResult]; Process.CheckForAbort[]; IF news = NIL THEN news _ new ELSE lastNew.rest _ new; lastNew _ new; IO.PutF[reports, "for expression: %g we get\N\T%g\N", IO.rope[tests.first.expression], IO.rope[result]]; IF (tests.first.validity # uninitializedVar) AND NOT Rope.Equal[Rope.Substr[result, 0, nChars], Rope.Substr[tests.first.expectedResult, 0, nChars]] THEN BEGIN delta: LIST OF ResultDescriptor _ LIST[[tests.first.expression, tests.first.expectedResult, result]]; IO.PutF[reports, " THIS IS WRONG, we expected\N\T%g\N\N", IO.rope[tests.first.expectedResult]]; IF deltas = NIL THEN deltas _ delta ELSE lastDelta.rest _ delta; lastDelta _ delta; nUnexpectedResults _ nUnexpectedResults + 1; END; ENDLOOP; IO.PutF[reports, "\N\Nhere is a list of expressions with their actual results\N"]; FOR items: LIST OF TestDescriptor _ news, items.rest WHILE items # NIL DO IO.PutF[reports, "\T[\"%g\", \"%g\"", IO.rope[items.first.expression], IO.rope[items.first.expectedResult]]; SELECT items.first.validity FROM valid => IF items.first.compareNCharsOnly > 0 THEN IO.PutF[reports, ", %g", IO.card[items.first.compareNCharsOnly]] ELSE NULL; proc => BEGIN nChars: CARD _ Rope.Index[items.first.expectedResult, 0, "(pc="]+4; IO.PutF[reports, ", %g, proc", IO.card[nChars]]; END; uninitializedVar => IO.PutF[reports, ", 0, uninitializedVar"]; WRONG => IO.PutF[reports, ", 0, WRONG"]; ENDCASE => ERROR; IO.PutF[reports, "],\N"]; ENDLOOP; IF deltas # NIL THEN BEGIN IO.PutF[reports, "\N\Nthere were unexpected results\N"]; FOR items: LIST OF ResultDescriptor _ deltas, items.rest WHILE items # NIL DO IO.PutF[reports, "\Texpression: %g\N", IO.rope[items.first.expression]]; IO.PutF[reports, "\Texpected result: %g\N", IO.rope[items.first.expectedResult]]; IO.PutF[reports, "\Tactual result: %g\N", IO.rope[items.first.actualResult]]; ENDLOOP; END ELSE IO.PutF[reports, "\N\Nthere were NO unexpected results\N\N"]; RETURN[nUnexpectedResults]; END; R: TYPE = RECORD[a, b: INT]; S: TYPE = RECORD[x: R, y: RECORD[u: INT, v: CARD]]; b: R _ [6, 7]; w: S _ [[4, 5], [6, 7]]; Subject: PUBLIC PROC[local: BOOLEAN, inner: PROC[CARD32]] = {[] _ bar[1234, 5678, inner]}; foo: PROC _ {NULL}; bar: PROC[arg1: INT, arg2: INT, debug: PROC[key: CARD32]] RETURNS[res1: INT, res2: INT] = BEGIN z: INT _ 8518320; -- should be placed in the frame extension because it is referenced from q yy: INT _ 3807; LL: TYPE = {w, x, y, z}; ll: LL _ x; MM: TYPE = MACHINE DEPENDENT { a (0), b (1), c(2), d(3), f(5), end (25)}; mm: MM _ f; action: Rope.ActionType = BEGIN bool1: BOOLEAN _ FALSE; bool2: BOOLEAN _ TRUE; charA: CHAR _ 'A; charB: CHARACTER _ 'b; array1: ARRAY [3..9] OF INT; array2: PACKED ARRAY [5..10] OF INT[0..128); refR: REF R _ NEW[R_[7, 8]]; B: TYPE = RECORD[ref: REF B, a, b: INT]; bb: B _ [NEW[B_[NIL, 45, 46]], 47, 48]; Seq: TYPE = RECORD[x: INT, fields: SEQUENCE nFields: CARD16 OF INT]; refSeq: REF Seq _ NEW[Seq[5]]; Seq2: TYPE = RECORD[y: INT, fields: PACKED SEQUENCE nFields: [0..45) OF BOOLEAN]; refSeq2: REF Seq2 _ NEW[Seq2[7]]; ref2Seq2: REF Seq2 _ NEW[Seq2[32]]; FOR I: INT IN [3..9] DO array1[I] _ 2*I ENDLOOP; FOR I: INT IN [5..10] DO array2[I] _ 2*I+1 ENDLOOP; refSeq.x _ 10; FOR I: INT IN [0..5) DO refSeq.fields[I] _ 4*I+3 ENDLOOP; refSeq2.y _ 45; FOR I: INT IN [0..7) DO refSeq2.fields[I] _ SELECT I FROM 0 => TRUE, 1 => TRUE, 2 => FALSE, 3 => TRUE, 4 => FALSE, 5 => FALSE, 6 => TRUE, ENDCASE => ERROR ENDLOOP; ref2Seq2.y _ 77; FOR I: INT IN [0..32) DO x: CARD _ (I/4)+1; bit: CARD _ I MOD 4; ref2Seq2.fields[I] _ SELECT bit FROM 0 => (x MOD 2) = 1, 1 => (x/2 MOD 2) = 1, 2 => (x/4 MOD 2) = 1, 3 => (x/8 MOD 2) = 1, ENDCASE => ERROR ENDLOOP; debug[444444]; RETURN[FALSE]; END; q: PROC[a: INT] = BEGIN deep: INT _ 1606016; rope: Rope.ROPE _ "abc"; [] _ Rope.Map[rope, 0, Rope.Length[rope], action]; debug[8511261]; x _ z-9; END; rData: INT _ 3456; r: PROC[a: INT] RETURNS[INT] = {res: INT _ rData; rData _ a; RETURN[res]}; res1 _ arg1*2; res2 _ arg2*4; foo[!veryBad => BEGIN q[33333]; x _ x+11 END]; BEGIN fluff: INT _ 45; q[22222]; END; END; x: INT _ 10; veryBad: SIGNAL[y: INT] RETURNS[BOOLEAN] = CODE; END.. ψ RMTWTestSubjectImpl.mesa Sturgis, March 13, 1990 2:53 pm PST Subject Stack Examination now we examine the located frame (commented out until we can show the global frame in less than n-squared time) BEGIN frameText: Rope.ROPE _ StackCirio.ShowCurrentFrame[stack, reports]; IO.PutF[reports, "\n\n%g\n\n", IO.rope[frameText]]; END; now we perform the individual expression tests lets skip a frame and look at the following frame and examine (commented out until we can show the global frame in less than n-squared time) BEGIN frameText: Rope.ROPE _ StackCirio.ShowCurrentFrame[stack, reports]; IO.PutF[reports, "\n\n%g\n\n", IO.rope[frameText]]; END; now we perform the individual expression tests overall result: Test Subject ENABLE UNWIND => NULL; we use CARD16 so that this will compile on a D-machine. we need to compile on a D-Machine because our companion code, ExamineOneFrame, will be executed on a D-machine. It would be better if we could test with CARD. ENABLE UNWIND => NULL; inner block of bar Κ V•NewlineDelimiter ™Jšœ™Jšœ#™#J˜šΟk ˜ Icodešœœœ˜#Kšœœ˜Kšœœ˜Kšœœ(œ ˜@Kšœ œ&˜6J˜—š Οnœœœœœœ˜bJš˜J˜™K˜šœœœ˜Jšœœ˜Jšœœ˜Jšœœ˜J˜—J˜Jšœ œ#œ˜8K˜š žœœœ!œ œœ˜_Kš˜Kšœœ˜J˜™ J™NJš™Jšœœ/™CJšœœ™3Jšœ™—J™™.Jš˜šœ œœœ˜+JšœΣ ˜Σ —J˜WJšœ˜—J˜™1J˜-—J˜™ J™NJš™Jšœœ/™CJšœœ™3Jšœ™—J˜™.Jš˜šœ œœœ˜+Jšœ³˜³—šœœœœ˜0J˜:—J˜Wšœ˜ J˜\—Jšœ˜—J˜™Jšœœœ:˜[Jšœœœ;œ˜a—Kšœ˜K˜—šžœœ#œœœœœΟcœœ˜ŠKš˜šœœœ˜ Jšœœ˜Jšœœ˜Jšœœ˜—Jšœœœœ˜'Jšœ œœœ˜*Jšœœœœ˜#Jšœ œœœ˜&šœœ˜J˜—š œœœ&œ œ˜LJšœ œH˜YJšœœœœX˜zJš œœœ#œœ)˜„Jšœ˜Jšœœœ œ˜6J˜Jšœ4œœ˜hšœ+œœ`˜˜Jš˜Jšœœœœ?˜eJšœ9œ#˜`Jšœ œœœ˜@J˜J˜,Jšœ˜—Jšœ˜—J˜JšœP˜Rš œœœ#œ œ˜IJšœ$œœ#˜lšœ˜ ˜šœ#˜)Jšœœ%˜@—Jšœœœ˜ —˜Jš˜Jšœœ7˜CJšœœ˜0Jšœ˜—šœ˜Jšœ(˜*—šœ˜Jšœ˜—Jšœœ˜—Jšœ˜Jšœ˜—J˜šœ œ˜Jš˜Jšœ6˜8š œœœ'œ œ˜MJšœ%œ˜HJšœ*œ#˜QJšœ(œ!˜MJšœ˜—Jš˜—Jšœœœ;˜CJšœ˜Kšœ˜——K˜™ K˜Kšœœœœ˜Jš œœœ œœœ˜3J˜J˜J˜J˜š žœœœœ œœ˜;Jšœ˜—J˜Jšœœœ˜šœœœœ œœœœœ˜YJš˜Jšœœœ™Jšœœ ŸJ˜]Jšœœ˜Jšœœ˜Jšœœ˜ Jšœœœ œ-˜IJšœœ˜ ˜Jš˜Jšœœœ˜Jšœœœ˜Jšœœ˜Jšœ œ˜Jšœœœœ˜Jš œœœ œœ ˜,Jšœœœ ˜Jš œœœœ œ˜(Jšœ œœ˜'šœœœœ œ œœœ˜EJšœœ*™7JšœŸ™Ÿ—Jšœœœ ˜Jšœœœœ œœœœ˜QJšœ œœ ˜!Jšœ œœ ˜#Jš œžœœœœœ˜0Jš œžœœœ œœ˜3J˜Jš œžœœœœœ˜9J˜š œžœœœœœ˜9Jšœœ˜ 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˜2Jšœ˜Jšœ˜Jšœ˜—Jšœœ˜š œœœœœ˜Jšœœœ˜+—J˜˜Jš˜J˜ J˜Jšœ˜—™Jš˜Jšœœ˜J˜ Jšœ˜—Jšœ˜—J˜Jšœœ˜ Jš œ œœœœœ˜0K™—˜K˜—Jšœ˜——…—!‚/Π