1 USING: destructors eval io io.streams.string kernel math memory
2 namespaces parser sequences strings tools.annotations
3 tools.test tools.time ;
4 IN: tools.annotations.tests
12 GENERIC: some-generic ( a -- b )
14 M: integer some-generic 1 + ;
16 { 4 } [ 3 some-generic ] unit-test
18 { } [ \ some-generic watch ] unit-test
20 { 4 } [ 3 some-generic ] unit-test
22 { } [ "IN: tools.annotations.tests USE: math M: integer some-generic 1 - ;" eval( -- ) ] unit-test
24 { 2 } [ 3 some-generic ] unit-test
26 { } [ \ some-generic reset ] unit-test
28 { 2 } [ 3 some-generic ] unit-test
31 GENERIC: another-generic ( a -- b )
33 M: object another-generic ;
35 \ another-generic watch
37 { } [ "IN: tools.annotations.tests GENERIC: another-generic ( a -- b )" eval( -- ) ] unit-test
39 { } [ \ another-generic reset ] unit-test
41 { "" } [ [ 3 another-generic drop ] with-string-writer ] unit-test
43 ! reset should do the right thing for generic words
44 { } [ \ another-generic watch ] unit-test
46 GENERIC: blah-generic ( a -- b )
48 M: string blah-generic ;
50 { } [ M\ string blah-generic watch ] unit-test
52 { "hi" } [ "hi" blah-generic ] unit-test
54 ! See how well watch interacts with optimizations.
55 GENERIC: my-generic ( a -- b )
56 M: object my-generic ;
63 { } [ some-code ] unit-test
65 ! Make sure annotations work on primitives
69 { f } [ [ [ gc ] with-error>output ] with-string-writer empty? ] unit-test