mirror of
https://github.com/janet-lang/janet
synced 2026-09-16 06:11:22 +00:00
Add first version of marsh (marshaling).
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user