]> gitweb.factorcode.org Git - factor.git/blob - basis/lists/lazy/lazy-tests.factor
5d00701a14b84a8b36cbd6cab22f9bdb8042c061
[factor.git] / basis / lists / lazy / lazy-tests.factor
1 ! Copyright (C) 2006 Matthew Willis and Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: destructors io io.encodings.utf8 io.files kernel lists
4 lists.lazy math sequences tools.test ;
5 IN: lists.lazy.tests
6
7 { { 1 2 3 4 } } [
8   { 1 2 3 4 } >list list>array
9 ] unit-test
10
11 { { { 1 4 } { 1 5 } { 2 4 } { 2 5 } { 3 4 } { 3 5 } } } [
12   { 1 2 3 } >list { 4 5 } >list 2list lcartesian-product* list>array
13 ] unit-test
14
15 { { { 1 4 } { 1 5 } { 2 4 } { 2 5 } { 3 4 } { 3 5 } } } [
16   { 1 2 3 } >list { 4 5 } >list lcartesian-product list>array
17 ] unit-test
18
19 { { 5 6 6 7 7 8 } } [
20   { 1 2 3 } >list { 4 5 } >list 2list [ first2 + ] lcomp list>array
21 ] unit-test
22
23 { { 5 6 7 8 } } [
24   { 1 2 3 } >list { 4 5 } >list 2list { [ first odd? ] } [ first2 + ] lcomp* list>array
25 ] unit-test
26
27 { { 4 5 6 } } [
28     3 { 1 2 3 } >list [ + ] with lazy-map list>array
29 ] unit-test
30
31 { { 1 2 4 8 16 } } [
32   5 1 [ 2 * ] lfrom-by ltake list>array
33 ] unit-test
34
35 [ [ ] lmap ] must-infer
36 [ [ ] lmap>array ] must-infer
37 [ [ drop ] foldr ] must-infer
38 [ [ drop ] foldl ] must-infer
39 [ [ drop ] leach ] must-infer
40 [ lnth ] must-infer
41
42 { { 1 2 3 } } [ { 1 2 3 4 5 } >list [ 2 > ] luntil list>array ] unit-test
43
44 { } [
45     "resource:LICENSE.txt" utf8 <file-reader> [
46         llines list>array drop
47     ] with-disposal
48 ] unit-test
49 { } [
50     "resource:LICENSE.txt" utf8 <file-reader> [
51         lcontents list>array drop
52     ] with-disposal
53 ] unit-test