1 USING: delegate kernel arrays tools.test words math definitions
2 compiler.units parser generic prettyprint io.streams.string
6 TUPLE: hello this that ;
9 TUPLE: goodbye these those ;
12 GENERIC: foo ( x -- y )
13 GENERIC: bar ( a -- b )
14 GENERIC# whoa 1 ( s t -- w )
15 PROTOCOL: baz foo { bar 0 } { whoa 1 } ;
17 : hello-test ( hello/goodbye -- array )
18 [ hello? ] [ this>> ] [ that>> ] tri 3array ;
20 CONSULT: baz goodbye these>> ;
22 M: hello bar hello-test ;
23 M: hello whoa [ this>> ] dip + ;
25 GENERIC: bing ( c -- d )
27 CONSULT: hello goodbye those>> ;
28 M: hello bing hello-test ;
30 [ 1 { t 1 0 } ] [ 1 0 <hello> [ foo ] [ bar ] bi ] unit-test
31 [ { t 1 0 } ] [ 1 0 <hello> bing ] unit-test
32 [ 1 ] [ 1 0 <hello> f <goodbye> foo ] unit-test
33 [ { t 1 0 } ] [ 1 0 <hello> f <goodbye> bar ] unit-test
34 [ 3 ] [ 1 0 <hello> 2 whoa ] unit-test
35 [ 3 ] [ 1 0 <hello> f <goodbye> 2 whoa ] unit-test
37 [ ] [ 3 [ "USING: accessors delegate ; IN: delegate.tests CONSULT: baz goodbye these>> ;" eval ] times ] unit-test
38 [ H{ { goodbye [ these>> ] } } ] [ baz protocol-consult ] unit-test
39 [ H{ } ] [ bee protocol-consult ] unit-test
41 [ "USING: delegate ;\nIN: delegate.tests\nPROTOCOL: baz foo bar { whoa 1 } ;\n" ] [ [ baz see ] with-string-writer ] unit-test
52 PROTOCOL: alpha one two ;
53 PROTOCOL: beta three ;
57 CONSULT: alpha hey value>> 1+ ;
58 CONSULT: beta hey value>> 1- ;
60 [ 2 ] [ 1 <hey> one ] unit-test
61 [ 2 ] [ 1 <hey> two ] unit-test
62 [ 0 ] [ 1 <hey> three ] unit-test
63 [ { hey } ] [ alpha protocol-users ] unit-test
64 [ { hey } ] [ beta protocol-users ] unit-test
65 [ ] [ "USE: delegate IN: delegate.tests PROTOCOL: alpha one ;" eval ] unit-test
66 [ f ] [ hey \ two method ] unit-test
67 [ f ] [ hey \ four method ] unit-test
68 [ ] [ "USE: delegate IN: delegate.tests PROTOCOL: beta two three four ;" eval ] unit-test
69 [ { hey } ] [ alpha protocol-users ] unit-test
70 [ { hey } ] [ beta protocol-users ] unit-test
71 [ 2 ] [ 1 <hey> one ] unit-test
72 [ 0 ] [ 1 <hey> two ] unit-test
73 [ 0 ] [ 1 <hey> three ] unit-test
74 [ 0 ] [ 1 <hey> four ] unit-test
75 [ ] [ "USING: math accessors delegate ; IN: delegate.tests CONSULT: beta hey value>> 2 - ;" eval ] unit-test
76 [ 2 ] [ 1 <hey> one ] unit-test
77 [ -1 ] [ 1 <hey> two ] unit-test
78 [ -1 ] [ 1 <hey> three ] unit-test
79 [ -1 ] [ 1 <hey> four ] unit-test
80 [ ] [ "IN: delegate.tests FORGET: alpha" eval ] unit-test
81 [ f ] [ hey \ one method ] unit-test
83 TUPLE: slot-protocol-test-1 a b ;
84 TUPLE: slot-protocol-test-2 < slot-protocol-test-1 { c integer } ;
86 TUPLE: slot-protocol-test-3 d ;
88 CONSULT: slot-protocol-test-2 slot-protocol-test-3 d>> ;
91 T{ slot-protocol-test-3 f T{ slot-protocol-test-2 f "a" "b" 5 } }
92 [ a>> ] [ b>> ] [ c>> ] tri