]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/tests/redefine8.factor
Solution to Project Euler problem 65
[factor.git] / basis / compiler / tests / redefine8.factor
1 USING: eval tools.test compiler.units vocabs multiline words
2 kernel ;
3 IN: compiler.tests.redefine8
4
5 ! Mixin redefinition did not recompile all necessary words.
6
7 [ ] [ [ "compiler.tests.redefine8" forget-vocab ] with-compilation-unit ] unit-test
8
9 [ ] [
10     <"
11     USING: kernel math math.order sorting ;
12     IN: compiler.tests.redefine8
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.redefine8
26     INSTANCE: float my-mixin
27     "> eval( -- )
28 ] unit-test
29
30 [ 2.0 ] [
31     1.0 "my-generic" "compiler.tests.redefine8" lookup execute
32 ] unit-test