Skip to content

Commit

Permalink
Allow input and output to be mixed in Test
Browse files Browse the repository at this point in the history
This was previously forbidden as it can lead to confusing errors,
but it also broke some valid Tests, as GAP can begin outputting
before a complete statement has been inputted.
  • Loading branch information
ChrisJefferson authored and fingolfin committed Jan 10, 2019
1 parent 771f234 commit 5296012
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 24 deletions.
3 changes: 0 additions & 3 deletions lib/test.gi
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ InstallGlobalFunction(ParseTestInput, function(str, ignorecomments, fnam)
Add(pos, i);
i := i+1;
elif Length(lines[i]) > 1 and lines[i]{[1..2]} = "> " then
if Length(outp) > 0 and Length(outp[Length(outp)]) > 0 then
testError("Invalid test file: '> ' continuation found in the middle of a test output");
fi;
if foundcmd then
testError("Invalid test file: #@ command found in the middle of a single test");
fi;
Expand Down
34 changes: 34 additions & 0 deletions tst/testinstall/testing.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Some very basic tests of GAP's Test function
gap> START_TEST("testing.tst");
gap> Print("cheese\n"); Print("bacon"); Print("egg\n");
cheese
baconegg
gap> 2;
2
gap> x := 4;
4
gap> x;
4

#
# Statements where input + output are mixed
# Checks test can handle output directly cut+pasted from GAP's output
#
gap> x :=
> 2;
2
gap> x :=
> 2; y :=
2
> 3;
3
gap> if x = 2 then
> Print("pass\n");
pass
> else
> Print("fail\n");
> fi;

#
#
gap> STOP_TEST("testing.tst", 1);
3 changes: 0 additions & 3 deletions tst/testspecial/broken-test-1.tst

This file was deleted.

2 changes: 0 additions & 2 deletions tst/testspecial/broken-test.g
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Test("broken-test-1.tst", rec(width := 800));
quit;
Test("broken-test-2.tst", rec(width := 800));
quit;
Test("broken-test-3.tst", rec(width := 800));
Expand Down
24 changes: 8 additions & 16 deletions tst/testspecial/broken-test.g.out
Original file line number Diff line number Diff line change
@@ -1,47 +1,39 @@
gap> Test("broken-test-1.tst", rec(width := 800));
Error, Invalid test file: '> ' continuation found in the middle of a test output at broken-test-1.tst:3 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file: '> ' continuation found in the middle of a test output" ); at GAPROOT/lib/test.gi:122 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:566 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("broken-test-2.tst", rec(width := 800));
Error, Invalid test file: #@ command found in the middle of a single test at broken-test-2.tst:5 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file: #@ command found in the middle of a single test" ); at GAPROOT/lib/test.gi:132 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:566 called from
testError( "Invalid test file: #@ command found in the middle of a single test" ); at GAPROOT/lib/test.gi:129 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:563 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("broken-test-3.tst", rec(width := 800));
Error, Invalid test file at broken-test-3.tst:5 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file" ); at GAPROOT/lib/test.gi:138 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:566 called from
testError( "Invalid test file" ); at GAPROOT/lib/test.gi:135 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:563 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("broken-test-4.tst", rec(width := 800));
Error, Invalid test file: Nested #@if at broken-test-4.tst:2 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file: Nested #@if" ); at GAPROOT/lib/test.gi:52 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:566 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:563 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("broken-test-5.tst", rec(width := 800));
Error, Invalid test file: two #@else at broken-test-5.tst:7 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file: two #@else" ); at GAPROOT/lib/test.gi:63 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:566 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:563 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("invalidtestfile.tst", rec(width := 800));
Error, Invalid test file at invalidtestfile.tst:7 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file" ); at GAPROOT/lib/test.gi:138 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:566 called from
testError( "Invalid test file" ); at GAPROOT/lib/test.gi:135 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:563 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
Expand Down

0 comments on commit 5296012

Please sign in to comment.