1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#
# Tests for functions defined in src/exprs.c
#
gap> START_TEST("kernel/exprs.tst");
# EvalPermExpr
gap> f:={a,b} -> (a,b);;
gap> f(1,2);
(1,2)
gap> f(2,1);
(1,2)
gap> f(2,2);
Error, Permutation: cycles must be disjoint and duplicate-free
gap> f(2,fail);
Error, Permutation: <expr> must be a positive integer (not a boolean or fail)
gap> f:={a,b,c,d} -> (a,b,c,d);;
gap> f(1,2,3,4);
(1,2,3,4)
gap> f(1,2,3,2);
Error, Permutation: cycles must be disjoint and duplicate-free
gap> f:={a,b,c,d} -> (a,b)(c,d);;
gap> f(1,2,3,4);
(1,2)(3,4)
gap> f(1,2,3,2);
Error, Permutation: cycles must be disjoint and duplicate-free
gap> f(1,2,1,2);
Error, Permutation: cycles must be disjoint and duplicate-free
# EvalRangeExpr
gap> f:={a,b,c} -> [a,b..c];;
gap> f(1,2,3);
[ 1 .. 3 ]
gap> f(1,3,5);
[ 1, 3 .. 5 ]
gap> f(1,1,1);
Error, Range: <second> must not be equal to <first> (1)
gap> f(1,3,4);
Error, Range: <last>-<first> (3) must be divisible by <inc> (2)
# EvalRecExpr
gap> f:={a,b} -> rec( (a) := b );;
gap> f(1,2);
rec( 1 := 2 )
gap> f(fail,2);
Error, Record: '<rec>.(<obj>)' <obj> must be a string or an integer
# PrintBinop
gap> Display(x-> (-2)^x);
function ( x )
return (-2) ^ x;
end
gap> Display( x -> 2 * f( 3 + 4 ));
function ( x )
return 2 * f( (3 + 4) );
end
# PrintTildeExpr, EvalTildeExpr
gap> l := [x -> ~];;
gap> f := l[1];;
gap> Display(f);
function ( x )
return ~;
end
gap> f(1);
Error, '~' does not have a value here
#
gap> STOP_TEST("kernel/exprs.tst", 1);
|