1 USING: accessors namespaces assocs kernel sequences math
2 tools.test words sets combinators.short-circuit
3 stack-checker.state compiler.tree compiler.tree.builder
4 compiler.tree.recursive compiler.tree.normalization
5 compiler.tree.propagation compiler.tree.cleanup
6 compiler.tree.def-use arrays kernel.private sorting math.order
7 binary-search compiler.tree.checker ;
8 IN: compiler.tree.def-use.tests
11 [ 1 2 3 ] build-tree compute-def-use drop
14 [ values [ uses>> [ #return? ] all? ] all? ]
18 : test-def-use ( quot -- )
27 : too-deep ( a b -- c )
28 dup [ drop ] [ 2dup too-deep too-deep drop ] if ; inline recursive
39 ! compute-def-use checks for SSA violations, so we use that to
40 ! ensure we generate some common patterns correctly.
42 [ [ drop ] each-integer ]
43 [ [ 2drop ] curry each-integer ]
44 [ [ 1 ] [ 2 ] if drop ]
46 [ [ 1 ] [ dup ] if drop ]
47 [ { array } declare swap ]
49 [ [ 1 ] [ 2 ] compose call + ]
50 [ [ 1 ] 2 [ + ] curry compose call + ]
51 [ [ 1 ] [ call 2 ] curry call + ]
52 [ [ 1 ] [ 2 ] compose swap [ 1 ] [ 2 ] if + * ]
53 [ dup slice? [ dup array? [ ] [ ] if ] [ ] if ]
54 [ dup [ drop f ] [ "A" throw ] if ]
56 [ [ <=> ] with search ]
58 [ ] swap [ test-def-use ] curry unit-test