Testament should run tests with no action (#8232)

* Testament should run tests with no action

* Fix strutils tests for JS
This commit is contained in:
genotrance 2018-07-08 19:38:46 -05:00 • committed by Varriount
commit c115090f6e
5 changed files with 27 additions and 21 deletions

View file

@ -1496,22 +1496,23 @@ when isMainModule:
doAssert parsedAgain["abc"].num == 5
# Bounds checking
try:
let a = testJson["a"][9]
doAssert(false, "IndexError not thrown")
except IndexError:
discard
try:
let a = testJson["a"][-1]
doAssert(false, "IndexError not thrown")
except IndexError:
discard
try:
doAssert(testJson["a"][0].num == 1, "Index doesn't correspond to its value")
except:
doAssert(false, "IndexError thrown for valid index")
when compileOption("boundChecks"):
try:
let a = testJson["a"][9]
doAssert(false, "IndexError not thrown")
except IndexError:
discard
try:
let a = testJson["a"][-1]
doAssert(false, "IndexError not thrown")
except IndexError:
discard
try:
doAssert(testJson["a"][0].num == 1, "Index doesn't correspond to its value")
except:
doAssert(false, "IndexError thrown for valid index")
doAssert(testJson{"b"}.str=="asd", "Couldn't fetch a singly nested key with {}")
doAssert(testJson{"b"}.getStr()=="asd", "Couldn't fetch a singly nested key with {}")
doAssert(isNil(testJson{"nonexistent"}), "Non-existent keys should return nil")
doAssert(isNil(testJson{"a", "b"}), "Indexing through a list should return nil")
doAssert(isNil(testJson{"a", "b"}), "Indexing through a list should return nil")
@ -1602,5 +1603,3 @@ when isMainModule:
# bug #6438
doAssert($ %*[] == "[]")
doAssert($ %*{} == "{}")
echo("Tests succeeded!")