Skip to content

Commit

Permalink
Added test function to compare syntax trees
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasguts committed May 4, 2019
1 parent d012fcd commit 3ade001
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions tst/testinstall/syntaxtree.tst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ gap> SyntaxTree(x -> x);
<syntax tree>
gap> SyntaxTree(\+);
Error, SYNTAX_TREE: <func> must be a plain GAP function (not a function)
gap> test_tree := function( f )
> local curr_tree, new_func, new_tree;
> curr_tree := SYNTAX_TREE( f );
> new_func := SYNTAX_TREE_CODE( curr_tree );
> new_tree := SYNTAX_TREE( new_func );
> return new_tree = curr_tree;
> end;;

# Just try compiling all functions we can find in the workspace
# to see nothing crashes.
Expand Down Expand Up @@ -37,8 +44,7 @@ gap> testit := function(f)
> local tree;
> tree := SYNTAX_TREE(f);
> Display(tree);
> # TODO: recode the tree, then decode again and compare
> return true;
> return test_tree( f );
> end;;

# T_PROCCALL_0ARGS
Expand Down Expand Up @@ -2687,6 +2693,23 @@ rec(
type := "T_FUNC_EXPR",
variadic := false )
true
gap> testit( x -> [, [] ] );
rec(
nams := [ "x" ],
narg := 1,
nloc := 0,
stats := rec(
statements := [ rec(
obj := rec(
list := [ , rec(
list := [ ],
type := "T_LIST_EXPR" ) ],
type := "T_LIST_EXPR" ),
type := "T_RETURN_OBJ" ) ],
type := "T_SEQ_STAT" ),
type := "T_FUNC_EXPR",
variadic := false )
true

# T_LIST_TILDE_EXPR
gap> testit(x -> [~]);
Expand Down

0 comments on commit 3ade001

Please sign in to comment.