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:
parent
d0b60f1fe3
commit
c115090f6e
5 changed files with 27 additions and 21 deletions
|
|
@ -1496,6 +1496,7 @@ when isMainModule:
|
||||||
doAssert parsedAgain["abc"].num == 5
|
doAssert parsedAgain["abc"].num == 5
|
||||||
|
|
||||||
# Bounds checking
|
# Bounds checking
|
||||||
|
when compileOption("boundChecks"):
|
||||||
try:
|
try:
|
||||||
let a = testJson["a"][9]
|
let a = testJson["a"][9]
|
||||||
doAssert(false, "IndexError not thrown")
|
doAssert(false, "IndexError not thrown")
|
||||||
|
|
@ -1511,7 +1512,7 @@ when isMainModule:
|
||||||
except:
|
except:
|
||||||
doAssert(false, "IndexError thrown for valid index")
|
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{"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")
|
||||||
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
|
# bug #6438
|
||||||
doAssert($ %*[] == "[]")
|
doAssert($ %*[] == "[]")
|
||||||
doAssert($ %*{} == "{}")
|
doAssert($ %*{} == "{}")
|
||||||
|
|
||||||
echo("Tests succeeded!")
|
|
||||||
|
|
|
||||||
|
|
@ -2389,19 +2389,22 @@ proc removePrefix*(s: var string, prefix: string) {.
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
proc nonStaticTests =
|
proc nonStaticTests =
|
||||||
doAssert formatBiggestFloat(1234.567, ffDecimal, -1) == "1234.567000"
|
doAssert formatBiggestFloat(1234.567, ffDecimal, -1) == "1234.567000"
|
||||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235."
|
when not defined(js):
|
||||||
|
doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235." # <=== bug 8242
|
||||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 1) == "1234.6"
|
doAssert formatBiggestFloat(1234.567, ffDecimal, 1) == "1234.6"
|
||||||
doAssert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001"
|
doAssert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001"
|
||||||
doAssert formatBiggestFloat(0.00000000001, ffScientific, 1, ',') in
|
doAssert formatBiggestFloat(0.00000000001, ffScientific, 1, ',') in
|
||||||
["1,0e-11", "1,0e-011"]
|
["1,0e-11", "1,0e-011"]
|
||||||
# bug #6589
|
# bug #6589
|
||||||
|
when not defined(js):
|
||||||
doAssert formatFloat(123.456, ffScientific, precision = -1) == "1.234560e+02"
|
doAssert formatFloat(123.456, ffScientific, precision = -1) == "1.234560e+02"
|
||||||
|
|
||||||
doAssert "$# $3 $# $#" % ["a", "b", "c"] == "a c b c"
|
doAssert "$# $3 $# $#" % ["a", "b", "c"] == "a c b c"
|
||||||
doAssert "${1}12 ${-1}$2" % ["a", "b"] == "a12 bb"
|
doAssert "${1}12 ${-1}$2" % ["a", "b"] == "a12 bb"
|
||||||
|
|
||||||
block: # formatSize tests
|
block: # formatSize tests
|
||||||
doAssert formatSize((1'i64 shl 31) + (300'i64 shl 20)) == "2.293GiB"
|
when not defined(js):
|
||||||
|
doAssert formatSize((1'i64 shl 31) + (300'i64 shl 20)) == "2.293GiB" # <=== bug #8231
|
||||||
doAssert formatSize((2.234*1024*1024).int) == "2.234MiB"
|
doAssert formatSize((2.234*1024*1024).int) == "2.234MiB"
|
||||||
doAssert formatSize(4096) == "4KiB"
|
doAssert formatSize(4096) == "4KiB"
|
||||||
doAssert formatSize(4096, prefix=bpColloquial, includeSpace=true) == "4 kB"
|
doAssert formatSize(4096, prefix=bpColloquial, includeSpace=true) == "4 kB"
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,5 @@ proc main =
|
||||||
var leaf = "this is the leaf. it allocates"
|
var leaf = "this is the leaf. it allocates"
|
||||||
let x = createCycle(leaf)
|
let x = createCycle(leaf)
|
||||||
let y = createCycle(leaf)
|
let y = createCycle(leaf)
|
||||||
echo "done ", getOccupiedMem()
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
discard """
|
||||||
|
output: "Hello, world"
|
||||||
|
"""
|
||||||
|
|
||||||
# bug #3584
|
# bug #3584
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,8 @@ proc testSpec(r: var TResults, test: TTest, target = targetC) =
|
||||||
var expected: TSpec
|
var expected: TSpec
|
||||||
if test.action != actionRunNoSpec:
|
if test.action != actionRunNoSpec:
|
||||||
expected = parseSpec(tname)
|
expected = parseSpec(tname)
|
||||||
|
if test.action == actionRun and expected.action == actionCompile:
|
||||||
|
expected.action = actionRun
|
||||||
else:
|
else:
|
||||||
specDefaults expected
|
specDefaults expected
|
||||||
expected.action = actionRunNoSpec
|
expected.action = actionRunNoSpec
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue