]> gitweb.factorcode.org Git - factor.git/blob - basis/circular/circular-tests.factor
b4a9d547f2edc888bde7efce60371f3f53616502
[factor.git] / basis / circular / circular-tests.factor
1 ! Copyright (C) 2005, 2006 Alex Chapman, Daniel Ehrenberg
2 ! See http;//factorcode.org/license.txt for BSD license
3 USING: arrays kernel tools.test sequences sequences.private
4 circular strings ;
5
6 [ 0 ] [ { 0 1 2 3 4 } <circular> 0 swap virtual@ drop ] unit-test
7 [ 2 ] [ { 0 1 2 3 4 } <circular> 2 swap virtual@ drop ] unit-test
8
9 [ CHAR: t ] [ "test" <circular> 0 swap nth ] unit-test
10 [ "test"  ] [ "test" <circular> >string ] unit-test
11
12 [ CHAR: e ] [ "test" <circular> 5 swap nth-unsafe ] unit-test
13  
14 [ [ 1 2 3 ] ] [ { 1 2 3 } <circular> [ ] like ] unit-test
15 [ [ 2 3 1 ] ] [ { 1 2 3 } <circular> [ rotate-circular ] keep [ ] like ] unit-test
16 [ [ 3 1 2 ] ] [ { 1 2 3 } <circular> [ rotate-circular ] keep [ rotate-circular ] keep [ ] like ] unit-test
17 [ [ 2 3 1 ] ] [ { 1 2 3 } <circular> 1 over change-circular-start [ ] like ] unit-test
18 [ [ 3 1 2 ] ] [ { 1 2 3 } <circular> 1 over change-circular-start 1 over change-circular-start [ ] like ] unit-test
19 [ [ 3 1 2 ] ] [ { 1 2 3 } <circular> -100 over change-circular-start [ ] like ] unit-test
20
21 [ "fob" ] [ "foo" <circular> CHAR: b 2 pick set-nth >string ] unit-test
22 [ "boo" ] [ "foo" <circular> CHAR: b 3 pick set-nth-unsafe >string ] unit-test
23 [ "ornact" ] [ "factor" <circular> 4 over change-circular-start CHAR: n 2 pick set-nth >string ] unit-test
24
25 [ "bcd" ] [ 3 <circular-string> "abcd" [ over push-circular ] each >string ] unit-test
26
27 [ { 0 0 } ] [ { 0 0 } <circular> -1 over change-circular-start >array ] unit-test
28
29 ! This no longer fails
30 ! [ "test" <circular> 5 swap nth ] must-fail
31 ! [ "foo" <circular> CHAR: b 3 rot set-nth ] must-fail
32
33 [ { } ] [ 3 <growing-circular> >array ] unit-test
34 [ { 1 2 } ] [
35     3 <growing-circular>
36     [ 1 swap push-growing-circular ] keep
37     [ 2 swap push-growing-circular ] keep >array
38 ] unit-test
39 [ { 3 4 5 } ] [
40     3 <growing-circular> dup { 1 2 3 4 5 } [
41         swap push-growing-circular
42     ] with each >array
43 ] unit-test