]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/tests/folding.factor
Solution to Project Euler problem 65
[factor.git] / basis / compiler / tests / folding.factor
1 USING: eval tools.test compiler.units vocabs multiline words
2 kernel classes.mixin arrays ;
3 IN: compiler.tests.folding
4
5 ! Calls to generic words were not folded away.
6
7 [ ] [ [ "compiler.tests.redefine11" forget-vocab ] with-compilation-unit ] unit-test
8
9 [ ] [
10     <"
11     USING: math arrays ;
12     IN: compiler.tests.folding
13     GENERIC: foldable-generic ( a -- b ) foldable
14     M: integer foldable-generic f <array> ;
15     "> eval( -- )
16 ] unit-test
17
18 [ ] [
19     <"
20     USING: math arrays ;
21     IN: compiler.tests.folding
22     : fold-test ( -- x ) 10 foldable-generic ;
23     "> eval( -- )
24 ] unit-test
25
26 [ t ] [
27     "fold-test" "compiler.tests.folding" lookup execute
28     "fold-test" "compiler.tests.folding" lookup execute
29     eq?
30 ] unit-test