assert() -> doAssert()

and an explicit "test" task for the sake of nimble.sh
This commit is contained in:
Ștefan Talpalaru 2019-03-14 00:39:10 +01:00
parent a9d565f8e0
commit 002c6bbb38
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
4 changed files with 13 additions and 5 deletions

View File

@ -11,3 +11,11 @@ requires "nim >= 0.17.0",
"serialization",
"std_shims"
import ospaths, strutils
task test, "Run tests":
for filename in listFiles("tests"):
if filename.startsWith("tests" / "test_") and filename.endsWith(".nim"):
exec "nim c -r " & filename
rmFile filename[0..^5]

View File

@ -71,7 +71,7 @@ proc requireToken(r: JsonReader, tk: TokKind) =
of tkBracketLe: etBracketLe
of tkCurlyRi: etCurrlyRi
of tkCurlyLe: etCurrlyLe
else: (assert false; etBool)
else: (doAssert false; etBool)
proc skipToken(r: var JsonReader, tk: TokKind) =
r.requireToken tk

View File

@ -41,7 +41,7 @@ template indent =
proc writeFieldName*(w: var JsonWriter, name: string) =
# this is implemented as a separate proc in order to
# keep the code bloat from `writeField` to a minimum
assert w.state != RecordExpected
doAssert w.state != RecordExpected
if w.state == AfterField:
append ','
@ -68,7 +68,7 @@ proc writeField*(w: var JsonWriter, name: string, value: auto) =
w.state = AfterField
proc beginRecord*(w: var JsonWriter) =
assert w.state == RecordExpected
doAssert w.state == RecordExpected
append '{'
if w.hasPrettyOutput:
@ -81,7 +81,7 @@ proc beginRecord*(w: var JsonWriter, T: type) =
if w.hasTypeAnnotations: w.writeField("$type", typetraits.name(T))
proc endRecord*(w: var JsonWriter) =
assert w.state != RecordExpected
doAssert w.state != RecordExpected
if w.hasPrettyOutput:
append '\n'

View File

@ -26,7 +26,7 @@ type
distance: Mile
template reject(code) =
static: assert(not compiles(code))
static: doAssert(not compiles(code))
borrowSerialization(Meter, int)