📄 mktests
字号:
p2 (from_main)int from_main;{ printf("in p2(%d)\n", from_main); global = 9;}p3 (s)char s[];{ printf("in p3(%s)\n", s); global = 10;}'endcat'echo tests/cc/nested.crm -f tests/cc/nested.ccat > tests/cc/nested.c <<'endcat'/* * Test of nested blocks. */ int i;main (){ i = 3; sub();}sub (){ int i, j; for (i = 1; i <= 10; i++) { int j; j = j + i; } j = 0; for (i = 11; i <= 20; i++) { j = j + i; }}after (){ int a; a = 3;}'endcat'echo tests/cc/sleep.outrm -f tests/cc/sleep.outcat > tests/cc/sleep.out <<'endcat'reading symbolic information ...about to sleepdoneexecution completed, exit code is 0'endcat'echo tests/cc/nested.inrm -f tests/cc/nested.incat > tests/cc/nested.in <<'endcat'stop at 20runwhereprint sub.i, sub.jdelete 1stop at 24contwhereprint sub.i, sub.jprint .i'endcat'echo tests/cc/strings.crm -f tests/cc/strings.ccat > tests/cc/strings.c <<'endcat'/* * Test of displaying strings compiled into the text segment via -R. */char str[] = "this is a test";main (){ f("parameter test");}f (s)char *s;{ abort();}'endcat'echo tests/cc/strings.inrm -f tests/cc/strings.incat > tests/cc/strings.in <<'endcat'whereprint str'endcat'echo tests/cc/arrays.crm -f tests/cc/arrays.ccat > tests/cc/arrays.c <<'endcat'/* * Test of debugging arrays in C. */int a[10], *b;p (i, a, j)int i, a[], j;{ a[3] = i; a[4] = j;}main (){ int i; b = a; for (i = 0; i < 10; i++) { a[i] = i; } p(4, a, 5);}'endcat'echo tests/cc/strings.outrm -f tests/cc/strings.outcat > tests/cc/strings.out <<'endcat'reading symbolic information ...abort at 0x9ff(s = "parameter test"), line 15 in "strings.c"main(0x1, 0x7fffed74, 0x7fffed7c), line 9 in "strings.c""this is a test" 'endcat'echo tests/cc/arrays.inrm -f tests/cc/arrays.incat > tests/cc/arrays.in <<'endcat'whatis p.astop at 10runprint .astepprint a[3], a[4], a[5]stepprint .a'endcat'echo tests/cc/call.inrm -f tests/cc/call.incat > tests/cc/call.in <<'endcat'call printf("starting")stop at 15runcall p1()call p2(3)call p3("blah")call printf("main_local = %d", main_local)print main_localcall callcall call()call p1(3)call p2("blah")'endcat'echo tests/cc/call.outrm -f tests/cc/call.outcat > tests/cc/call.out <<'endcat'reading symbolic information ...startingprintf returns successfully[2] stop at 15in p1in p2(3)in p3(blah)main_local = 19[2] stopped in main at line 15 15 p1();p1 returns successfullyp2 returns successfullyp3 returns successfullyprintf returns successfully19 call call ^ syntax error"call" not call-abletoo many parameters in call to p1type mismatch for from_main in call to p2'endcat'echo tests/mod/Makefilerm -f tests/mod/Makefilecat > tests/mod/Makefile <<'endcat'## Makefile for testing dbx.#.SUFFIXES:.SUFFIXES: .mod .def .pcd .s .o .x .t .in .tst .outMOD = modTESTDBX = ../../tdbxTESTS = imports.t arrays.t records.t procvars.t sets.t \ nested.t reals.t call.t assign.t recur.t jsb.t stkcmds.tPROGS = imports.x arrays.x records.x procvars.x sets.x \ nested.x reals.x call.x assign.x recur.x jsb.x stkcmds.x## Suffix conventions:## .mod Modula-2 source# .def Modula-2 definitions file# .pcd P-code intermediate source# .s assembly code file# .o object file# .x executable file# .t dummy file represented last time tested# .in input for testing# .tst test output# .out expected output#.mod.x: ${MOD} -g $*.mod -o tmp mv tmp $*.x.mod.o: ${MOD} -c -g $*.mod.def.mod: touch $*.mod.in.tst: csh -f -c "${TESTDBX} $*.x < $*.in |& tail +3 >! $*.tst".x.t: @echo " $*" @rm -f tmp @csh -f -c "${TESTDBX} $*.x < $*.in |& tail +3 > tmp" @check tmp $*.out @rm -f tmp @rm -f $*.t @touch $*.tpassed: ${PROGS} beforemsg ${TESTS} @echo "passed Modula-2 tests"beforemsg: @echo "" @echo "Modula-2 tests:"IMPORTSOBJ = imports.o imported.o imptypes.oimports.x: ${IMPORTSOBJ} ${MOD} -g ${IMPORTSOBJ} -o tmp mv tmp imports.xjsb.x: jsb.mod ${MOD} -O -g jsb.mod -o tmp mv tmp jsb.ximports.t: imports.x ${TESTDBX}arrays.t: arrays.x ${TESTDBX}records.t: records.x ${TESTDBX}procvars.t: procvars.x ${TESTDBX}sets.t: sets.x ${TESTDBX}nested.t: nested.x ${TESTDBX}reals.t: reals.x ${TESTDBX}call.t: call.x ${TESTDBX}assign.t: assign.x ${TESTDBX}recur.t: recur.x ${TESTDBX}jsb.t: jsb.x ${TESTDBX}stkcmds.t: stkcmds.x ${TESTDBX}'endcat'echo tests/mod/checkrm -f tests/mod/checkcat > tests/mod/check <<'endcat'#! /bin/csh -f## check <test output> <expected output>## Check to see if test output matches expected output.# If not, run diff and ask if differences are "ok". If so,# install new output as expected output.#cmp -s $1 $2if ($status != 0) then diff $1 $2 echo -n "ok? " if ($< != y) then exit 1 endif mv $1 $2endifexit 0'endcat'echo tests/mod/imports.inrm -f tests/mod/imports.incat > tests/mod/imports.in <<'endcat'whereis vwhereis pwhatis main.pwhatis main.Twhatis main.OTwhatis imported.pstop in imported.Blahrunwhere'endcat'echo tests/mod/records.modrm -f tests/mod/records.modcat > tests/mod/records.mod <<'endcat'module main;type Rec = record charValue : char; intValue : integer; subrange : [0..1000]; realValue : real; end;var r : Rec;begin r.charValue := 'c'; r.intValue := 3; r.subrange := 10; r.realValue := 3.4;end main.'endcat'echo tests/mod/records.inrm -f tests/mod/records.incat > tests/mod/records.in <<'endcat'whatis Recwhatis rrunprint rprint r.realValue, r.subrange, r.intValue, r.charValue'endcat'echo tests/mod/imports.modrm -f tests/mod/imports.modcat > tests/mod/imports.mod <<'endcat'module main;from imptypes import RT;import imported;type RT = pointer to record i, j : integer; end;var p : imported.T; q : imported.OT; r : RT;begin new(r); r^.i := 3; r^.j := 4; imported.Blah;end main.'endcat'echo tests/mod/imported.defrm -f tests/mod/imported.defcat > tests/mod/imported.def <<'endcat'definition module imported;export qualified Blah, T, OT;export v;type OT; T = record a, b : integer; end;var v : integer;procedure Blah ;end imported.'endcat'echo tests/mod/imported.modrm -f tests/mod/imported.modcat > tests/mod/imported.mod <<'endcat'implementation module imported;type OT = integer;var p : OT;procedure Blah;begin p := 3;end Blah;end imported.'endcat'echo tests/mod/imports.outrm -f tests/mod/imports.outcat > tests/mod/imports.out <<'endcat'reading symbolic information ....vmem.modmalloc.p mem.Storage_DEALLOCATE.p mem.Storage_ALLOCATE.p imported.p main.pvar p : main.T;type T = record a : integer; b : integer;end;type OT = integer;var p : integer;[1] stop in Blah[1] stopped in Blah at line 8 in file "imported.mod" 8 procedure Blah;Blah, line 8 in "imported.mod"_init(0x1, 0x7fffed74, 0x7fffed7c), line 16 in "imports.mod"'endcat'echo tests/mod/records.outrm -f tests/mod/records.outcat > tests/mod/records.out <<'endcat'reading symbolic information ...type Rec = record charValue : char; intValue : integer; subrange : 0..1000; realValue : real;end;var r : Rec;execution completed, exit code is 0(charValue = 'c', intValue = 3, subrange = 10, realValue = 3.4) 3.4 10 3 'c' 'endcat'echo tests/mod/arrays.modrm -f tests/mod/arrays.modcat > tests/mod/arrays.mod <<'endcat'module main;type Color = (RED, BLUE, GREEN);var a : array [1..10] of integer; i : integer; b : array Color of integer; c : Color;procedure p (i : integer; var a : array of integer; j : integer);begin a[3] := i; a[4] := j;end p;begin for i := 1 to 10 do a[i] := i; end; p(4, a, 5); b[BLUE] := 3; c := RED;end main.'endcat'echo tests/mod/sets.inrm -f tests/mod/sets.incat > tests/mod/sets.in <<'endcat'whatis Colorwhatis ColorSetstop in prunstepwherestepprint sets.sstepstepwhereprint sets.s'endcat'echo tests/mod/arrays.inrm -f tests/mod/arrays.incat > tests/mod/arrays.in <<'endcat'whatis p.astop at 12runprint aprint a[3], a[4], a[5]stepstepwhereprint b, c'endcat'echo tests/mod/arrays.outrm -f tests/mod/arrays.outcat > tests/mod/arrays.out <<'endcat'reading symbolic information ...(var parameter) a : array[integer] of integer;[1] stop at "arrays.mod":12[1] stopped in p at line 12 in file "arrays.mod" 12 a[3] := i;(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) 4 5 6 stopped in p at line 13 in file "arrays.mod" 13 a[4] := j;stopped in _init at line 21 in file "arrays.mod" 21 b[BLUE] := 3;_init(0x1, 0x7fffed74, 0x7fffed7c), line 21 in "arrays.mod"(0, 0, 0) RED 'endcat'echo tests/mod/sets.modrm -f tests/mod/sets.modcat > tests/mod/sets.mod <<'endcat'module sets;type Color = (RED, BLUE, GREEN); ColorSet = set of Color;var s : ColorSet;procedure p (var s : ColorSet);begin s := ColorSet{RED, BLUE};end p;begin p(s); if BLUE in s then s := s - ColorSet{BLUE}; end;end sets.'endcat'echo tests/mod/variants.modrm -f tests/mod/variants.modcat > tests/mod/variants.mod <<'endcat'module main;type ElementType = (CHAR, INT, REAL); VR = record case tag : ElementType of CHAR: charValue : char;| INT: intValue : integer;| REAL: realValue : real; end; end;var vr : VR;begin vr.tag := CHAR; vr.charValue := 'c'; vr.tag := INT; vr.intValue := 3; vr.tag := REAL; vr.realValue := 3.4;end main.'endcat'echo tests/mod/stkcmds.modrm -f tests/mod/stkcmds.modcat > tests/mod/stkcmds.mod <<'endcat'module main;var i : integer;procedure p2 (i : integer);begin if i < 5 then p2(i+1); end;end p2;procedure p1 (i : integer);begin p2(i+1);end p1;begin i := 0; p1(i+1);end main.'endcat'echo tests/mod/procvars.inrm -f tests/mod/procvars.incat > tests/mod/procvars.in <<'endcat'whatis q.tstop in pstop in qrunstepstepprint tcontwherestepstepprint j'endcat'echo tests/mod/nested.modrm -f tests/mod/nested.modcat > tests/mod/nested.mod <<'endcat'(* * Test of nested procedures and modules. *)module main;var i : integer;procedure p (var i : integer);var j : integer; procedure nestedp (var j : integer); var i : integer; begin i := j + 2; j := i; end nestedp;begin j := i + 1; nestedp(j); i := j;end p;begin i := 3; p(i);end main.'endcat'echo tests/mod/procvars.modrm -f tests/mod/procvars.modcat > tests/mod/procvars.mod <<'endcat'(* * Test of procedure variables. *)module main;procedure p (var i : integer);begin i := 3;end p;procedure q ;var t : procedure(var integer); j : integer;begin t := p; t(j); j := j + 1;end q;begin q;end main.'endcat'echo tests/mod/procvars.outrm -f tests/mod/procvars.outcat > tests/mod/procvars.out <<'endcat'reading symbolic information ...var t : (class 23);[1] stop in p[2] stop in q[2] stopped in q at line 12 in file "procvars.mod" 12 procedure q ;stopped in q at line 17 in file "procvars.mod" 17 t := p;stopped in q at line 18 in file "procvars.mod" 18 t(j);p [1] stopped in p at line 7 in file "procvars.mod" 7 procedure p (var i : integer);p(i = 0), line 7 in "procvars.mod"q, line 18 in "procvars.mod"_init(0x1, 0x7fffed74, 0x7fffed7c), line 23 in "procvars.mod"stopped in p at line 9 in file "procvars.mod" 9 i := 3;stopped in q at line 19 in file "procvars.mod" 19 j := j + 1;3 'endcat'echo tests/mod/sets.outrm -f tests/mod/sets.outcat > tests/mod/sets.out <<'endcat'reading symbolic information ...type Color = (RED, BLUE, GREEN);type ColorSet = set of Color;[1] stop in p[1] stopped in p at line 8 in file "sets.mod" 8 procedure p (var s : ColorSet);stopped in p at line 10 in file "sets.mod" 10 s := ColorSet{RED, BLUE};p(s = {}), line 10 in "sets.mod"_init(0x1, 0x7fffed78, 0x7fffed80), line 14 in "sets.mod"stopped in _init at line 15 in file "sets.mod" 15 if BLUE in s then{RED, BLUE} stopped in _init at line 16 in file "sets.mod" 16 s := s - ColorSet{BLUE};execution completed, exit code is 0exit(0x0) at 0x1602_init(0x1, 0x7fffed78, 0x7fffed80), line 16 in "sets.mod"{RED} 'endcat'echo tests/mod/imptypes.defrm -f tests/mod/imptypes.defcat > tests/mod/imptypes.def <<'endcat'definition module imptypes;export qualified RT;type RT;end imptypes.'endcat'echo tests/mod/imptypes.modrm -f tests/mod/imptypes.modcat > tests/mod/imptypes.mod <<'endcat'implementation module imptypes;end imptypes.'endcat'echo tests/mod/jsb.outrm -f tests/mod/jsb.outcat > tests/mod/jsb.out <<'endcat'reading symbolic information ...[1] stop in pin p(3, blah, 4)[1] stopped in p at line 7 in file "jsb.mod" 7 procedure p (i : integer; s : array of char; j : integer);p(i = 3, s = 'blah', j = 4), line 7 in "jsb.mod"_init(0x1, 0x7fffed78, 0x7fffed80), line 15 in "jsb.mod"3 execution completed, exit code is 0'endcat'echo tests/mod/nested.inrm -f tests/mod/nested.incat > tests/mod/nested.in <<'endcat'whereis iwhereis jstop at 18runprint i, j, main.i, p.i, p.jstepprint i, j, main.icontprint main.i'endcat'echo tests/mod/jsb.modrm -f tests/mod/jsb.modcat > tests/mod/jsb.mod <<'endcat'module main;from io import Writef, output;var global : integer;procedure p (i : integer; s : array of char; j : integer);begin Writef(output, "in p(%d, %s, %d)\n", i, s, j); global := 10;end p;begin global := 3; p(3, "blah", 4);end main.'endcat'echo tests/mod/nested.outrm -f tests/mod/nested.outcat > tests/mod/nested.out <<'endcat'reading symbolic information ...main.p.i main.p.nestedp.i main.imain.p.j main.p.nestedp.j[1] stop at "nested.mod":18[1] stopped in nestedp at line 18 in file "nested.mod" 18 j := i;6 4 3 3 4 stopped in main.p at line 24 in file "nested.mod" 24 i := j;3 6 3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -