]> gitweb.factorcode.org Git - factor.git/blob - core/quotations/quotations-tests.factor
functors: inline the parts of interpolate this needs
[factor.git] / core / quotations / quotations-tests.factor
1 USING: kernel math quotations.private sequences tools.test ;
2 IN: quotations
3
4 { [ 3 ] } [ 3 [ ] curry ] unit-test
5 { [ \ + ] } [ \ + [ ] curry ] unit-test
6 { [ \ + = ] } [ \ + [ = ] curry ] unit-test
7
8 { [ 1 + 2 + 3 + ] } [
9     { 1 2 3 } [ [ + ] curry ] map concat
10 ] unit-test
11
12 { [ 1 2 3 4 ] } [ [ 1 2 ] [ 3 4 ] append ] unit-test
13 { [ 1 2 3 ] } [ [ 1 2 ] 3 suffix ] unit-test
14 { [ 3 1 2 ] } [ [ 1 2 ] 3 prefix ] unit-test
15
16 { [ "hi" ] } [ "hi" 1quotation ] unit-test
17
18 [ 1 \ + curry ] must-fail
19
20 : trouble ( -- arr quot ) { 123 } dup array>quotation ;
21
22 { 999 } [
23     ! Call the quotation which compiles it.
24     trouble call drop
25     ! Change the array used for it.
26     999 0 rot set-nth
27     trouble nip call
28 ] unit-test