Started work on *safe-sparse-operations*

Not fully working yet
This commit is contained in:
Simon Brooke 2019-06-26 09:37:00 +01:00
parent d430937c56
commit 9d2b6da1cc
2 changed files with 63 additions and 18 deletions

View file

@ -4,7 +4,21 @@
(deftest creation-and-testing
(testing "Creation and testing."
(is (sparse-array? (make-sparse-array :x :y :z)))))
(is (sparse-array? (make-sparse-array :x :y :z)))
(is (sparse-array? {:dimensions 2,
:coord :x,
:content '(:y),
3 {:dimensions 1,
:coord :y,
:content :data,
4 "hello"},
4 {:dimensions 1,
:coord :y,
:content :data,
3 "goodbye"}}))
(is-not (sparse-array? []))
(is-not (sparse-array? "hello"))
))
(deftest put-and-get
(testing "get"
@ -84,9 +98,17 @@
[nil nil nil nil nil]
[nil nil nil nil "hello"]
[nil nil nil "goodbye" nil]]
actual (sparse-to-dense (put
(put
(make-sparse-array :x :y)
"hello" 3 4)
"goodbye" 4 3))]
actual (sparse-to-dense {:dimensions 2,
:coord :x,
:content '(:y),
3 {:dimensions 1,
:coord :y,
:content :data,
4 "hello"},
4 {:dimensions 1,
:coord :y,
:content :data,
3 "goodbye"}})]
(is (= actual expected)))))