From 18d629a916970773f417263dd9be15e88d6ee8fb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 31 Aug 2008 09:22:36 -0500 Subject: [PATCH] Add failing unit test --- basis/compiler/tests/folding.factor | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 basis/compiler/tests/folding.factor diff --git a/basis/compiler/tests/folding.factor b/basis/compiler/tests/folding.factor new file mode 100644 index 0000000000..d6868fd034 --- /dev/null +++ b/basis/compiler/tests/folding.factor @@ -0,0 +1,30 @@ +USING: eval tools.test compiler.units vocabs multiline words +kernel classes.mixin arrays ; +IN: compiler.tests + +! Calls to generic words were not folded away. + +[ ] [ [ "compiler.tests.redefine11" forget-vocab ] with-compilation-unit ] unit-test + +[ ] [ + <" + USING: math arrays ; + IN: compiler.tests.folding + GENERIC: foldable-generic ( a -- b ) foldable + M: integer foldable-generic f ; + "> eval +] unit-test + +[ ] [ + <" + USING: math arrays ; + IN: compiler.tests.folding + : fold-test ( -- x ) 10 foldable-generic ; + "> eval +] unit-test + +[ t ] [ + "fold-test" "compiler.tests.folding" lookup execute + "fold-test" "compiler.tests.folding" lookup execute + eq? +] unit-test