Login
7 branches 0 tags
Ben (X13/Arch) C-D now works as expected d12ef03 3 years ago 802 Commits
nujel / testsuite / arrays.nuj
[test/add "##[2 3 4]" [string/write [-> #[1 2 3 4] [delete 1]]]]
[test/add "##[1 2 3 #nil]" [string/write [array/push #[1 2 3]]]]
[test/add "##[1 2 3 \"4\"]" [string/write [array/push #[1 2 3] "4"]]]
[test/add "##[1 2 3 4]" [string/write [array/push #[1 2 3] 4]]]
[test/add "##[1 2 3 5.2]" [string/write [array/push #[1 2 3] 5.2]]]
[test/add 0 [array/length #[]]]
[test/add 1 [array/length #[1]]]
[test/add 4 [array/length #[1 2 3 4]]]
[test/add 2 [array/ref #[1 2 3 4] 1]]
[test/add 3 [array/length [array/allocate 3]]]
[test/add #t [array/equal? #[1 2 3] #[1 2 3]]]
[test/add #f [array/equal? #[2 2 3] #[1 2 3]]]
[test/add #f [array/equal? #[1 2 3] #[1 2 3 4]]]
[test/add #f [array/equal? #[1 2 3 4] #[1 2 3]]]
[test/add #t [array/equal? #[1.0 2.0 3.0] #[1.0 2.0 3.0]]]
[test/add #t [array/equal? #[:a :b :c] #[:a :b :c]]]
[test/add #f [array/equal? #[:a :b :c] #[:a :b :d]]]
[test/add #f [array/equal? #["a" "b" "c"] #["a" "b" "d"]]]
[test/add #t [array/equal? #["a" "b" "c"] #["a" "b" "c"]]]
[test/add #t [array? #[1 2 3]]]
[test/add #t [array? [array/allocate 3]]]
[test/add #f [array? '[1 2 3]]]
[test/add #f [array? @[:a 1 :b 2 :c 3]]]
[test/add :type-error [try car [def ein-test-arr #[1 2 3]] [array/ref ein-test-arr 2.2]]]
[test/add #[99 2 3 4] [let [[cur-arr #[1 2 3 4]]] [array/set! cur-arr 0 99] cur-arr]]
[test/add #[42 42 42 42 42 42] [array/fill! [array/allocate 6] 42]]
[test/add 3 [def ein-test-arr #[1 2 3]] [array/ref ein-test-arr 2]]
[test/add 3 [def ein-test-arr #[1 2 3]] [array/ref ein-test-arr 2 9] [array/ref ein-test-arr 2]]
[test/add :out-of-bounds [try car [def testerle #[1 2 3]] [array/ref testerle 4]]]
[test/add :out-of-bounds [try car [def testerle #[1 2 3]] [array/ref testerle 40000]]]
[test/add #[1 2 3] [def testerle #[1 2 3]] testerle]
[test/add :type-error [try car [def testerle #[1 2 3]] [array/ref testerle #t]]]
[test/add 1 [array/ref #[1 2 3] 0]]
[test/add 2 [def arr #[1 2 3]] [array/length! arr 2] [length arr]]
[test/add 3 [def arr #[1 2 3]] [array/length! arr 2] [reduce arr + 0]]
[test/add "##[2 4]" [string/write [filter #[1 2 3 4] even?]]]
[test/add "##[0 0 0]" [string/write [-> [array/allocate 3] [array/fill! 0]]]]
[test/add "##[3 9 0]" [string/write [-> [array/allocate 3] [array/fill! 0] [array/set! 1 9] [array/set! 0 3]]]]
[test/add 10 [def arr #[1 2 3]] [array/length! arr 4] [array/set! arr 3 4] [reduce arr + 0]]
[test/add 10 [-> #[1 2 3] [array/length! 4] [array/set! 3 4] [reduce + 0]]]
[test/add 10 [sum #[1 2 3 4]]]
[test/add "##[#nil]" [string/write [array/set! #[1] 0 #nil]]]
[test/add "##[2]" [string/write [array/set! #[1] 0 2]]]
[test/add "##[#t]" [string/write [array/set! #[1] 0 #t]]]
[test/add "##[#f]" [string/write [array/set! #[1] 0 #f]]]
[test/add "##[1 2 3 4]" [string/write [array/append #[1 2] #[3 4]]]]
[test/add "##[1 2 3]" [string/write [array/append #[1 2] #[3]]]]
[test/add "##[1 2]" [string/write [array/append #[1 2] #[]]]]
[test/add :type-error [try car [array/append #[1] '[2]]]]
[test/add :type-error [try car [array/append '[1] #nil]]]
[test/add :type-error [try car [array/append #[1]]]]
[test/add :type-error [try car [array/append '[1]]]]
[test/add :type-error [try car [array/append]]]
[test/add "##[1 2 3]" [string/write [let [[o #[2 2 3]]] [array/set! o 0 1] [array/set! [array/dup o] 0 3] o]]]
[test/add #f [= #[1] #[1]]]
[test/add #f [= #[1] #[2]]]
[test/add #t [let [[a #[1]]] [= a a]]]