arrays.glisp 539 B

123456789101112131415161718192021
  1. (def testarr [1 2 3 4 5 6])
  2. (assert (= 3 (aget testarr 2)))
  3. (assert (= 1 (first testarr)))
  4. (assert (= [2 3 4 5 6] (rest testarr)))
  5. (aset! testarr 1 0)
  6. (assert (= [1 0 3 4 5 6] testarr))
  7. (assert (= [3 4] (slice testarr 2 4)))
  8. (assert (= [1 2 3] (append [1 2] 3)))
  9. (assert (= [0 1 2 3] (concat [0 1] [2 3])))
  10. (assert (= 6 (len testarr)))
  11. (assert (= ['() '() '()] (make-array 3)))
  12. (assert (= [0 0 0] (make-array 3 0)))
  13. (let [a 0]
  14. (assert (= [a 3] (array 0 3))))
  15. (assert (array? [1 2 3]))
  16. (assert (empty? []))
  17. (assert (not (empty? [1])))