1 ! Copyright (C) 2007 Slava Pestov, Daniel Ehrenberg.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: math kernel memoize tools.test parser generalizations
4 prettyprint io.streams.string sequences eval ;
8 dup 1 <= [ drop 1 ] [ dup 1 - fib swap 2 - fib + ] if ;
10 [ 89 ] [ 10 fib ] unit-test
12 [ "USING: kernel math memoize generalizations ; IN: memoize.tests MEMO: x ( a b c d e -- f g h i j ) [ 1+ ] 4 ndip ;" eval ] must-fail
14 MEMO: see-test ( a -- b ) reverse ;
16 [ "USING: memoize sequences ;\nIN: memoize.tests\nMEMO: see-test ( a -- b ) reverse ;\n" ]
17 [ [ \ see-test see ] with-string-writer ]
20 [ ] [ "IN: memoize.tests : fib ;" eval ] unit-test
22 [ "IN: memoize.tests\n: fib ( -- ) ;\n" ] [ [ \ fib see ] with-string-writer ] unit-test