Clean up JSON tests
This commit is contained in:
parent
77b010bd36
commit
55e126c5c8
1 changed files with 4 additions and 25 deletions
|
|
@ -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):
|
|
||||||
echo(parsed)
|
|
||||||
echo()
|
|
||||||
echo(pretty(parsed, 2))
|
|
||||||
echo()
|
|
||||||
echo(parsed["keyÄÖöoßß"])
|
|
||||||
echo()
|
|
||||||
echo(pretty(parsed2))
|
|
||||||
try:
|
try:
|
||||||
echo(parsed["key2"][12123])
|
discard parsed["key2"][12123]
|
||||||
raise newException(ValueError, "That line was expected to fail")
|
assert(false)
|
||||||
except IndexError: echo()
|
except IndexError: assert(true)
|
||||||
|
|
||||||
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()
|
|
||||||
"""
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue