1 ! (c)2009 Joe Groff bsd license
2 USING: accessors pair-methods classes kernel sequences tools.test ;
13 : class-names ( a b prefix -- string )
14 [ [ class-of name>> ] bi@ "-" glue ] dip prepend ;
16 PAIR-GENERIC: blibble ( a b -- c )
18 PAIR-M: thang thang blibble
19 "vanilla " class-names ;
21 PAIR-M: foom thang blibble
22 "chocolate " class-names ;
24 PAIR-M: barm thang blibble
25 "strawberry " class-names ;
27 PAIR-M: barm zim blibble
28 "coconut " class-names ;
30 { "vanilla zang-zim" } [ zim new zang new blibble ] unit-test
32 ! args automatically swap to match most specific method
33 { "chocolate foom-zim" } [ foom new zim new blibble ] unit-test
34 { "chocolate foom-zim" } [ zim new foom new blibble ] unit-test
36 { "strawberry barm-barm" } [ barm new barm new blibble ] unit-test
37 { "strawberry barm-foom" } [ barm new foom new blibble ] unit-test
38 { "strawberry barm-foom" } [ foom new barm new blibble ] unit-test
40 { "coconut barm-zang" } [ zang new barm new blibble ] unit-test
41 { "coconut barm-zim" } [ barm new zim new blibble ] unit-test
43 [ 1 2 blibble ] [ no-pair-method? ] must-fail-with