megatest checks output and nimout
This commit is contained in:
parent
2a4c09ff88
commit
3859878db8
16 changed files with 218 additions and 202 deletions
|
|
@ -591,9 +591,10 @@ const specialDisabedTests = [
|
||||||
"tests/system/trealloc.nim", # out of memory
|
"tests/system/trealloc.nim", # out of memory
|
||||||
"tests/system/t7894.nim", # causes out of memory in later tests
|
"tests/system/t7894.nim", # causes out of memory in later tests
|
||||||
"tests/types/tissues_types.nim", # causes out of memory with --gc:boehm
|
"tests/types/tissues_types.nim", # causes out of memory with --gc:boehm
|
||||||
|
"tests/pragmas/tused.nim", # paths in nimout differ when imported
|
||||||
]
|
]
|
||||||
|
|
||||||
proc parseAllSpecs(): void =
|
proc runJoinedTest(): void =
|
||||||
var specs: array[TTestAction, seq[TSpec]]
|
var specs: array[TTestAction, seq[TSpec]]
|
||||||
var specialTests = 0
|
var specialTests = 0
|
||||||
var ignoredTests = 0
|
var ignoredTests = 0
|
||||||
|
|
@ -601,6 +602,7 @@ proc parseAllSpecs(): void =
|
||||||
var specsWithCustomCmd: seq[TSpec]
|
var specsWithCustomCmd: seq[TSpec]
|
||||||
var specsEarlyExit: seq[TSpec]
|
var specsEarlyExit: seq[TSpec]
|
||||||
var specsWithInput: seq[TSpec]
|
var specsWithInput: seq[TSpec]
|
||||||
|
var specsNonCtarget: seq[TSpec]
|
||||||
|
|
||||||
for file in os.walkFiles("tests/*/t*.nim"):
|
for file in os.walkFiles("tests/*/t*.nim"):
|
||||||
|
|
||||||
|
|
@ -643,6 +645,10 @@ proc parseAllSpecs(): void =
|
||||||
specsWithInput.add spec
|
specsWithInput.add spec
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if card(spec.targets) > 0 and spec.targets != {targetC}:
|
||||||
|
specsNonCtarget.add spec
|
||||||
|
continue
|
||||||
|
|
||||||
specs[spec.action].add spec
|
specs[spec.action].add spec
|
||||||
|
|
||||||
for action, specs in specs.pairs:
|
for action, specs in specs.pairs:
|
||||||
|
|
@ -653,16 +659,52 @@ proc parseAllSpecs(): void =
|
||||||
echo "special: ", specialTests
|
echo "special: ", specialTests
|
||||||
echo "ignored: ", ignoredTests
|
echo "ignored: ", ignoredTests
|
||||||
echo "withInput: ", specsWithInput.len
|
echo "withInput: ", specsWithInput.len
|
||||||
|
echo "nonCtarget: ", specsNonCtarget.len
|
||||||
|
|
||||||
var megatest: string
|
var megatest: string
|
||||||
|
|
||||||
for runSpec in specs[actionRun]:
|
for runSpec in specs[actionRun]:
|
||||||
if targetC in runSpec.targets or runSpec.targets == {}:
|
megatest.add "import \""
|
||||||
megatest.add "echo \"------------------------------: "
|
megatest.add runSpec.file
|
||||||
megatest.add runSpec.file
|
megatest.add "\"\n"
|
||||||
megatest.add "\"\n"
|
|
||||||
megatest.add "import \""
|
|
||||||
megatest.add runSpec.file
|
|
||||||
megatest.add "\"\n"
|
|
||||||
|
|
||||||
writeFile("megatest.nim", megatest)
|
writeFile("megatest.nim", megatest)
|
||||||
|
|
||||||
|
let args = ["c", "-d:testing", "--gc:boehm", "megatest.nim"]
|
||||||
|
var (buf, exitCode) = execCmdEx2(command = "nim", args = args, options = {poStdErrToStdOut, poUsePath}, input = "")
|
||||||
|
if exitCode != 0:
|
||||||
|
quit("megatest compilation failed")
|
||||||
|
|
||||||
|
echo "compilation ok"
|
||||||
|
|
||||||
|
var nimoutOK = true
|
||||||
|
for runSpec in specs[actionRun]:
|
||||||
|
for line in runSpec.nimout.splitLines:
|
||||||
|
if buf.find(line) < 0:
|
||||||
|
echo "could not find: ", line
|
||||||
|
echo runSpec.file
|
||||||
|
nimoutOK = false
|
||||||
|
|
||||||
|
if nimoutOK:
|
||||||
|
echo "nimout OK"
|
||||||
|
else:
|
||||||
|
echo "nimout FAIL"
|
||||||
|
|
||||||
|
(buf, exitCode) = execCmdEx2("./megatest", [], {}, "")
|
||||||
|
if exitCode != 0:
|
||||||
|
quit("megatest execution failed")
|
||||||
|
|
||||||
|
echo "run ok"
|
||||||
|
|
||||||
|
var outputOK = true
|
||||||
|
for runSpec in specs[actionRun]:
|
||||||
|
for line in runSpec.output.splitLines:
|
||||||
|
if buf.find(line) < 0:
|
||||||
|
echo "could not find: ", line
|
||||||
|
echo runSpec.file
|
||||||
|
outputOK = false
|
||||||
|
if outputOK:
|
||||||
|
echo "output OK"
|
||||||
|
else:
|
||||||
|
echo "output FAIL"
|
||||||
|
|
||||||
|
removeFile("megatest.nim")
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ type
|
||||||
input*: string
|
input*: string
|
||||||
outputCheck*: TOutputCheck
|
outputCheck*: TOutputCheck
|
||||||
sortoutput*: bool
|
sortoutput*: bool
|
||||||
outp*: string
|
output*: string
|
||||||
line*, column*: int
|
line*, column*: int
|
||||||
tfile*: string
|
tfile*: string
|
||||||
tline*, tcolumn*: int
|
tline*, tcolumn*: int
|
||||||
|
|
@ -161,12 +161,12 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
discard parseInt(e.value, result.tcolumn)
|
discard parseInt(e.value, result.tcolumn)
|
||||||
of "output":
|
of "output":
|
||||||
result.outputCheck = ocEqual
|
result.outputCheck = ocEqual
|
||||||
result.outp = strip(e.value)
|
result.output = strip(e.value)
|
||||||
of "input":
|
of "input":
|
||||||
result.input = e.value
|
result.input = e.value
|
||||||
of "outputsub":
|
of "outputsub":
|
||||||
result.outputCheck = ocSubstr
|
result.outputCheck = ocSubstr
|
||||||
result.outp = strip(e.value)
|
result.output = strip(e.value)
|
||||||
of "sortoutput":
|
of "sortoutput":
|
||||||
try:
|
try:
|
||||||
result.sortoutput = parseCfgBool(e.value)
|
result.sortoutput = parseCfgBool(e.value)
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ proc callCompiler(cmdTemplate, filename, options: string,
|
||||||
close(p)
|
close(p)
|
||||||
result.msg = ""
|
result.msg = ""
|
||||||
result.file = ""
|
result.file = ""
|
||||||
result.outp = ""
|
result.output = ""
|
||||||
result.line = 0
|
result.line = 0
|
||||||
result.column = 0
|
result.column = 0
|
||||||
result.tfile = ""
|
result.tfile = ""
|
||||||
|
|
@ -173,7 +173,7 @@ proc callCCompiler(cmdTemplate, filename, options: string,
|
||||||
result.nimout = ""
|
result.nimout = ""
|
||||||
result.msg = ""
|
result.msg = ""
|
||||||
result.file = ""
|
result.file = ""
|
||||||
result.outp = ""
|
result.output = ""
|
||||||
result.line = -1
|
result.line = -1
|
||||||
while outp.readLine(x.TaintedString) or running(p):
|
while outp.readLine(x.TaintedString) or running(p):
|
||||||
result.nimout.add(x & "\n")
|
result.nimout.add(x & "\n")
|
||||||
|
|
@ -400,12 +400,12 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
exeFile = changeFileExt(test.name, ExeExt)
|
exeFile = changeFileExt(test.name, ExeExt)
|
||||||
|
|
||||||
if not existsFile(exeFile):
|
if not existsFile(exeFile):
|
||||||
r.addResult(test, target, expected.outp, "executable not found", reExeNotFound)
|
r.addResult(test, target, expected.output, "executable not found", reExeNotFound)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let nodejs = if isJsTarget: findNodeJs() else: ""
|
let nodejs = if isJsTarget: findNodeJs() else: ""
|
||||||
if isJsTarget and nodejs == "":
|
if isJsTarget and nodejs == "":
|
||||||
r.addResult(test, target, expected.outp, "nodejs binary not in PATH",
|
r.addResult(test, target, expected.output, "nodejs binary not in PATH",
|
||||||
reExeNotFound)
|
reExeNotFound)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -438,10 +438,10 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
bufB, reExitCodesDiffer)
|
bufB, reExitCodesDiffer)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (expected.outputCheck == ocEqual and expected.outp != bufB) or
|
if (expected.outputCheck == ocEqual and expected.output != bufB) or
|
||||||
(expected.outputCheck == ocSubstr and expected.outp notin bufB):
|
(expected.outputCheck == ocSubstr and expected.output notin bufB):
|
||||||
given.err = reOutputsDiffer
|
given.err = reOutputsDiffer
|
||||||
r.addResult(test, target, expected.outp, bufB, reOutputsDiffer)
|
r.addResult(test, target, expected.output, bufB, reOutputsDiffer)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
compilerOutputTests(test, target, given, expected, r)
|
compilerOutputTests(test, target, given, expected, r)
|
||||||
|
|
@ -582,7 +582,7 @@ proc main() =
|
||||||
of "html":
|
of "html":
|
||||||
generateHtml(resultsFile, optFailing)
|
generateHtml(resultsFile, optFailing)
|
||||||
of "stats":
|
of "stats":
|
||||||
parseAllSpecs()
|
runJoinedTest()
|
||||||
else:
|
else:
|
||||||
quit Usage
|
quit Usage
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,4 @@ echo bug()[0]
|
||||||
echo bug()[0]
|
echo bug()[0]
|
||||||
echo bug()[0]
|
echo bug()[0]
|
||||||
|
|
||||||
when isMainModule: test()
|
test()
|
||||||
|
|
|
||||||
|
|
@ -22,5 +22,4 @@ proc dosomething(): seq[TThing] =
|
||||||
|
|
||||||
result = @[TThing(data: 10, children: result)]
|
result = @[TThing(data: 10, children: result)]
|
||||||
|
|
||||||
when isMainModule:
|
echo($dosomething()[0])
|
||||||
echo($dosomething()[0])
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ proc lift1[A, B](f: proc(a: A): B, r: RandomVar[A]): ClosureVar[B] =
|
||||||
|
|
||||||
return inner
|
return inner
|
||||||
|
|
||||||
when isMainModule:
|
|
||||||
|
proc main() =
|
||||||
proc sq(x: float): float = x * x
|
proc sq(x: float): float = x * x
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
@ -59,3 +60,4 @@ when isMainModule:
|
||||||
echo rng.sample(u)
|
echo rng.sample(u)
|
||||||
echo rng.sample(t)
|
echo rng.sample(t)
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ treportunused.nim(27, 5) Hint: 's9' is declared but not used [XDeclaredButNotUse
|
||||||
treportunused.nim(21, 10) Hint: 's3' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(21, 10) Hint: 's3' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(28, 6) Hint: 's10' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(28, 6) Hint: 's10' is declared but not used [XDeclaredButNotUsed]
|
||||||
'''
|
'''
|
||||||
|
action: compile
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# bug #9764
|
# bug #9764
|
||||||
|
|
|
||||||
|
|
@ -430,55 +430,50 @@ iterator keys* [T,D] (n: PNode[T,D]): T =
|
||||||
i = Path[level].Xi
|
i = Path[level].Xi
|
||||||
inc(i)
|
inc(i)
|
||||||
|
|
||||||
|
proc test() =
|
||||||
|
var oldvalue: int
|
||||||
|
var root = internalPut[int, int](nil, 312, 312, oldvalue)
|
||||||
|
var someOtherRoot = internalPut[string, int](nil, "312", 312, oldvalue)
|
||||||
|
var it1 = internalFind(root, 312)
|
||||||
|
echo it1.value
|
||||||
|
|
||||||
when isMainModule:
|
for i in 1..1_000_000:
|
||||||
|
root = internalPut(root, i, i, oldvalue)
|
||||||
|
|
||||||
proc test() =
|
var cnt = 0
|
||||||
var oldvalue: int
|
oldvalue = -1
|
||||||
var root = internalPut[int, int](nil, 312, 312, oldvalue)
|
when true : # code compiles, when this or the other when is switched to false
|
||||||
var someOtherRoot = internalPut[string, int](nil, "312", 312, oldvalue)
|
for k in root.keys :
|
||||||
var it1 = internalFind(root, 312)
|
if k <= oldvalue :
|
||||||
echo it1.value
|
echo k
|
||||||
|
oldvalue = k
|
||||||
for i in 1..1_000_000:
|
inc(cnt)
|
||||||
root = internalPut(root, i, i, oldvalue)
|
echo cnt
|
||||||
|
when true :
|
||||||
var cnt = 0
|
cnt = 0
|
||||||
oldvalue = -1
|
VisitAll(root, proc(key, val: int) = inc(cnt))
|
||||||
when true : # code compiles, when this or the other when is switched to false
|
echo cnt
|
||||||
for k in root.keys :
|
|
||||||
if k <= oldvalue :
|
|
||||||
echo k
|
|
||||||
oldvalue = k
|
|
||||||
inc(cnt)
|
|
||||||
echo cnt
|
|
||||||
when true :
|
when true :
|
||||||
cnt = 0
|
|
||||||
VisitAll(root, proc(key, val: int) = inc(cnt))
|
|
||||||
echo cnt
|
|
||||||
when true :
|
|
||||||
root = VisitAll(root, proc(key: int, value: var int): bool =
|
|
||||||
return key mod 2 == 0 )
|
|
||||||
cnt = 0
|
|
||||||
oldvalue = -1
|
|
||||||
VisitAll(root, proc(key: int, value: int) {.closure.} =
|
|
||||||
if key <= oldvalue :
|
|
||||||
echo key
|
|
||||||
oldvalue = key
|
|
||||||
inc(cnt) )
|
|
||||||
echo cnt
|
|
||||||
root = VisitAll(root, proc(key: int, value: var int): bool =
|
root = VisitAll(root, proc(key: int, value: var int): bool =
|
||||||
return key mod 2 != 0 )
|
return key mod 2 == 0 )
|
||||||
cnt = 0
|
cnt = 0
|
||||||
oldvalue = -1
|
oldvalue = -1
|
||||||
VisitAll(root, proc(key: int, value: int) {.closure.} =
|
VisitAll(root, proc(key: int, value: int) {.closure.} =
|
||||||
if key <= oldvalue :
|
if key <= oldvalue :
|
||||||
echo "error ", key
|
echo key
|
||||||
oldvalue = key
|
oldvalue = key
|
||||||
inc(cnt) )
|
inc(cnt) )
|
||||||
echo cnt
|
echo cnt
|
||||||
#traceTree(root)
|
root = VisitAll(root, proc(key: int, value: var int): bool =
|
||||||
|
return key mod 2 != 0 )
|
||||||
|
cnt = 0
|
||||||
|
oldvalue = -1
|
||||||
|
VisitAll(root, proc(key: int, value: int) {.closure.} =
|
||||||
|
if key <= oldvalue :
|
||||||
|
echo "error ", key
|
||||||
|
oldvalue = key
|
||||||
|
inc(cnt) )
|
||||||
|
echo cnt
|
||||||
|
#traceTree(root)
|
||||||
|
|
||||||
|
test()
|
||||||
|
|
||||||
test()
|
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,11 @@ proc safeReadLine(): TMaybe[string] =
|
||||||
if r == "": return Nothing[string]()
|
if r == "": return Nothing[string]()
|
||||||
else: return Just(r)
|
else: return Just(r)
|
||||||
|
|
||||||
when isMainModule:
|
proc main() =
|
||||||
var Test = Just("Test")
|
var Test = Just("Test")
|
||||||
echo(Test.value)
|
echo(Test.value)
|
||||||
var mSomething = safeReadLine()
|
var mSomething = safeReadLine()
|
||||||
echo(mSomething.value)
|
echo(mSomething.value)
|
||||||
mSomething = safeReadLine()
|
mSomething = safeReadLine()
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
|
||||||
|
|
@ -397,19 +397,18 @@ template grammar*[K](Kind, Text, Symbol: typedesc; default: K, code: untyped): t
|
||||||
template grammar*[K](Kind: typedesc; default: K, code: untyped): typed {.hint[XDeclaredButNotUsed]: off.} =
|
template grammar*[K](Kind: typedesc; default: K, code: untyped): typed {.hint[XDeclaredButNotUsed]: off.} =
|
||||||
grammar(Kind, string, char, default, code)
|
grammar(Kind, string, char, default, code)
|
||||||
|
|
||||||
when isMainModule:
|
block:
|
||||||
block:
|
type DummyKind = enum dkDefault
|
||||||
type DummyKind = enum dkDefault
|
grammar(DummyKind, string, char, dkDefault):
|
||||||
grammar(DummyKind, string, char, dkDefault):
|
let rule = token("h[a]+m") + ignore(token(r"\s+")) + (literal("eggs") / literal("beans"))
|
||||||
let rule = token("h[a]+m") + ignore(token(r"\s+")) + (literal("eggs") / literal("beans"))
|
var text = "ham beans"
|
||||||
var text = "ham beans"
|
discard rule.parse(text)
|
||||||
discard rule.parse(text)
|
|
||||||
|
|
||||||
var recursive = newRule()
|
var recursive = newRule()
|
||||||
recursive -> (literal("(") + recursive + literal(")")) / token(r"\d+")
|
recursive -> (literal("(") + recursive + literal(")")) / token(r"\d+")
|
||||||
for test in ["spam", "57", "(25)", "((25))"]:
|
for test in ["spam", "57", "(25)", "((25))"]:
|
||||||
discard recursive.parse(test)
|
discard recursive.parse(test)
|
||||||
|
|
||||||
let repeated = +literal("spam") + ?literal("ham") + *literal("salami")
|
let repeated = +literal("spam") + ?literal("ham") + *literal("salami")
|
||||||
for test in ["ham", "spam", "spamspamspam" , "spamham", "spamsalami", "spamsalamisalami"]:
|
for test in ["ham", "spam", "spamspamspam" , "spamham", "spamsalami", "spamsalamisalami"]:
|
||||||
discard repeated.parse(test)
|
discard repeated.parse(test)
|
||||||
|
|
|
||||||
|
|
@ -589,70 +589,68 @@ proc delete*[M, D: Dim; RT, LT](t: RTree[M, D, RT, LT]; leaf: L[D, RT, LT]): boo
|
||||||
t.root.parent = nil
|
t.root.parent = nil
|
||||||
return true
|
return true
|
||||||
|
|
||||||
when isMainModule:
|
|
||||||
|
|
||||||
var t = [4, 1, 3, 2]
|
var t = [4, 1, 3, 2]
|
||||||
var xt = 7
|
var xt = 7
|
||||||
sortPlus(t, xt, system.cmp, SortOrder.Ascending)
|
sortPlus(t, xt, system.cmp, SortOrder.Ascending)
|
||||||
echo xt, " ", t
|
echo xt, " ", t
|
||||||
|
|
||||||
type
|
type
|
||||||
RSE = L[2, int, int]
|
RSE = L[2, int, int]
|
||||||
RSeq = seq[RSE]
|
RSeq = seq[RSE]
|
||||||
|
|
||||||
proc rseq_search(rs: RSeq; rse: RSE): seq[int] =
|
proc rseq_search(rs: RSeq; rse: RSE): seq[int] =
|
||||||
result = newSeq[int]()
|
result = newSeq[int]()
|
||||||
for i in rs:
|
for i in rs:
|
||||||
if intersect(i.b, rse.b):
|
if intersect(i.b, rse.b):
|
||||||
result.add(i.l)
|
result.add(i.l)
|
||||||
|
|
||||||
proc rseq_delete(rs: var RSeq; rse: RSE): bool =
|
proc rseq_delete(rs: var RSeq; rse: RSE): bool =
|
||||||
for i in 0 .. rs.high:
|
for i in 0 .. rs.high:
|
||||||
if rs[i] == rse:
|
if rs[i] == rse:
|
||||||
#rs.delete(i)
|
#rs.delete(i)
|
||||||
rs[i] = rs[rs.high]
|
rs[i] = rs[rs.high]
|
||||||
rs.setLen(rs.len - 1)
|
rs.setLen(rs.len - 1)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
import random, algorithm
|
import random, algorithm
|
||||||
|
|
||||||
proc test(n: int) =
|
proc test(n: int) =
|
||||||
var b: Box[2, int]
|
var b: Box[2, int]
|
||||||
echo center(b)
|
echo center(b)
|
||||||
var x1, x2, y1, y2: int
|
var x1, x2, y1, y2: int
|
||||||
var t = newRStarTree[8, 2, int, int]()
|
var t = newRStarTree[8, 2, int, int]()
|
||||||
#var t = newRTree[8, 2, int, int]()
|
#var t = newRTree[8, 2, int, int]()
|
||||||
var rs = newSeq[RSE]()
|
var rs = newSeq[RSE]()
|
||||||
for i in 0 .. 5:
|
for i in 0 .. 5:
|
||||||
for i in 0 .. n - 1:
|
for i in 0 .. n - 1:
|
||||||
x1 = rand(1000)
|
x1 = rand(1000)
|
||||||
y1 = rand(1000)
|
y1 = rand(1000)
|
||||||
x2 = x1 + rand(25)
|
x2 = x1 + rand(25)
|
||||||
y2 = y1 + rand(25)
|
y2 = y1 + rand(25)
|
||||||
b = [(x1, x2), (y1, y2)]
|
b = [(x1, x2), (y1, y2)]
|
||||||
let el: L[2, int, int] = (b, i + 7)
|
let el: L[2, int, int] = (b, i + 7)
|
||||||
t.insert(el)
|
t.insert(el)
|
||||||
rs.add(el)
|
rs.add(el)
|
||||||
|
|
||||||
for i in 0 .. (n div 4):
|
for i in 0 .. (n div 4):
|
||||||
let j = rand(rs.high)
|
let j = rand(rs.high)
|
||||||
var el = rs[j]
|
var el = rs[j]
|
||||||
assert t.delete(el)
|
assert t.delete(el)
|
||||||
assert rs.rseq_delete(el)
|
assert rs.rseq_delete(el)
|
||||||
|
|
||||||
for i in 0 .. n - 1:
|
for i in 0 .. n - 1:
|
||||||
x1 = rand(1000)
|
x1 = rand(1000)
|
||||||
y1 = rand(1000)
|
y1 = rand(1000)
|
||||||
x2 = x1 + rand(100)
|
x2 = x1 + rand(100)
|
||||||
y2 = y1 + rand(100)
|
y2 = y1 + rand(100)
|
||||||
b = [(x1, x2), (y1, y2)]
|
b = [(x1, x2), (y1, y2)]
|
||||||
let el: L[2, int, int] = (b, i)
|
let el: L[2, int, int] = (b, i)
|
||||||
let r = search(t, b)
|
let r = search(t, b)
|
||||||
let r2 = rseq_search(rs, el)
|
let r2 = rseq_search(rs, el)
|
||||||
assert r.len == r2.len
|
assert r.len == r2.len
|
||||||
assert r.sorted(system.cmp) == r2.sorted(system.cmp)
|
assert r.sorted(system.cmp) == r2.sorted(system.cmp)
|
||||||
|
|
||||||
test(1500)
|
test(1500)
|
||||||
|
|
||||||
# 651 lines
|
|
||||||
|
|
||||||
|
# 651 lines
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ proc lrange*(key: string): TRedisList =
|
||||||
foo.str = key
|
foo.str = key
|
||||||
result = @[foo]
|
result = @[foo]
|
||||||
|
|
||||||
when isMainModule:
|
var p = lrange("mylist")
|
||||||
var p = lrange("mylist")
|
for i in items(p):
|
||||||
for i in items(p):
|
echo(i.str)
|
||||||
echo(i.str)
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''(k: kindA, a: (x: "abc", z: [1, 1, 3]), method: ())
|
output: '''
|
||||||
(k: kindA, a: (x: "abc", z: [1, 2, 3]), method: ())
|
(k: kindA, a: (x: "abc", z: @[1, 1, 3]), method: ())
|
||||||
(k: kindA, a: (x: "abc", z: [1, 3, 3]), method: ())
|
(k: kindA, a: (x: "abc", z: @[1, 2, 3]), method: ())
|
||||||
(k: kindA, a: (x: "abc", z: [1, 4, 3]), method: ())
|
(k: kindA, a: (x: "abc", z: @[1, 3, 3]), method: ())
|
||||||
(k: kindA, a: (x: "abc", z: [1, 5, 3]), method: ())
|
(k: kindA, a: (x: "abc", z: @[1, 4, 3]), method: ())
|
||||||
(k: kindA, a: (x: "abc", z: [1, 6, 3]), method: ())
|
(k: kindA, a: (x: "abc", z: @[1, 5, 3]), method: ())
|
||||||
(k: kindA, a: (x: "abc", z: [1, 7, 3]), method: ())
|
(k: kindA, a: (x: "abc", z: @[1, 6, 3]), method: ())
|
||||||
(k: kindA, a: (x: "abc", z: [1, 8, 3]), method: ())
|
(k: kindA, a: (x: "abc", z: @[1, 7, 3]), method: ())
|
||||||
(k: kindA, a: (x: "abc", z: [1, 9, 3]), method: ())
|
(k: kindA, a: (x: "abc", z: @[1, 8, 3]), method: ())
|
||||||
(k: kindA, a: (x: "abc", z: [1, 10, 3]), method: ())
|
(k: kindA, a: (x: "abc", z: @[1, 9, 3]), method: ())
|
||||||
|
(k: kindA, a: (x: "abc", z: @[1, 10, 3]), method: ())
|
||||||
(y: 0, x: 123)
|
(y: 0, x: 123)
|
||||||
(y: 678, x: 123)
|
(y: 678, x: 123)
|
||||||
(z: 89, y: 0, x: 128)
|
(z: 89, y: 0, x: 128)
|
||||||
|
|
@ -16,7 +17,8 @@ discard """
|
||||||
(y: 678, x: 123)
|
(y: 678, x: 123)
|
||||||
(y: 0, x: 123)
|
(y: 0, x: 123)
|
||||||
(y: 678, x: 123)
|
(y: 678, x: 123)
|
||||||
(y: 123, x: 678)'''
|
(y: 123, x: 678)
|
||||||
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -32,13 +34,6 @@ type
|
||||||
a: TArg
|
a: TArg
|
||||||
`method`: TEmpty # bug #1791
|
`method`: TEmpty # bug #1791
|
||||||
|
|
||||||
proc `$`[T](s: seq[T]): string =
|
|
||||||
result = "["
|
|
||||||
for i, x in s:
|
|
||||||
if i > 0: result.add(", ")
|
|
||||||
result.add($x)
|
|
||||||
result.add("]")
|
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
for i in 1..10:
|
for i in 1..10:
|
||||||
let d = TDummy(k: kindA, a: TArg(x: "abc", z: @[1,i,3]), `method`: TEmpty())
|
let d = TDummy(k: kindA, a: TArg(x: "abc", z: @[1,i,3]), `method`: TEmpty())
|
||||||
|
|
|
||||||
|
|
@ -119,28 +119,24 @@ template test(loopCount: int, testBody: untyped): typed =
|
||||||
test(loopCount, 0, testBody)
|
test(loopCount, 0, testBody)
|
||||||
echo "done extraI passed 0"
|
echo "done extraI passed 0"
|
||||||
|
|
||||||
when isMainModule:
|
var
|
||||||
var
|
loops = 0
|
||||||
loops = 0
|
|
||||||
|
|
||||||
test 0, 0:
|
test 0, 0:
|
||||||
|
loops += 1
|
||||||
|
echo "test 0 complete, loops=", loops
|
||||||
|
|
||||||
|
test 1, 1.0:
|
||||||
|
loops += 1
|
||||||
|
echo "test 1.0 complete, loops=", loops
|
||||||
|
|
||||||
|
when true:
|
||||||
|
# when true we get the following compile time error:
|
||||||
|
# b.nim(35, 6) Error: expression 'loops += 1' has no type (or is ambiguous)
|
||||||
|
loops = 0
|
||||||
|
test 2:
|
||||||
loops += 1
|
loops += 1
|
||||||
echo "test 0 complete, loops=", loops
|
echo "test no extra complete, loops=", loops
|
||||||
|
|
||||||
test 1, 1.0:
|
|
||||||
loops += 1
|
|
||||||
echo "test 1.0 complete, loops=", loops
|
|
||||||
|
|
||||||
when true:
|
|
||||||
# when true we get the following compile time error:
|
|
||||||
# b.nim(35, 6) Error: expression 'loops += 1' has no type (or is ambiguous)
|
|
||||||
loops = 0
|
|
||||||
test 2:
|
|
||||||
loops += 1
|
|
||||||
echo "test no extra complete, loops=", loops
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# bug #2229
|
# bug #2229
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
discard """
|
|
||||||
outputsub: ""
|
|
||||||
"""
|
|
||||||
|
|
||||||
import nativesockets, unittest
|
|
||||||
|
|
||||||
suite "nativesockets":
|
|
||||||
test "getHostname":
|
|
||||||
let hostname = getHostname()
|
|
||||||
check hostname.len > 0
|
|
||||||
check hostname.len < 64
|
|
||||||
|
|
@ -24,9 +24,8 @@ proc weird(json_params: Table) =
|
||||||
sort(f, system.cmp[int])
|
sort(f, system.cmp[int])
|
||||||
outp(f)
|
outp(f)
|
||||||
|
|
||||||
when isMainModule:
|
var t = @[3, 2, 1]
|
||||||
var t = @[3, 2, 1]
|
sort(t, system.cmp[int])
|
||||||
sort(t, system.cmp[int])
|
outp(t)
|
||||||
outp(t)
|
works()
|
||||||
works()
|
weird(initTable[string, JsonNode]())
|
||||||
weird(initTable[string, JsonNode]())
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue