1 IN: stack-checker.transforms.tests
2 USING: sequences stack-checker.transforms tools.test math kernel
3 quotations stack-checker accessors combinators words arrays
4 classes classes.tuple ;
6 : compose-n-quot ( word -- quot' ) <repetition> >quotation ;
7 : compose-n ( quot -- ) compose-n-quot call ;
8 \ compose-n [ compose-n-quot ] 2 define-transform
9 : compose-n-test ( a b c -- x ) 2 \ + compose-n ;
11 [ 6 ] [ 1 2 3 compose-n-test ] unit-test
17 : cleave-test ( color -- r g b )
18 { [ r>> ] [ g>> ] [ b>> ] } cleave ;
20 { 1 3 } [ cleave-test ] must-infer-as
22 [ 1 2 3 ] [ 1 2 3 <color> cleave-test ] unit-test
24 [ 1 2 3 ] [ 1 2 3 <color> \ cleave-test def>> call ] unit-test
26 : 2cleave-test ( a b -- c d e ) { [ 2array ] [ + ] [ - ] } 2cleave ;
28 [ { 1 2 } 3 -1 ] [ 1 2 2cleave-test ] unit-test
30 [ { 1 2 } 3 -1 ] [ 1 2 \ 2cleave-test def>> call ] unit-test
32 : spread-test ( a b c -- d e f ) { [ sq ] [ neg ] [ recip ] } spread ;
34 [ 16 -3 1/6 ] [ 4 3 6 spread-test ] unit-test
36 [ 16 -3 1/6 ] [ 4 3 6 \ spread-test def>> call ] unit-test
38 [ fixnum instance? ] must-infer
40 : bad-new-test ( -- obj ) V{ } new ;
42 [ bad-new-test ] must-infer
44 [ bad-new-test ] must-fail