Clean up JSON tests

This commit is contained in:
Flaviu Tamas 2015-05-25 11:48:49 -04:00
commit 55e126c5c8

View file

@ -1187,24 +1187,13 @@ when false:
# To get that we shall use, obj["json"] # To get that we shall use, obj["json"]
when isMainModule: when isMainModule:
#var node = parse("{ \"test\": null }")
#echo(node.existsKey("test56"))
var parsed = parseFile("tests/testdata/jsontest.json") var parsed = parseFile("tests/testdata/jsontest.json")
var parsed2 = parseFile("tests/testdata/jsontest2.json") var parsed2 = parseFile("tests/testdata/jsontest2.json")
when not defined(testing): try:
echo(parsed) discard parsed["key2"][12123]
echo() assert(false)
echo(pretty(parsed, 2)) except IndexError: assert(true)
echo()
echo(parsed["keyÄÖöoßß"])
echo()
echo(pretty(parsed2))
try:
echo(parsed["key2"][12123])
raise newException(ValueError, "That line was expected to fail")
except IndexError: echo()
let testJson = parseJson"""{ "a": [1, 2, 3, 4], "b": "asd" }""" let testJson = parseJson"""{ "a": [1, 2, 3, 4], "b": "asd" }"""
# nil passthrough # nil passthrough
@ -1271,13 +1260,3 @@ when isMainModule:
} }
] ]
assert j3 == %[%{"name": %"John", "age": %30}, %{"name": %"Susan", "age": %31}] assert j3 == %[%{"name": %"John", "age": %30}, %{"name": %"Susan", "age": %31}]
when not defined(testing):
discard """
while true:
var json = stdin.readLine()
var node = parse(json)
echo(node)
echo()
echo()
"""