1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-22 11:17:40 +00:00

Added some tests (suite 5)

This commit is contained in:
J.-F. Cap
2019-02-25 18:49:04 +01:00
parent febfefa4b2
commit fb5119bf43
3 changed files with 69 additions and 20 deletions

View File

@@ -1,3 +1,5 @@
# naive matrix implementation for testing typed array
(defmacro printf [& xs] ['print ['string/format (splice xs)]])
(defn matrix [nrow ncol] {:nrow nrow :ncol ncol :array (tarray/new :float64 (* nrow ncol))})
@@ -66,24 +68,16 @@
(matrix/set** A i j i))
(matrix/print A)
(print "tarray")
(tarray/print (A :array))
(printf "properties:\n%p" (tarray/properties (A :array)))
(printf "row properties:\n%p" (tarray/properties (matrix/row A 1)))
# test marshalling
(def a (tarray/new :float64 20))
(set (a 0) math/pi)
(set (a 1) 1234)
(def b (unmarshal (marshal a)))
(printf "%p" (tarray/properties b))
(print (b 0))
(print (b 1))
(for i 0 nr
(printf "row properties:[%i]\n%p" i (tarray/properties (matrix/row A i))))
(for i 0 nc
(printf "col properties:[%i]\n%p" i (tarray/properties (matrix/column A i))))