]> gitweb.factorcode.org Git - factor.git/blob - basis/fry/fry-tests.factor
d4a3b8b734a13e29ba4dbd43aa01c218ac7c8d69
[factor.git] / basis / fry / fry-tests.factor
1 IN: fry.tests
2 USING: fry tools.test math prettyprint kernel io arrays
3 sequences ;
4
5 [ [ 3 + ] ] [ 3 '[ _ + ] ] unit-test
6
7 [ [ 1 3 + ] ] [ 1 3 '[ _ _ + ] ] unit-test
8
9 [ [ 1 + ] ] [ 1 [ + ] '[ _ @ ] ] unit-test
10
11 [ [ 1 + . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test
12
13 [ [ + - ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
14
15 [ [ "a" write "b" print ] ]
16 [ "a" "b" '[ _ write _ print ] ] unit-test
17
18 [ [ 1 2 + 3 4 - ] ]
19 [ [ + ] [ - ] '[ 1 2 @ 3 4 @ ] ] unit-test
20
21 [ 1/2 ] [
22     1 '[ [ _ ] dip / ] 2 swap call
23 ] unit-test
24
25 [ { { 1 "a" "A" } { 1 "b" "B" } { 1 "c" "C" } } ] [
26     1 '[ [ _ ] 2dip 3array ]
27     { "a" "b" "c" } { "A" "B" "C" } rot 2map
28 ] unit-test
29
30 [ { { 1 "a" } { 1 "b" } { 1 "c" } } ] [
31     '[ [ 1 ] dip 2array ]
32     { "a" "b" "c" } swap map
33 ] unit-test
34
35 [ { { 1 "a" 2 } { 1 "b" 2 } { 1 "c" 2 } } ] [
36     1 2 '[ [ _ ] dip _ 3array ]
37     { "a" "b" "c" } swap map
38 ] unit-test
39
40 : funny-dip '[ [ @ ] dip ] call ; inline
41
42 [ "hi" 3 ] [ "h" "i" 3 [ append ] funny-dip ] unit-test
43
44 [ { 1 2 3 } ] [
45     3 1 '[ _ [ _ + ] map ] call
46 ] unit-test
47
48 [ { 1 { 2 { 3 } } } ] [
49     1 2 3 '[ _ [ _ [ _ 1array ] call 2array ] call 2array ] call
50 ] unit-test
51
52 { 1 1 } [ '[ [ [ _ ] ] ] ] must-infer-as
53
54 [ { { { 3 } } } ] [
55     3 '[ [ [ _ 1array ] call 1array ] call 1array ] call
56 ] unit-test
57
58 [ { { { 3 } } } ] [
59     3 '[ [ [ _ 1array ] call 1array ] call 1array ] call
60 ] unit-test