Add first version of marsh (marshaling).

This commit is contained in:
Calvin Rose
2018-06-12 14:24:45 -04:00
parent f0f5af24c2
commit 0cf10946b0
12 changed files with 613 additions and 14 deletions
+22
View File
@@ -127,4 +127,26 @@
(assert (= (string.find "123" "abc123def") 3) "string.find positive")
(assert (= (string.find "1234" "abc123def") nil) "string.find negative")
# Marshal
(defn testmarsh [x msg]
(def marshx (marsh.marshal x))
(def out (-> marshx marsh.unmarshal marsh.marshal))
(assert (= (string marshx) (string out)) msg))
(testmarsh nil "marshal nil")
(testmarsh false "marshal false")
(testmarsh true "marshal true")
(testmarsh 1 "marshal small integers")
(testmarsh -1 "marshal integers (-1)")
(testmarsh 199 "marshal small integers (199)")
(testmarsh 1.0 "marshal double")
(testmarsh "doctordolittle" "marshal string")
(testmarsh :chickenshwarma "marshal symbol")
(testmarsh @"oldmcdonald" "marshal buffer")
(testmarsh @[1 2 3 4 5] "marshal array")
(testmarsh [tuple 1 2 3 4 5] "marshal tuple")
(testmarsh @{1 2 3 4} "marshal table")
(testmarsh {1 2 3 4} "marshal struct")
(end-suite)