factor/basis/compiler/tests/redefine1.factor

77 lines
2.2 KiB
Factor
Raw Normal View History

2008-06-30 04:57:00 -04:00
USING: accessors compiler compiler.units tools.test math parser
kernel sequences sequences.private classes.mixin generic
definitions arrays words assocs eval strings ;
2008-08-22 18:38:23 -04:00
IN: compiler.tests
2008-06-11 03:58:38 -04:00
GENERIC: method-redefine-generic-1 ( a -- b )
2008-06-11 03:58:38 -04:00
M: integer method-redefine-generic-1 3 + ;
2008-06-11 03:58:38 -04:00
: method-redefine-test-1 ( -- b ) 3 method-redefine-generic-1 ;
2008-06-11 03:58:38 -04:00
[ 6 ] [ method-redefine-test-1 ] unit-test
[ ] [ "IN: compiler.tests USE: math M: fixnum method-redefine-generic-1 4 + ;" eval ] unit-test
2008-06-11 03:58:38 -04:00
[ 7 ] [ method-redefine-test-1 ] unit-test
[ ] [ [ fixnum \ method-redefine-generic-1 method forget ] with-compilation-unit ] unit-test
2008-06-11 03:58:38 -04:00
[ 6 ] [ method-redefine-test-1 ] unit-test
GENERIC: method-redefine-generic-2 ( a -- b )
M: integer method-redefine-generic-2 3 + ;
: method-redefine-test-2 ( -- b ) 3 method-redefine-generic-2 ;
[ 6 ] [ method-redefine-test-2 ] unit-test
[ ] [ "IN: compiler.tests USE: kernel USE: math M: fixnum method-redefine-generic-2 4 + ; USE: strings M: string method-redefine-generic-2 drop f ;" eval ] unit-test
[ 7 ] [ method-redefine-test-2 ] unit-test
[ ] [
[
fixnum string [ \ method-redefine-generic-2 method forget ] bi@
] with-compilation-unit
] unit-test
2008-06-11 03:58:38 -04:00
! Test ripple-up behavior
: hey ( -- ) ;
: there ( -- ) hey ;
2009-01-23 19:20:47 -05:00
[ t ] [ \ hey optimized>> ] unit-test
[ t ] [ \ there optimized>> ] unit-test
2008-06-11 03:58:38 -04:00
[ ] [ "IN: compiler.tests : hey ( -- ) 3 ;" eval ] unit-test
2009-01-23 19:20:47 -05:00
[ f ] [ \ hey optimized>> ] unit-test
[ f ] [ \ there optimized>> ] unit-test
2008-06-11 03:58:38 -04:00
[ ] [ "IN: compiler.tests : hey ( -- ) ;" eval ] unit-test
2009-01-23 19:20:47 -05:00
[ t ] [ \ there optimized>> ] unit-test
2008-06-11 03:58:38 -04:00
: good ( -- ) ;
: bad ( -- ) good ;
: ugly ( -- ) bad ;
2009-01-23 19:20:47 -05:00
[ t ] [ \ good optimized>> ] unit-test
[ t ] [ \ bad optimized>> ] unit-test
[ t ] [ \ ugly optimized>> ] unit-test
2008-06-11 03:58:38 -04:00
[ f ] [ \ good compiled-usage assoc-empty? ] unit-test
[ ] [ "IN: compiler.tests : good ( -- ) 3 ;" eval ] unit-test
2009-01-23 19:20:47 -05:00
[ f ] [ \ good optimized>> ] unit-test
[ f ] [ \ bad optimized>> ] unit-test
[ f ] [ \ ugly optimized>> ] unit-test
2008-06-11 03:58:38 -04:00
[ t ] [ \ good compiled-usage assoc-empty? ] unit-test
[ ] [ "IN: compiler.tests : good ( -- ) ;" eval ] unit-test
2009-01-23 19:20:47 -05:00
[ t ] [ \ good optimized>> ] unit-test
[ t ] [ \ bad optimized>> ] unit-test
[ t ] [ \ ugly optimized>> ] unit-test
2008-06-11 03:58:38 -04:00
[ f ] [ \ good compiled-usage assoc-empty? ] unit-test