factor/basis/tools/walker/walker-tests.factor

134 lines
2.7 KiB
Factor
Raw Normal View History

2008-02-21 00:13:22 -05:00
USING: tools.walker io io.streams.string kernel math
math.private namespaces prettyprint sequences tools.test
continuations math.parser threads arrays tools.walker.debug
2009-04-17 00:14:26 -04:00
generic.standard sequences.private kernel.private
tools.continuations accessors words ;
2008-03-01 17:00:45 -05:00
IN: tools.walker.tests
2008-02-21 00:13:22 -05:00
[ { } ] [
[ ] test-walker
] unit-test
[ { 1 } ] [
[ 1 ] test-walker
] unit-test
[ { 1 2 3 } ] [
[ 1 2 3 ] test-walker
] unit-test
[ { "Yo" 2 } ] [
2008-11-23 22:40:54 -05:00
[ 2 [ "Yo" ] dip ] test-walker
] unit-test
[ { "Yo" 2 3 } ] [
[ 2 [ "Yo" ] dip 3 ] test-walker
2008-02-21 00:13:22 -05:00
] unit-test
[ { 2 } ] [
[ t [ 2 ] [ "hi" ] if ] test-walker
] unit-test
[ { "hi" } ] [
[ f [ 2 ] [ "hi" ] if ] test-walker
] unit-test
[ { 4 } ] [
[ 2 2 fixnum+ ] test-walker
] unit-test
2009-03-23 01:34:02 -04:00
: foo ( -- x ) 2 2 fixnum+ ;
2008-02-21 00:13:22 -05:00
[ { 8 } ] [
[ foo 4 fixnum+ ] test-walker
] unit-test
[ { C{ 1 1.5 } { } C{ 1 1.5 } { } } ] [
[ C{ 1 1.5 } { } 2dup ] test-walker
] unit-test
[ { t } ] [
[ 5 5 number= ] test-walker
] unit-test
[ { f } ] [
[ 5 6 number= ] test-walker
] unit-test
2008-07-07 20:26:58 -04:00
[ { 0 } ] [
[ 0 { array-capacity } declare ] test-walker
] unit-test
2008-02-21 00:13:22 -05:00
[ { f } ] [
[ "XYZ" "XYZ" mismatch ] test-walker
] unit-test
[ { t } ] [
[ "XYZ" "XYZ" sequence= ] test-walker
] unit-test
[ { t } ] [
[ "XYZ" "XYZ" = ] test-walker
] unit-test
[ { f } ] [
[ "XYZ" "XuZ" = ] test-walker
] unit-test
[ { 4 } ] [
[ 2 2 + ] test-walker
] unit-test
[ { 3 } ] [
[ [ 3 "x" set "x" get ] with-scope ] test-walker
] unit-test
[ { "hi\n" } ] [
[ [ "hi" print ] with-string-writer ] test-walker
] unit-test
[ { "4\n" } ] [
[ [ 2 2 + number>string print ] with-string-writer ] test-walker
] unit-test
[ { 1 2 3 } ] [
[ { 1 2 3 } set-datastack ] test-walker
] unit-test
[ { 6 } ]
[ [ 3 [ nip continue ] callcc0 2 * ] test-walker ] unit-test
[ { 6 } ]
[ [ [ 3 swap continue-with ] callcc1 2 * ] test-walker ] unit-test
[ { } ]
[ [ [ ] [ ] recover ] test-walker ] unit-test
[ { 6 } ]
[ [ [ 3 throw ] [ 2 * ] recover ] test-walker ] unit-test
[ { T{ no-method f + nth } } ]
[ [ [ 0 \ + nth ] [ ] recover ] test-walker ] unit-test
2008-02-21 00:13:22 -05:00
[ { } ] [
[ "a" "b" set "c" "d" set [ ] test-walker ] with-scope
] unit-test
2009-04-17 00:14:26 -04:00
: breakpoint-test ( -- x ) break 1 2 + ;
\ breakpoint-test don't-step-into
[ f ] [ \ breakpoint-test optimized? ] unit-test
2009-04-17 00:14:26 -04:00
[ { 3 } ] [ [ breakpoint-test ] test-walker ] unit-test
GENERIC: method-breakpoint-test ( x -- y )
TUPLE: method-breakpoint-tuple ;
M: method-breakpoint-tuple method-breakpoint-test break drop 1 2 + ;
\ method-breakpoint-test don't-step-into
[ { 3 } ]
[ [ T{ method-breakpoint-tuple } method-breakpoint-test ] test-walker ] unit-test