fixes #2517
This commit is contained in:
parent
2c91e999e2
commit
6725aa3634
8 changed files with 76 additions and 1834 deletions
|
|
@ -593,7 +593,7 @@ proc register*(d: Dispatcher, ftp: AsyncFTPClient): Delegate {.discardable.} =
|
||||||
ftp.disp = d
|
ftp.disp = d
|
||||||
return ftp.disp.register(ftp.csock)
|
return ftp.disp.register(ftp.csock)
|
||||||
|
|
||||||
when isMainModule:
|
when not defined(testing) and isMainModule:
|
||||||
proc main =
|
proc main =
|
||||||
var d = newDispatcher()
|
var d = newDispatcher()
|
||||||
let hev =
|
let hev =
|
||||||
|
|
|
||||||
|
|
@ -186,19 +186,21 @@ when isMainModule:
|
||||||
assert( z["first"]["one"] == 1) # retrieve from first inner table
|
assert( z["first"]["one"] == 1) # retrieve from first inner table
|
||||||
assert( z["second"]["red"] == 10) # retrieve from second inner table
|
assert( z["second"]["red"] == 10) # retrieve from second inner table
|
||||||
|
|
||||||
var output = ""
|
when false:
|
||||||
for k, v in pairs(z):
|
# disabled: depends on hash order:
|
||||||
output.add( "$# ($#) ->\n" % [k,$len(v)] )
|
var output = ""
|
||||||
for k2,v2 in pairs(v):
|
for k, v in pairs(z):
|
||||||
output.add( " $# <-> $#\n" % [k2,$v2] )
|
output.add( "$# ($#) ->\L" % [k,$len(v)] )
|
||||||
|
for k2,v2 in pairs(v):
|
||||||
|
output.add( " $# <-> $#\L" % [k2,$v2] )
|
||||||
|
|
||||||
let expected = unindent """
|
let expected = unindent """
|
||||||
first (3) ->
|
first (3) ->
|
||||||
two <-> 2
|
two <-> 2
|
||||||
three <-> 3
|
three <-> 3
|
||||||
one <-> 1
|
one <-> 1
|
||||||
second (2) ->
|
second (2) ->
|
||||||
red <-> 10
|
red <-> 10
|
||||||
blue <-> 20
|
blue <-> 20
|
||||||
"""
|
"""
|
||||||
assert output == expected
|
assert output == expected
|
||||||
|
|
|
||||||
1770
lib/pure/pegs.nimfix
1770
lib/pure/pegs.nimfix
File diff suppressed because it is too large
Load diff
|
|
@ -1410,7 +1410,8 @@ when isMainModule:
|
||||||
doAssert wordWrap(inp, 10, false) == outp
|
doAssert wordWrap(inp, 10, false) == outp
|
||||||
|
|
||||||
doAssert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001"
|
doAssert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001"
|
||||||
doAssert formatBiggestFloat(0.00000000001, ffScientific, 1) == "1.0e-11"
|
doAssert formatBiggestFloat(0.00000000001, ffScientific, 1) in
|
||||||
|
["1.0e-11", "1.0e-011"]
|
||||||
|
|
||||||
doAssert "$# $3 $# $#" % ["a", "b", "c"] == "a c b c"
|
doAssert "$# $3 $# $#" % ["a", "b", "c"] == "a c b c"
|
||||||
when not defined(testing):
|
when not defined(testing):
|
||||||
|
|
|
||||||
|
|
@ -764,7 +764,7 @@ proc parseToken(info: var TimeInfo; token, value: string; j: var int) =
|
||||||
info.monthday = value[j..j+1].parseInt()
|
info.monthday = value[j..j+1].parseInt()
|
||||||
j += 2
|
j += 2
|
||||||
of "ddd":
|
of "ddd":
|
||||||
case value[j..j+2].toLower():
|
case value[j..j+2].toLower()
|
||||||
of "sun":
|
of "sun":
|
||||||
info.weekday = dSun
|
info.weekday = dSun
|
||||||
of "mon":
|
of "mon":
|
||||||
|
|
@ -1068,45 +1068,45 @@ when isMainModule:
|
||||||
var f = "dddd at hh:mmtt on MMM d, yyyy"
|
var f = "dddd at hh:mmtt on MMM d, yyyy"
|
||||||
assert($s.parse(f) == "Tue Dec 15 09:04:00 2015")
|
assert($s.parse(f) == "Tue Dec 15 09:04:00 2015")
|
||||||
# ANSIC = "Mon Jan _2 15:04:05 2006"
|
# ANSIC = "Mon Jan _2 15:04:05 2006"
|
||||||
s = "Mon Jan 2 15:04:05 2006"
|
s = "Thu Jan 12 15:04:05 2006"
|
||||||
f = "ddd MMM d HH:mm:ss yyyy"
|
f = "ddd MMM dd HH:mm:ss yyyy"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:05 2006")
|
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
|
||||||
# UnixDate = "Mon Jan _2 15:04:05 MST 2006"
|
# UnixDate = "Mon Jan _2 15:04:05 MST 2006"
|
||||||
s = "Mon Jan 2 15:04:05 MST 2006"
|
s = "Thu Jan 12 15:04:05 MST 2006"
|
||||||
f = "ddd MMM d HH:mm:ss ZZZ yyyy"
|
f = "ddd MMM dd HH:mm:ss ZZZ yyyy"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:05 2006")
|
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
|
||||||
# RubyDate = "Mon Jan 02 15:04:05 -0700 2006"
|
# RubyDate = "Mon Jan 02 15:04:05 -0700 2006"
|
||||||
s = "Mon Jan 02 15:04:05 -07:00 2006"
|
s = "Thu Jan 12 15:04:05 -07:00 2006"
|
||||||
f = "ddd MMM dd HH:mm:ss zzz yyyy"
|
f = "ddd MMM dd HH:mm:ss zzz yyyy"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:05 2006")
|
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
|
||||||
# RFC822 = "02 Jan 06 15:04 MST"
|
# RFC822 = "02 Jan 06 15:04 MST"
|
||||||
s = "02 Jan 06 15:04 MST"
|
s = "12 Jan 16 15:04 MST"
|
||||||
f = "dd MMM yy HH:mm ZZZ"
|
f = "dd MMM yy HH:mm ZZZ"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:00 2006")
|
assert($s.parse(f) == "Tue Jan 12 15:04:00 2016")
|
||||||
# RFC822Z = "02 Jan 06 15:04 -0700" # RFC822 with numeric zone
|
# RFC822Z = "02 Jan 06 15:04 -0700" # RFC822 with numeric zone
|
||||||
s = "02 Jan 06 15:04 -07:00"
|
s = "12 Jan 16 15:04 -07:00"
|
||||||
f = "dd MMM yy HH:mm zzz"
|
f = "dd MMM yy HH:mm zzz"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:00 2006")
|
assert($s.parse(f) == "Tue Jan 12 15:04:00 2016")
|
||||||
# RFC850 = "Monday, 02-Jan-06 15:04:05 MST"
|
# RFC850 = "Monday, 02-Jan-06 15:04:05 MST"
|
||||||
s = "Monday, 02-Jan-06 15:04:05 MST"
|
s = "Monday, 12-Jan-06 15:04:05 MST"
|
||||||
f = "dddd, dd-MMM-yy HH:mm:ss ZZZ"
|
f = "dddd, dd-MMM-yy HH:mm:ss ZZZ"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:05 2006")
|
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
|
||||||
# RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"
|
# RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"
|
||||||
s = "Mon, 02 Jan 2006 15:04:05 MST"
|
s = "Thu, 12 Jan 2006 15:04:05 MST"
|
||||||
f = "ddd, dd MMM yyyy HH:mm:ss ZZZ"
|
f = "ddd, dd MMM yyyy HH:mm:ss ZZZ"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:05 2006")
|
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
|
||||||
# RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" # RFC1123 with numeric zone
|
# RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" # RFC1123 with numeric zone
|
||||||
s = "Mon, 02 Jan 2006 15:04:05 -07:00"
|
s = "Thu, 12 Jan 2006 15:04:05 -07:00"
|
||||||
f = "ddd, dd MMM yyyy HH:mm:ss zzz"
|
f = "ddd, dd MMM yyyy HH:mm:ss zzz"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:05 2006")
|
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
|
||||||
# RFC3339 = "2006-01-02T15:04:05Z07:00"
|
# RFC3339 = "2006-01-02T15:04:05Z07:00"
|
||||||
s = "2006-01-02T15:04:05Z-07:00"
|
s = "2006-01-12T15:04:05Z-07:00"
|
||||||
f = "yyyy-MM-ddTHH:mm:ssZzzz"
|
f = "yyyy-MM-ddTHH:mm:ssZzzz"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:05 2006")
|
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
|
||||||
# RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
|
# RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
|
||||||
s = "2006-01-02T15:04:05.999999999Z-07:00"
|
s = "2006-01-12T15:04:05.999999999Z-07:00"
|
||||||
f = "yyyy-MM-ddTHH:mm:ss.999999999Zzzz"
|
f = "yyyy-MM-ddTHH:mm:ss.999999999Zzzz"
|
||||||
assert($s.parse(f) == "Mon Jan 2 15:04:05 2006")
|
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
|
||||||
# Kitchen = "3:04PM"
|
# Kitchen = "3:04PM"
|
||||||
s = "3:04PM"
|
s = "3:04PM"
|
||||||
f = "h:mmtt"
|
f = "h:mmtt"
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
|
||||||
for test in os.walkFiles(pattern):
|
for test in os.walkFiles(pattern):
|
||||||
let contents = readFile(test).string
|
let contents = readFile(test).string
|
||||||
if contents.contains("when isMainModule"):
|
if contents.contains("when isMainModule"):
|
||||||
testSpec r, makeTest(test, options, cat, actionRun)
|
testSpec r, makeTest(test, options, cat, actionRunNoSpec)
|
||||||
else:
|
else:
|
||||||
testNoSpec r, makeTest(test, options, cat, actionCompile)
|
testNoSpec r, makeTest(test, options, cat, actionCompile)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,14 @@
|
||||||
import parseutils, strutils, os, osproc, streams, parsecfg
|
import parseutils, strutils, os, osproc, streams, parsecfg
|
||||||
|
|
||||||
const
|
const
|
||||||
cmdTemplate* = r"nim $target --hints:on $options $file"
|
cmdTemplate* = r"nim $target --hints:on -d:testing $options $file"
|
||||||
|
|
||||||
type
|
type
|
||||||
TTestAction* = enum
|
TTestAction* = enum
|
||||||
actionCompile = "compile"
|
actionCompile = "compile"
|
||||||
actionRun = "run"
|
actionRun = "run"
|
||||||
actionReject = "reject"
|
actionReject = "reject"
|
||||||
|
actionRunNoSpec = "runNoSpec"
|
||||||
TResultEnum* = enum
|
TResultEnum* = enum
|
||||||
reNimcCrash, # nim compiler seems to have crashed
|
reNimcCrash, # nim compiler seems to have crashed
|
||||||
reMsgsDiffer, # error messages differ
|
reMsgsDiffer, # error messages differ
|
||||||
|
|
@ -78,7 +79,7 @@ proc extractSpec(filename: string): string =
|
||||||
when not defined(nimhygiene):
|
when not defined(nimhygiene):
|
||||||
{.pragma: inject.}
|
{.pragma: inject.}
|
||||||
|
|
||||||
template parseSpecAux(fillResult: stmt) {.immediate.} =
|
template parseSpecAux(fillResult: untyped) =
|
||||||
var ss = newStringStream(extractSpec(filename))
|
var ss = newStringStream(extractSpec(filename))
|
||||||
var p {.inject.}: CfgParser
|
var p {.inject.}: CfgParser
|
||||||
open(p, ss, filename, 1)
|
open(p, ss, filename, 1)
|
||||||
|
|
@ -92,8 +93,7 @@ template parseSpecAux(fillResult: stmt) {.immediate.} =
|
||||||
fillResult
|
fillResult
|
||||||
close(p)
|
close(p)
|
||||||
|
|
||||||
proc parseSpec*(filename: string): TSpec =
|
proc specDefaults*(result: var TSpec) =
|
||||||
result.file = filename
|
|
||||||
result.msg = ""
|
result.msg = ""
|
||||||
result.outp = ""
|
result.outp = ""
|
||||||
result.nimout = ""
|
result.nimout = ""
|
||||||
|
|
@ -101,6 +101,10 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
result.cmd = cmdTemplate
|
result.cmd = cmdTemplate
|
||||||
result.line = 0
|
result.line = 0
|
||||||
result.column = 0
|
result.column = 0
|
||||||
|
|
||||||
|
proc parseSpec*(filename: string): TSpec =
|
||||||
|
specDefaults(result)
|
||||||
|
result.file = filename
|
||||||
parseSpecAux:
|
parseSpecAux:
|
||||||
case normalize(e.key)
|
case normalize(e.key)
|
||||||
of "action":
|
of "action":
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,12 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||||
let tname = test.name.addFileExt(".nim")
|
let tname = test.name.addFileExt(".nim")
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
styledEcho "Processing ", fgCyan, extractFilename(tname)
|
styledEcho "Processing ", fgCyan, extractFilename(tname)
|
||||||
var expected = parseSpec(tname)
|
var expected: TSpec
|
||||||
|
if test.action != actionRunNoSpec:
|
||||||
|
expected = parseSpec(tname)
|
||||||
|
else:
|
||||||
|
specDefaults expected
|
||||||
|
expected.action = actionRunNoSpec
|
||||||
if expected.err == reIgnored:
|
if expected.err == reIgnored:
|
||||||
r.addResult(test, "", "", reIgnored)
|
r.addResult(test, "", "", reIgnored)
|
||||||
inc(r.skipped)
|
inc(r.skipped)
|
||||||
|
|
@ -206,7 +211,7 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||||
var given = callCompiler(expected.cmd, test.name,
|
var given = callCompiler(expected.cmd, test.name,
|
||||||
test.options & " --hint[Path]:off --hint[Processing]:off", test.target)
|
test.options & " --hint[Path]:off --hint[Processing]:off", test.target)
|
||||||
compilerOutputTests(test, given, expected, r)
|
compilerOutputTests(test, given, expected, r)
|
||||||
of actionRun:
|
of actionRun, actionRunNoSpec:
|
||||||
var given = callCompiler(expected.cmd, test.name, test.options,
|
var given = callCompiler(expected.cmd, test.name, test.options,
|
||||||
test.target)
|
test.target)
|
||||||
if given.err != reSuccess:
|
if given.err != reSuccess:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue