factor/core/definitions/definitions-tests.factor

54 lines
925 B
Factor
Raw Normal View History

2008-03-01 17:00:45 -05:00
IN: definitions.tests
2008-01-09 19:13:26 -05:00
USING: tools.test generic kernel definitions sequences
compiler.units ;
2007-10-09 17:35:09 -04:00
TUPLE: combination-1 ;
M: combination-1 perform-combination 2drop { } [ ] each [ ] ;
2008-02-05 00:30:59 -05:00
M: combination-1 make-default-method 2drop [ "No method" throw ] ;
2007-10-09 17:35:09 -04:00
SYMBOL: generic-1
2007-12-24 19:40:09 -05:00
[
generic-1 T{ combination-1 } define-generic
2007-10-09 17:35:09 -04:00
2008-02-03 15:19:07 -05:00
[ ] object \ generic-1 define-method
2007-12-24 19:40:09 -05:00
] with-compilation-unit
2007-10-09 17:35:09 -04:00
[ ] [
[
{ combination-1 { object generic-1 } } forget-all
] with-compilation-unit
] unit-test
2007-10-09 17:35:09 -04:00
2008-02-05 00:30:59 -05:00
GENERIC: some-generic ( a -- b )
2007-10-09 17:35:09 -04:00
USE: arrays
M: array some-generic ;
USE: bit-arrays
M: bit-array some-generic ;
USE: byte-arrays
M: byte-array some-generic ;
TUPLE: some-class ;
M: some-class some-generic ;
TUPLE: another-class some-generic ;
[ ] [
[
{
some-generic
some-class
{ another-class some-generic }
} forget-all
] with-compilation-unit
2007-10-09 17:35:09 -04:00
] unit-test