forked from gap-system/gap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: more tests, and some minor code cleanup
- Loading branch information
Showing
14 changed files
with
283 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# Tests for functions defined in src/exprs.c | ||
# | ||
gap> START_TEST("kernel/exprs.tst"); | ||
|
||
# | ||
|
||
# | ||
gap> STOP_TEST("kernel/exprs.tst", 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# | ||
# Tests for functions defined in src/intrprtr.c | ||
# | ||
gap> START_TEST("kernel/intrprtr.tst"); | ||
|
||
# test Assert with two arguments | ||
gap> Assert(0, 0); | ||
Error, <condition> in Assert must yield 'true' or 'false' (not a integer) | ||
gap> Assert(0, true); | ||
gap> Assert(0, false); | ||
Error, Assertion failure | ||
gap> Assert(100, 0); | ||
gap> Assert(100, true); | ||
gap> Assert(100, false); | ||
|
||
# test Assert with three arguments | ||
gap> Assert(0, 0, "message\n"); | ||
Error, <condition> in Assert must yield 'true' or 'false' (not a integer) | ||
gap> Assert(0, true, "message\n"); | ||
gap> Assert(0, false, "message\n"); | ||
message | ||
gap> Assert(0, false, 1); Print("\n"); # message can also be any object | ||
1 | ||
gap> Assert(100, 0, "message\n"); | ||
gap> Assert(100, true, "message\n"); | ||
gap> Assert(100, false, "message\n"); | ||
|
||
# | ||
gap> STOP_TEST("kernel/intrprtr.tst", 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Tests for functions defined in src/set.c | ||
# | ||
gap> START_TEST("kernel/set.tst"); | ||
|
||
# | ||
gap> a := [-10..10];; INTER_RANGE(a,[-10..10]); a; | ||
[ -10 .. 10 ] | ||
gap> a := [-10..10];; INTER_RANGE(a,[-11..10]); a; | ||
[ -10 .. 10 ] | ||
gap> a := [-10..10];; INTER_RANGE(a,[-10..11]); a; | ||
[ -10 .. 10 ] | ||
gap> a := [-10..10];; INTER_RANGE(a,[-11..9]); a; | ||
[ -10 .. 9 ] | ||
gap> a := [-10..10];; INTER_RANGE(a,[-9..11]); a; | ||
[ -9 .. 10 ] | ||
gap> a := [-10..10];; INTER_RANGE(a,[-21,-18..21]); a; | ||
[ -9, -6 .. 9 ] | ||
gap> a := [-10..10];; INTER_RANGE(a,[-6,-3..21]); a; | ||
[ -6, -3 .. 9 ] | ||
gap> a := [-10..10];; INTER_RANGE(a,[-21,-18..6]); a; | ||
[ -9, -6 .. 6 ] | ||
gap> a := [-10,-7..20];; INTER_RANGE(a,[-21,-18..6]); a; | ||
[ ] | ||
gap> a := [-9,-6..21];; INTER_RANGE(a,[-21,-18..6]); a; | ||
[ -9, -6 .. 6 ] | ||
gap> a := [-12,-10..20];; INTER_RANGE(a,[-21,-18..6]); a; | ||
[ -12, -6 .. 6 ] | ||
gap> a := [-15,-12..3];; INTER_RANGE(a,[-21,-18..6]); a; | ||
[ -15, -12 .. 3 ] | ||
gap> a := [-12,-9..3];; INTER_RANGE(a,[-21,-18..6]); a; | ||
[ -12, -9 .. 3 ] | ||
gap> a := [-9,-6..3];; INTER_RANGE(a,[-21,-18..6]); a; | ||
[ -9, -6 .. 3 ] | ||
gap> a := [-9,-3..3];; INTER_RANGE(a,[-21,-18..6]); a; | ||
[ -9, -3 .. 3 ] | ||
gap> a := [-9,-5..3];; INTER_RANGE(a,[-21,-18..6]); a; | ||
[ -9, 3 ] | ||
|
||
# | ||
gap> STOP_TEST("kernel/set.tst", 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# | ||
# Tests for functions defined in src/set.c | ||
# | ||
gap> START_TEST("kernel/set.tst"); | ||
|
||
# | ||
gap> IsSet(1); | ||
false | ||
gap> LIST_SORTED_LIST(1); | ||
Error, Set: <list> must be a small list (not a integer) | ||
|
||
# | ||
gap> IS_EQUAL_SET; | ||
function( list1, list2 ) ... end | ||
gap> IS_EQUAL_SET(1,1); | ||
Error, IsEqualSet: <list1> must be a small list (not a integer) | ||
gap> IS_EQUAL_SET([],1); | ||
Error, IsEqualSet: <list2> must be a small list (not a integer) | ||
gap> IS_EQUAL_SET([],[]); | ||
true | ||
|
||
# | ||
gap> IS_SUBSET_SET; | ||
function( set1, set2 ) ... end | ||
gap> IS_SUBSET_SET(1,1); | ||
Error, IsSubsetSet: <set1> must be a small list (not a integer) | ||
gap> IS_SUBSET_SET([],1); | ||
Error, IsSubsetSet: <set2> must be a small list (not a integer) | ||
gap> IS_SUBSET_SET([],[]); | ||
true | ||
gap> IS_SUBSET_SET([1,2,3],[1,2]); | ||
true | ||
gap> IS_SUBSET_SET([1,2,3],[2,1]); | ||
true | ||
gap> IS_SUBSET_SET([1,2,3],[,1]); | ||
true | ||
gap> IS_SUBSET_SET([1,2,3],[1,2,4]); | ||
false | ||
gap> IS_SUBSET_SET([1,2,3],[2,1,4]); | ||
false | ||
gap> IS_SUBSET_SET([1,2,3],[,1,4]); | ||
false | ||
|
||
# | ||
gap> ADD_SET; | ||
function( set, val ) ... end | ||
gap> ADD_SET(1,1); | ||
Error, AddSet: <set> must be a mutable proper set (not a integer) | ||
|
||
# | ||
gap> REM_SET; | ||
function( set, val ) ... end | ||
gap> REM_SET(1,1); | ||
Error, RemoveSet: <set> must be a mutable proper set (not a integer) | ||
|
||
# | ||
gap> UNITE_SET; | ||
function( set1, set2 ) ... end | ||
gap> UNITE_SET(1,1); | ||
Error, UniteSet: <set1> must be a mutable proper set (not a integer) | ||
gap> UNITE_SET([],1); | ||
Error, UniteSet: <set2> must be a small list (not a integer) | ||
gap> UNITE_SET([],[]); | ||
|
||
# | ||
gap> INTER_SET; | ||
function( set1, set2 ) ... end | ||
gap> INTER_SET(1,1); | ||
Error, IntersectSet: <set1> must be a mutable proper set (not a integer) | ||
gap> INTER_SET([],1); | ||
Error, IntersectSet: <set2> must be a small list (not a integer) | ||
gap> INTER_SET([],[]); | ||
|
||
# | ||
gap> SUBTR_SET; | ||
function( set1, set2 ) ... end | ||
gap> SUBTR_SET(1,1); | ||
Error, SubtractSet: <set1> must be a mutable proper set (not a integer) | ||
gap> SUBTR_SET([],1); | ||
Error, SubtractSet: <set2> must be a small list (not a integer) | ||
gap> SUBTR_SET([],[]); | ||
|
||
# | ||
gap> STOP_TEST("kernel/set.tst", 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# | ||
# Tests for functions defined in src/stats.c | ||
# | ||
gap> START_TEST("kernel/stats.tst"); | ||
|
||
# test checks in ExecForRangeHelper | ||
gap> f := function(a) local x; for x in [a..1] do od; end;; | ||
gap> f('x'); | ||
Error, Range: <first> must be an integer (not a character) | ||
gap> f := function(a) local x; for x in [1..a] do od; end;; | ||
gap> f('x'); | ||
Error, Range: <last> must be an integer (not a character) | ||
|
||
# test Assert with two arguments | ||
gap> function() Assert(0, 0); end(); | ||
Error, Assertion condition must evaluate to 'true' or 'false', not a integer | ||
gap> function() Assert(0, true); end(); | ||
gap> function() Assert(0, false); end(); | ||
Error, Assertion failure | ||
gap> function() Assert(100, 0); end(); | ||
gap> function() Assert(100, true); end(); | ||
gap> function() Assert(100, false); end(); | ||
|
||
# test Assert with three arguments | ||
gap> function() Assert(0, 0, "message\n"); end(); | ||
Error, Assertion condition must evaluate to 'true' or 'false', not a integer | ||
gap> function() Assert(0, true, "message\n"); end(); | ||
gap> function() Assert(0, false, "message\n"); end(); | ||
message | ||
gap> function() Assert(0, false, 1); Print("\n"); end(); # message can also be any object | ||
1 | ||
gap> function() Assert(100, 0, "message\n"); end(); | ||
gap> function() Assert(100, true, "message\n"); end(); | ||
gap> function() Assert(100, false, "message\n"); end(); | ||
|
||
# | ||
gap> STOP_TEST("kernel/stats.tst", 1); |
Oops, something went wrong.