]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/tests/redefine9.factor
Solution to Project Euler problem 65
[factor.git] / basis / compiler / tests / redefine9.factor
1 USING: eval tools.test compiler.units vocabs multiline words
2 kernel generic.math ;
3 IN: compiler.tests.redefine9
4
5 ! Mixin redefinition did not recompile all necessary words.
6
7 [ ] [ [ "compiler.tests.redefine9" forget-vocab ] with-compilation-unit ] unit-test
8
9 [ ] [
10     <"
11     USING: kernel math math.order sorting ;
12     IN: compiler.tests.redefine9
13     MIXIN: my-mixin
14     INSTANCE: fixnum my-mixin
15     GENERIC: my-generic ( a -- b )
16     ! We add the bogus quotation here to hinder inlining
17     ! since otherwise we cannot trigger this bug.
18     M: my-mixin my-generic 1 + [ [ <=> ] sort ] drop ;
19     "> eval( -- )
20 ] unit-test
21
22 [ ] [
23     <"
24     USE: math
25     IN: compiler.tests.redefine9
26     TUPLE: my-tuple ;
27     INSTANCE: my-tuple my-mixin
28     "> eval( -- )
29 ] unit-test
30
31 [
32     "my-tuple" "compiler.tests.redefine9" lookup boa
33     "my-generic" "compiler.tests.redefine9" lookup
34     execute
35 ] [ no-math-method? ] must-fail-with