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 committed Jan 10, 2019
1 parent 8079c16 commit 85eb95f
Show file tree
Hide file tree
Showing 5 changed files with 27 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
19 changes: 19 additions & 0 deletions tst/testinstall/interpreter.tst
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,25 @@ gap> Unbind(l![fail]);
Error, PosObj Assignment: <position> must be a positive small integer (not the\
value 'fail')

#
# Statements where input + output are mixed
# Checks test can handle output directly cute+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("interpreter.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 85eb95f

Please sign in to comment.