]> gitweb.factorcode.org Git - factor.git/blob - core/sbufs/sbufs-tests.factor
core: Rename iota to <iota> so we can have TUPLE: iota ... ; instead of TUPLE: iota...
[factor.git] / core / sbufs / sbufs-tests.factor
1 USING: classes kernel math namespaces sbufs sequences
2 sequences.private strings tools.test ;
3
4 { 5 } [ "Hello" >sbuf length ] unit-test
5
6 { "Hello" } [
7     100 <sbuf> "buf" set
8     "Hello" "buf" get push-all
9     "buf" get clone "buf-clone" set
10     "World" "buf-clone" get push-all
11     "buf" get >string
12 ] unit-test
13
14 { CHAR: h } [ 0 SBUF" hello world" nth ] unit-test
15 { CHAR: H } [
16     CHAR: H 0 SBUF" hello world" [ set-nth ] keep first
17 ] unit-test
18
19 { SBUF" x" } [ 1 <sbuf> CHAR: x >bignum suffix! ] unit-test
20
21 { fixnum } [ 1 >bignum SBUF" " new-sequence length class-of ] unit-test
22
23 { fixnum } [ 1 >bignum <iota> [ ] SBUF" " map-as length class-of ] unit-test
24
25 [ 1.5 SBUF" " new-sequence ] must-fail
26
27 [ CHAR: A 0.5 0.5 SBUF" a" set-nth-unsafe ] must-fail