test suite test json printer
import ideal • machine • characters • unicode handler
private json printer make printer()
return json printer • new(unicode handler • instance)
test case test basic printer()
json0 : printer • print("'Hello, world!'\n\\")
assert json0 == "\"'Hello, world!'\\n\\\\\""
json1 : printer • print(68)
assert json1 == "68"
json2 : printer • print([42, 68])
assert json2 == "[42, 68]"
json3 : printer • print(missing • instance)
assert json3 == "null"
the dictionary : list dictionary[string, readonly value] • new()
the dictionary • put("foo", "bar")
the dictionary • put("baz", 68)
json4 : printer • print(the dictionary)
assert json4 == "{\"foo\": \"bar\", \"baz\": 68}"
the dictionary2 : list dictionary[string, readonly value] • new()
the dictionary2 • put("foo", false)
the dictionary2 • put("bar", true)
json5 : printer • print(the dictionary2)
assert json5 == "{\"foo\": false, \"bar\": true}"