Merge pull request #2800 from flaviut/fixup-tests
Misc. changes to stdlib tests
This commit is contained in:
commit
4013071f81
2 changed files with 5 additions and 26 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):
|
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()
|
|
||||||
"""
|
|
||||||
|
|
|
||||||
|
|
@ -449,7 +449,7 @@ else:
|
||||||
if handle < 0: raise newEOS("posix.open() call failed")
|
if handle < 0: raise newEOS("posix.open() call failed")
|
||||||
result = newFileHandleStream(handle)
|
result = newFileHandleStream(handle)
|
||||||
|
|
||||||
when defined(testing):
|
when isMainModule and defined(testing):
|
||||||
var ss = newStringStream("The quick brown fox jumped over the lazy dog.\nThe lazy dog ran")
|
var ss = newStringStream("The quick brown fox jumped over the lazy dog.\nThe lazy dog ran")
|
||||||
assert(ss.getPosition == 0)
|
assert(ss.getPosition == 0)
|
||||||
assert(ss.peekStr(5) == "The q")
|
assert(ss.peekStr(5) == "The q")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue