factor/basis/fry/fry-tests.factor

65 lines
1.6 KiB
Factor
Raw Normal View History

2008-03-03 17:44:24 -05:00
IN: fry.tests
USING: fry tools.test math prettyprint kernel io arrays
sequences eval accessors ;
2008-03-03 17:44:24 -05:00
2008-09-10 23:11:40 -04:00
[ [ 3 + ] ] [ 3 '[ _ + ] ] unit-test
2008-03-03 17:44:24 -05:00
2008-09-10 23:11:40 -04:00
[ [ 1 3 + ] ] [ 1 3 '[ _ _ + ] ] unit-test
2008-03-03 17:44:24 -05:00
[ [ 1 [ + ] call ] ] [ 1 [ + ] '[ _ @ ] ] unit-test
2008-03-03 17:44:24 -05:00
[ [ 1 [ + ] call . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test
2008-03-03 17:44:24 -05:00
[ [ [ + ] [ - ] [ call ] dip call ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
2008-03-03 17:44:24 -05:00
[ [ "a" "b" [ write ] dip print ] ]
2008-09-10 23:11:40 -04:00
[ "a" "b" '[ _ write _ print ] ] unit-test
2008-03-03 17:44:24 -05:00
[ 1/2 ] [
2008-09-10 23:11:40 -04:00
1 '[ [ _ ] dip / ] 2 swap call
2008-03-03 17:44:24 -05:00
] unit-test
[ { { 1 "a" "A" } { 1 "b" "B" } { 1 "c" "C" } } ] [
2008-09-10 23:11:40 -04:00
1 '[ [ _ ] 2dip 3array ]
2008-03-03 17:44:24 -05:00
{ "a" "b" "c" } { "A" "B" "C" } rot 2map
] unit-test
[ { { 1 "a" } { 1 "b" } { 1 "c" } } ] [
'[ [ 1 ] dip 2array ]
2008-03-03 17:44:24 -05:00
{ "a" "b" "c" } swap map
] unit-test
[ { { 1 "a" 2 } { 1 "b" 2 } { 1 "c" 2 } } ] [
1 2 '[ [ _ ] dip _ 3array ]
2008-03-03 17:44:24 -05:00
{ "a" "b" "c" } swap map
] unit-test
: funny-dip '[ [ @ ] dip ] call ; inline
2008-03-03 17:44:24 -05:00
[ "hi" 3 ] [ "h" "i" 3 [ append ] funny-dip ] unit-test
2008-04-22 17:29:20 -04:00
[ { 1 2 3 } ] [
2008-09-10 23:11:40 -04:00
3 1 '[ _ [ _ + ] map ] call
2008-04-22 17:29:20 -04:00
] unit-test
2008-05-05 01:11:37 -04:00
[ { 1 { 2 { 3 } } } ] [
2008-09-10 23:11:40 -04:00
1 2 3 '[ _ [ _ [ _ 1array ] call 2array ] call 2array ] call
2008-05-05 01:11:37 -04:00
] unit-test
2008-05-26 01:48:18 -04:00
2008-09-10 23:11:40 -04:00
{ 1 1 } [ '[ [ [ _ ] ] ] ] must-infer-as
2008-05-26 01:48:18 -04:00
[ { { { 3 } } } ] [
2008-09-10 23:11:40 -04:00
3 '[ [ [ _ 1array ] call 1array ] call 1array ] call
2008-05-26 01:48:18 -04:00
] unit-test
[ { { { 3 } } } ] [
2008-09-10 23:11:40 -04:00
3 '[ [ [ _ 1array ] call 1array ] call 1array ] call
2008-05-26 01:48:18 -04:00
] unit-test
[ "USING: fry locals.backend ; f '[ load-local _ ]" eval ]
[ error>> >r/r>-in-fry-error? ] must-fail-with
2008-11-21 06:47:47 -05:00
[ { { "a" 1 } { "b" 2 } { "c" 3 } { "d" 4 } } ] [
1 2 3 4 '[ "a" _ 2array "b" _ 2array "c" _ 2array "d" _ 2array 4array ] call
] unit-test