1 USING: tools.test tools.annotations tools.time math parser eval
2 io.streams.string kernel strings ;
3 IN: tools.annotations.tests
11 GENERIC: some-generic ( a -- b )
13 M: integer some-generic 1 + ;
15 [ 4 ] [ 3 some-generic ] unit-test
17 [ ] [ \ some-generic watch ] unit-test
19 [ 4 ] [ 3 some-generic ] unit-test
21 [ ] [ "IN: tools.annotations.tests USE: math M: integer some-generic 1 - ;" eval( -- ) ] unit-test
23 [ 2 ] [ 3 some-generic ] unit-test
25 [ ] [ \ some-generic reset ] unit-test
27 [ 2 ] [ 3 some-generic ] unit-test
30 GENERIC: another-generic ( a -- b )
32 M: object another-generic ;
34 \ another-generic watch
36 [ ] [ "IN: tools.annotations.tests GENERIC: another-generic ( a -- b )" eval( -- ) ] unit-test
38 [ ] [ \ another-generic reset ] unit-test
40 [ "" ] [ [ 3 another-generic drop ] with-string-writer ] unit-test
42 ! reset should do the right thing for generic words
43 [ ] [ \ another-generic watch ] unit-test
45 GENERIC: blah-generic ( a -- b )
47 M: string blah-generic ;
49 [ ] [ M\ string blah-generic watch ] unit-test
51 [ "hi" ] [ "hi" blah-generic ] unit-test
53 ! See how well watch interacts with optimizations.
54 GENERIC: my-generic ( a -- b )
55 M: object my-generic ;
62 [ ] [ some-code ] unit-test