]> gitweb.factorcode.org Git - factor.git/blob - core/arrays/arrays-tests.factor
factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!
[factor.git] / core / arrays / arrays-tests.factor
1 USING: accessors arrays kernel kernel.private literals sequences
2 sequences.private growable tools.test vectors layouts system math
3 vectors.private ;
4 IN: arrays.tests
5
6 [ -2 { "a" "b" "c" } nth ] must-fail
7 [ 10 { "a" "b" "c" } nth ] must-fail
8 [ "hi" -2 { "a" "b" "c" } set-nth ] must-fail
9 [ "hi" 10 { "a" "b" "c" } set-nth ] must-fail
10 { f } [ { "a" "b" "c" } dup clone eq? ] unit-test
11 { "hi" } [ "hi" 1 { "a" "b" "c" } clone [ set-nth ] keep second ] unit-test
12 { V{ "a" "b" "c" } } [ { "a" "b" "c" } >vector ] unit-test
13 { f } [ { "a" "b" "c" } dup >array eq? ] unit-test
14 { t } [ { "a" "b" "c" } dup { } like eq? ] unit-test
15 { t } [ { "a" "b" "c" } dup dup length vector boa underlying>> eq? ] unit-test
16 { V{ "a" "b" "c" } } [ { "a" "b" "c" } V{ } like ] unit-test
17 { { "a" "b" "c" } } [ { "a" } { "b" "c" } append ] unit-test
18 { { "a" "b" "c" "d" "e" } }
19 [ { "a" } { "b" "c" } { "d" "e" } 3append ] unit-test
20
21 [ -1 f <array> ] must-fail
22 [ cell-bits cell log2 - 2^ f <array> ] must-fail
23 ! To big for a fixnum #1045
24 [ 67 2^ 3 <array> ] [
25     ${ "kernel-error" ERROR-OUT-OF-FIXNUM-RANGE 147573952589676412928 f }
26     =
27 ] must-fail-with