1 USING: arrays continuations io.streams.null kernel
2 kernel.private literals make math math.order memory namespaces
3 prettyprint sbufs sequences strings strings.private tools.test
6 { CHAR: b } [ 1 >bignum "abc" nth ] unit-test
8 { } [ 10 [ [ -1000000 <sbuf> ] ignore-errors ] times ] unit-test
10 { "abc" } [ [ "a" "b" "c" ] [ [ % ] each ] "" make ] unit-test
12 { "abc" } [ "ab" "c" append ] unit-test
13 { "abc" } [ "a" "b" "c" 3append ] unit-test
15 { 3 } [ "hola" "a" start ] unit-test
16 { f } [ "hola" "x" start ] unit-test
17 { 0 } [ "a" "" start ] unit-test
18 { 0 } [ "" "" start ] unit-test
19 { 0 } [ "hola" "hola" start ] unit-test
20 { 1 } [ "hola" "ol" start ] unit-test
21 { f } [ "hola" "amigo" start ] unit-test
22 { f } [ "hola" "holaa" start ] unit-test
24 { "Beginning" } [ "Beginning and end" 9 head ] unit-test
26 { f } [ CHAR: I "team" member? ] unit-test
27 { t } [ "team" "ea" subseq? ] unit-test
28 { f } [ "Factor" "actore" subseq? ] unit-test
30 { "end" } [ "Beginning and end" 14 tail ] unit-test
32 { t } [ "abc" "abd" before? ] unit-test
33 { t } [ "z" "abd" after? ] unit-test
34 { "abc" } [ "abc" "abd" min ] unit-test
35 { "z" } [ "z" "abd" max ] unit-test
37 [ 0 10 "hello" subseq ] must-fail
39 { "Replacing+spaces+with+plus" }
41 "Replacing spaces with plus"
42 [ dup CHAR: \s = [ drop CHAR: + ] when ] map
46 { "05" } [ "5" 2 CHAR: 0 pad-head ] unit-test
47 { "666" } [ "666" 2 CHAR: 0 pad-head ] unit-test
49 [ 1 "" nth ] must-fail
50 [ -6 "hello" nth ] must-fail
52 { t } [ "hello world" dup >vector >string = ] unit-test
54 { "ab" } [ 2 "abc" resize-string ] unit-test
55 { "abc\0\0\0" } [ 6 "abc" resize-string ] unit-test
57 { "\u001234b" } [ 2 "\u001234bc" resize-string ] unit-test
58 { "\u001234bc\0\0\0" } [ 6 "\u001234bc" resize-string ] unit-test
60 ! Random tester found this
61 [ 2 -7 resize-string ]
62 [ ${ KERNEL-ERROR ERROR-TYPE 11 -7 } = ] must-fail-with
64 ! Make sure 24-bit strings work
67 { } [ 0x1234 1 "s" get set-nth ] unit-test
68 { 0x1234 } [ 1 "s" get nth ] unit-test
70 { } [ 0x4321 3 "s" get set-nth ] unit-test
71 { 0x4321 } [ 3 "s" get nth ] unit-test
73 { } [ 0x654321 5 "s" get set-nth ] unit-test
74 { 0x654321 } [ 5 "s" get nth ] unit-test
94 ! Make sure string initialization works
95 { 0x123456 } [ 100 0x123456 <string> first ] unit-test
97 ! Make sure we clear aux vector when storing octets
98 { "\u123456hi" } [ "ih\u123456" clone reverse! ] unit-test
100 ! Make sure aux vector is not shared
103 CHAR: \u123456 over clone set-first
110 100 [ "obdurak" clone ] replicate
113 1234 0 rot set-string-nth
126 300 100 CHAR: \u123456
127 [ <string> clone resize-string first ] keep =
132 { } [ 0x100,0000 0 "s" get set-nth ] unit-test
133 { 0 } [ 0 "s" get nth ] unit-test
135 { } [ -1 0 "s" get set-nth ] unit-test
136 { 0x7fffff } [ 0 "s" get nth ] unit-test