2 USING: tools.test math prettyprint kernel io arrays vectors sequences
3 generalizations bake bake.fry ;
7 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9 : unit-test* ( input output -- ) swap unit-test ;
11 : must-be-t ( in -- ) [ t ] swap unit-test ;
12 : must-be-f ( in -- ) [ f ] swap unit-test ;
14 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 [ [ 3 + ] ] [ 3 '[ , + ] ] unit-test
18 [ [ 1 3 + ] ] [ 1 3 '[ , , + ] ] unit-test
20 [ [ 1 + ] ] [ 1 [ + ] '[ , @ ] ] unit-test
22 [ [ 1 + . ] ] [ 1 [ + ] '[ , @ . ] ] unit-test
24 [ [ + - ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
26 [ [ "a" write "b" print ] ]
27 [ "a" "b" '[ , write , print ] ] unit-test
30 [ [ + ] [ - ] '[ 1 2 @ 3 4 @ ] ] unit-test
33 1 '[ , _ / ] 2 swap call
36 [ { { 1 "a" "A" } { 1 "b" "B" } { 1 "c" "C" } } ] [
38 { "a" "b" "c" } { "A" "B" "C" } rot 2map
41 [ { { 1 "a" } { 1 "b" } { 1 "c" } } ] [
43 { "a" "b" "c" } swap map
50 [ { { 1 "a" 2 } { 1 "b" 2 } { 1 "c" 2 } } ] [
52 { "a" "b" "c" } swap map
55 : funny-dip '[ @ _ ] call ; inline
57 [ "hi" 3 ] [ "h" "i" 3 [ append ] funny-dip ] unit-test
60 3 1 '[ , [ , + ] map ] call
63 [ { 1 { 2 { 3 } } } ] [
64 1 2 3 '[ , [ , [ , 1array ] call 2array ] call 2array ] call
67 { 1 1 } [ '[ [ [ , ] ] ] ] must-infer-as
70 3 '[ [ [ , 1array ] call 1array ] call 1array ] call
74 3 '[ [ [ , 1array ] call 1array ] call 1array ] call
77 ! [ 10 20 30 40 '[ , V{ , { , } } , ] ] [ [ 10 V{ 20 { 30 } } 40 ] ] unit-test*
79 [ 10 20 30 40 '[ , V{ , { , } } , ] ]
80 [ [ 10 20 30 >r r> 1 narray >r >r r> r> 2 narray >vector 40 ] ]
83 [ { 1 2 3 } { 4 5 6 } { 7 8 9 } '[ , { V{ @ } { , } } ] call ]
86 { V{ 4 5 6 } { { 7 8 9 } } }