]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/tests/redefine5.factor
Solution to Project Euler problem 65
[factor.git] / basis / compiler / tests / redefine5.factor
1 USING: eval tools.test compiler.units vocabs multiline words
2 kernel ;
3 IN: compiler.tests.redefine5
4
5 ! Regression: if dispatch was eliminated but method was not inlined,
6 ! compiled usage information was not recorded.
7
8 [ "compiler.tests.redefine5" forget-vocab ] with-compilation-unit
9
10 [ ] [
11     <"
12     USING: sorting kernel math.order ;
13     IN: compiler.tests.redefine5
14     GENERIC: my-generic ( a -- b )
15     M: object my-generic [ <=> ] sort ;
16     : my-inline ( a -- b ) my-generic ;
17     "> eval( -- )
18 ] unit-test
19
20 [ ] [
21     <"
22     USE: kernel
23     IN: compiler.tests.redefine5
24     TUPLE: my-tuple ;
25     M: my-tuple my-generic drop 0 ;
26     "> eval( -- )
27 ] unit-test
28
29 [ 0 ] [
30     "my-tuple" "compiler.tests.redefine5" lookup boa
31     "my-inline" "compiler.tests.redefine5" lookup execute
32 ] unit-test