1 ! Copyright (C) 2009 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors pair-methods classes kernel sequences tools.test ;
14 : class-names ( a b prefix -- string )
15 [ [ class-of name>> ] bi@ "-" glue ] dip prepend ;
17 PAIR-GENERIC: blibble ( a b -- c )
19 PAIR-M: thang thang blibble
20 "vanilla " class-names ;
22 PAIR-M: foom thang blibble
23 "chocolate " class-names ;
25 PAIR-M: barm thang blibble
26 "strawberry " class-names ;
28 PAIR-M: barm zim blibble
29 "coconut " class-names ;
31 { "vanilla zang-zim" } [ zim new zang new blibble ] unit-test
33 ! args automatically swap to match most specific method
34 { "chocolate foom-zim" } [ foom new zim new blibble ] unit-test
35 { "chocolate foom-zim" } [ zim new foom new blibble ] unit-test
37 { "strawberry barm-barm" } [ barm new barm new blibble ] unit-test
38 { "strawberry barm-foom" } [ barm new foom new blibble ] unit-test
39 { "strawberry barm-foom" } [ foom new barm new blibble ] unit-test
41 { "coconut barm-zang" } [ zang new barm new blibble ] unit-test
42 { "coconut barm-zim" } [ barm new zim new blibble ] unit-test
44 [ 1 2 blibble ] [ no-pair-method? ] must-fail-with