]> gitweb.factorcode.org Git - factor.git/blob - basis/sequences/product/product-tests.factor
Update some copyright headers to follow the current convention
[factor.git] / basis / sequences / product / product-tests.factor
1 ! Copyright (C) 2009 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays kernel make sequences sequences.product tools.test ;
4 IN: sequences.product.tests
5
6
7 { { { 0 "a" } { 1 "a" } { 2 "a" } { 0 "b" } { 1 "b" } { 2 "b" } } }
8 [ { { 0 1 2 } { "a" "b" } } <product-sequence> >array ] unit-test
9
10 : x ( n s -- sss ) <repetition> concat ;
11
12 { { "a" "aa" "aaa" "b" "bb" "bbb" } }
13 [ { { 1 2 3 } { "a" "b" } } [ first2 x ] product-map ] unit-test
14
15 {
16     {
17         { 0 "a" t } { 1 "a" t } { 2 "a" t } { 0 "b" t } { 1 "b" t } { 2 "b" t }
18         { 0 "a" f } { 1 "a" f } { 2 "a" f } { 0 "b" f } { 1 "b" f } { 2 "b" f }
19     }
20 } [ { { 0 1 2 } { "a" "b" } { t f } } [ ] product-map ] unit-test
21
22 { "a1b1c1a2b2c2" } [
23     [
24         { { "a" "b" "c" } { "1" "2" } }
25         [ [ % ] each ] product-each
26     ] "" make
27 ] unit-test
28
29 { { } } [ { { } { 1 } } [ ] product-map ] unit-test
30 { } [ { { } { 1 } } [ drop ] product-each ] unit-test