]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/tree/normalization/normalization-tests.factor
Merge branch 'master' into new_optimizer
[factor.git] / basis / compiler / tree / normalization / normalization-tests.factor
1 IN: compiler.tree.normalization.tests
2 USING: compiler.tree.builder compiler.tree.normalization
3 compiler.tree sequences accessors tools.test kernel math ;
4
5 \ count-introductions must-infer
6 \ fixup-enter-recursive must-infer
7 \ eliminate-introductions must-infer
8 \ normalize must-infer
9
10 [ 3 ] [ [ 3drop 1 2 3 ] build-tree count-introductions ] unit-test
11
12 [ 4 ] [ [ 3drop 1 2 3 3drop drop ] build-tree count-introductions ] unit-test
13
14 [ 3 ] [ [ [ drop ] [ 2drop 3 ] if ] build-tree count-introductions ] unit-test
15
16 [ 2 ] [ [ 3 [ drop ] [ 2drop 3 ] if ] build-tree count-introductions ] unit-test
17
18 : foo ( -- ) swap ; inline recursive
19
20 : recursive-inputs ( nodes -- n )
21     [ #recursive? ] find nip child>> first in-d>> length ;
22
23 [ 0 2 ] [
24     [ foo ] build-tree
25     [ recursive-inputs ]
26     [ normalize recursive-inputs ] bi
27 ] unit-test
28
29 [ ] [ [ [ 1 ] [ 2 ] if + * ] build-tree normalize drop ] unit-test