]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/annotations/annotations-tests.factor
factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!
[factor.git] / basis / tools / annotations / annotations-tests.factor
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
5
6 : foo ( -- ) ;
7 \ foo watch
8
9 { } [ foo ] unit-test
10
11 ! erg's bug
12 GENERIC: some-generic ( a -- b )
13
14 M: integer some-generic 1 + ;
15
16 { 4 } [ 3 some-generic ] unit-test
17
18 { } [ \ some-generic watch ] unit-test
19
20 { 4 } [ 3 some-generic ] unit-test
21
22 { } [ "IN: tools.annotations.tests USE: math M: integer some-generic 1 - ;" eval( -- ) ] unit-test
23
24 { 2 } [ 3 some-generic ] unit-test
25
26 { } [ \ some-generic reset ] unit-test
27
28 { 2 } [ 3 some-generic ] unit-test
29
30 ! slava's bug
31 GENERIC: another-generic ( a -- b )
32
33 M: object another-generic ;
34
35 \ another-generic watch
36
37 { } [ "IN: tools.annotations.tests GENERIC: another-generic ( a -- b )" eval( -- ) ] unit-test
38
39 { } [ \ another-generic reset ] unit-test
40
41 { "" } [ [ 3 another-generic drop ] with-string-writer ] unit-test
42
43 ! reset should do the right thing for generic words
44 { } [ \ another-generic watch ] unit-test
45
46 GENERIC: blah-generic ( a -- b )
47
48 M: string blah-generic ;
49
50 { } [ M\ string blah-generic watch ] unit-test
51
52 { "hi" } [ "hi" blah-generic ] unit-test
53
54 ! See how well watch interacts with optimizations.
55 GENERIC: my-generic ( a -- b )
56 M: object my-generic ;
57
58 \ my-generic watch
59
60 : some-code ( -- )
61     f my-generic drop ;
62
63 { } [ some-code ] unit-test
64
65 ! Make sure annotations work on primitives
66 \ gc reset
67 \ gc watch
68
69 { f } [ [ [ gc ] with-error>output ] with-string-writer empty? ] unit-test
70
71 \ gc reset