factor/basis/tools/annotations/annotations-tests.factor

72 lines
1.5 KiB
Factor
Raw Normal View History

2011-10-19 03:57:06 -04:00
USING: destructors eval io io.streams.string kernel math memory
namespaces parser sequences strings tools.annotations
tools.test tools.time ;
2008-03-01 17:00:45 -05:00
IN: tools.annotations.tests
2007-09-20 18:09:08 -04:00
2009-03-23 01:34:02 -04:00
: foo ( -- ) ;
2007-09-20 18:09:08 -04:00
\ foo watch
{ } [ foo ] unit-test
2008-02-16 16:54:53 -05:00
! erg's bug
2008-02-17 19:38:29 -05:00
GENERIC: some-generic ( a -- b )
2008-02-16 16:54:53 -05:00
M: integer some-generic 1 + ;
2008-02-16 16:54:53 -05:00
{ 4 } [ 3 some-generic ] unit-test
2008-02-16 16:54:53 -05:00
{ } [ \ some-generic watch ] unit-test
2008-02-16 16:54:53 -05:00
{ 4 } [ 3 some-generic ] unit-test
2008-02-16 16:54:53 -05:00
{ } [ "IN: tools.annotations.tests USE: math M: integer some-generic 1 - ;" eval( -- ) ] unit-test
2008-02-16 16:54:53 -05:00
{ 2 } [ 3 some-generic ] unit-test
2008-02-16 16:54:53 -05:00
{ } [ \ some-generic reset ] unit-test
2008-02-16 16:54:53 -05:00
{ 2 } [ 3 some-generic ] unit-test
2008-08-23 21:24:54 -04:00
! slava's bug
GENERIC: another-generic ( a -- b )
M: object another-generic ;
\ another-generic watch
{ } [ "IN: tools.annotations.tests GENERIC: another-generic ( a -- b )" eval( -- ) ] unit-test
2008-08-23 21:24:54 -04:00
{ } [ \ another-generic reset ] unit-test
2008-08-23 21:24:54 -04:00
{ "" } [ [ 3 another-generic drop ] with-string-writer ] unit-test
! reset should do the right thing for generic words
{ } [ \ another-generic watch ] unit-test
GENERIC: blah-generic ( a -- b )
M: string blah-generic ;
{ } [ M\ string blah-generic watch ] unit-test
{ "hi" } [ "hi" blah-generic ] unit-test
! See how well watch interacts with optimizations.
GENERIC: my-generic ( a -- b )
M: object my-generic ;
\ my-generic watch
: some-code ( -- )
f my-generic drop ;
{ } [ some-code ] unit-test
! Make sure annotations work on primitives
2011-10-19 03:57:06 -04:00
\ gc reset
\ gc watch
{ f } [ [ [ gc ] with-error>output ] with-string-writer empty? ] unit-test
\ gc reset