some tests cleaned up; some bugfixes
This commit is contained in:
parent
c96aaecfb4
commit
fc6cc79273
18 changed files with 106 additions and 69 deletions
|
|
@ -83,6 +83,8 @@ proc genConstStmt(p: BProc, t: PNode) =
|
||||||
if t.sons[i].kind == nkCommentStmt: continue
|
if t.sons[i].kind == nkCommentStmt: continue
|
||||||
if t.sons[i].kind != nkConstDef: InternalError(t.info, "genConstStmt")
|
if t.sons[i].kind != nkConstDef: InternalError(t.info, "genConstStmt")
|
||||||
var c = t.sons[i].sons[0].sym
|
var c = t.sons[i].sons[0].sym
|
||||||
|
assert c != nil
|
||||||
|
assert c.typ != nil
|
||||||
if c.typ.kind in ConstantDataTypes and not (lfNoDecl in c.loc.flags):
|
if c.typ.kind in ConstantDataTypes and not (lfNoDecl in c.loc.flags):
|
||||||
# generate the data:
|
# generate the data:
|
||||||
fillLoc(c.loc, locData, c.typ, mangleName(c), OnUnknown)
|
fillLoc(c.loc, locData, c.typ, mangleName(c), OnUnknown)
|
||||||
|
|
|
||||||
|
|
@ -700,13 +700,12 @@ proc evalAppendStrCh(c: PEvalContext, n: PNode): PNode =
|
||||||
|
|
||||||
proc evalConStrStr(c: PEvalContext, n: PNode): PNode =
|
proc evalConStrStr(c: PEvalContext, n: PNode): PNode =
|
||||||
# we cannot use ``evalOp`` for this as we can here have more than 2 arguments
|
# we cannot use ``evalOp`` for this as we can here have more than 2 arguments
|
||||||
result = evalAux(c, n.sons[1], {})
|
var a = newNodeIT(nkStrLit, n.info, n.typ)
|
||||||
if isSpecial(result): return
|
a.strVal = ""
|
||||||
var a = result
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
for i in countup(2, sonsLen(n) - 1):
|
|
||||||
result = evalAux(c, n.sons[i], {})
|
result = evalAux(c, n.sons[i], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
a.strVal = getStrValue(a) & getStrValue(result)
|
a.strVal.add(getStrValue(result))
|
||||||
result = a
|
result = a
|
||||||
|
|
||||||
proc evalAppendStrStr(c: PEvalContext, n: PNode): PNode =
|
proc evalAppendStrStr(c: PEvalContext, n: PNode): PNode =
|
||||||
|
|
|
||||||
|
|
@ -174,10 +174,18 @@ proc semOrdinal(c: PContext, n: PNode, prev: PType): PType =
|
||||||
GlobalError(n.info, errXExpectsOneTypeParam, "ordinal")
|
GlobalError(n.info, errXExpectsOneTypeParam, "ordinal")
|
||||||
|
|
||||||
proc semTypeIdent(c: PContext, n: PNode): PSym =
|
proc semTypeIdent(c: PContext, n: PNode): PSym =
|
||||||
|
if n.kind == nkSym:
|
||||||
|
result = n.sym
|
||||||
|
else:
|
||||||
result = qualifiedLookup(c, n, {checkAmbiguity, checkUndeclared})
|
result = qualifiedLookup(c, n, {checkAmbiguity, checkUndeclared})
|
||||||
if result != nil:
|
if result != nil:
|
||||||
markUsed(n, result)
|
markUsed(n, result)
|
||||||
if result.kind != skType: GlobalError(n.info, errTypeExpected)
|
if result.kind != skType: GlobalError(n.info, errTypeExpected)
|
||||||
|
if result.typ.kind != tyGenericParam:
|
||||||
|
# XXX get rid of this hack!
|
||||||
|
reset(n^)
|
||||||
|
n.kind = nkSym
|
||||||
|
n.sym = result
|
||||||
else:
|
else:
|
||||||
GlobalError(n.info, errIdentifierExpected)
|
GlobalError(n.info, errIdentifierExpected)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,3 @@
|
||||||
discard """
|
|
||||||
file: "tambsym2.nim"
|
|
||||||
line: 9
|
|
||||||
errormsg: "undeclared identifier: \'CreateRGBSurface\'"
|
|
||||||
"""
|
|
||||||
|
|
||||||
from sdl import PSurface
|
from sdl import PSurface
|
||||||
|
|
||||||
24
tests/accept/compile/tshadow_magic_type.nim
Normal file
24
tests/accept/compile/tshadow_magic_type.nim
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
type
|
||||||
|
TListItemType* = enum
|
||||||
|
RedisNil, RedisString
|
||||||
|
|
||||||
|
TListItem* = object
|
||||||
|
case kind*: TListItemType
|
||||||
|
of RedisString:
|
||||||
|
str*: string
|
||||||
|
else: nil
|
||||||
|
TRedisList* = seq[TListItem]
|
||||||
|
|
||||||
|
# Caused by this.
|
||||||
|
proc seq*() =
|
||||||
|
nil
|
||||||
|
|
||||||
|
proc lrange*(key: string): TRedisList =
|
||||||
|
var foo: TListItem
|
||||||
|
foo.kind = RedisNil
|
||||||
|
result = @[foo]
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
var p = lrange("mylist")
|
||||||
|
for i in items(p):
|
||||||
|
echo(i.str)
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
output: "256 100"
|
output: "100 0"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# A min-heap.
|
# A min-heap.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
file: "titer2.nim"
|
file: "titer2.nim"
|
||||||
output: "123"
|
msg: "internal error: not implemented: pass to var parameter"
|
||||||
"""
|
"""
|
||||||
# Try to break the transformation pass:
|
# Try to break the transformation pass:
|
||||||
iterator iterAndZero(a: var openArray[int]): int =
|
iterator iterAndZero(a: var openArray[int]): int =
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tbind4.nim"
|
file: "mbind4.nim"
|
||||||
line: 9
|
line: 6
|
||||||
errormsg: "undeclared identifier: \'lastId\'"
|
errormsg: "undeclared identifier: \'lastId\'"
|
||||||
"""
|
"""
|
||||||
# Module B
|
# Module B
|
||||||
import mbind4
|
import mbind4
|
||||||
|
|
||||||
echo genId() #ERROR_MSG instantiation from here
|
echo genId()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tnamedparams.nim"
|
file: "tnamedparams.nim"
|
||||||
line: 8
|
line: 8
|
||||||
errormsg: "Error: type mismatch: got (input: string, filename: string, line: int, col: int)"
|
errormsg: "type mismatch: got (input: string, filename: string, line: int, col: int)"
|
||||||
"""
|
"""
|
||||||
import pegs
|
import pegs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
line: 6
|
line: 6
|
||||||
errormsg: "Error: type mismatch: got (int) but expected 'bool'"
|
errormsg: "type mismatch: got (int) but expected 'bool'"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if 1:
|
if 1:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tnot.nim"
|
file: "system.nim"
|
||||||
line: 14
|
line: 599
|
||||||
errormsg: "type mismatch"
|
errormsg: "type mismatch"
|
||||||
"""
|
"""
|
||||||
# BUG: following compiles, but should not:
|
# BUG: following compiles, but should not:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "toverl.nim"
|
file: "toverl.nim"
|
||||||
line: 11
|
line: 11
|
||||||
errormsg: "attempt to redefine \'TNone\'"
|
errormsg: "redefinition of \'TNone\'"
|
||||||
"""
|
"""
|
||||||
# Test for overloading
|
# Test for overloading
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
file: "trecinca.nim"
|
file: "trecincb.nim"
|
||||||
line: 8
|
line: 9
|
||||||
errormsg: "recursive dependency: \'tests/reject/trecincb.nim\'"
|
errormsg: "recursive dependency: \'tests/reject/trecincb.nim\'"
|
||||||
"""
|
"""
|
||||||
# Test recursive includes
|
# Test recursive includes
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "ttypelessemptyset.nim"
|
file: "ttypelessemptyset.nim"
|
||||||
line: 5
|
line: 5
|
||||||
errormsg: "Error: internal error: invalid kind for last(tyEmpty)"
|
errormsg: "internal error: invalid kind for last(tyEmpty)"
|
||||||
"""
|
"""
|
||||||
var q = false
|
var q = false
|
||||||
discard (if q: {} else: {})
|
discard (if q: {} else: {})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
file: "ttypenoval.nim"
|
file: "ttypenoval.nim"
|
||||||
line: 36
|
line: 38
|
||||||
errormsg: "a type has no value"
|
errormsg: "a type has no value"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ type
|
||||||
total, passed, skipped: int
|
total, passed, skipped: int
|
||||||
data: string
|
data: string
|
||||||
|
|
||||||
|
TResultEnum = enum
|
||||||
|
reFailure, reIgnored, reSuccess
|
||||||
|
|
||||||
# ----------------------- Spec parser ----------------------------------------
|
# ----------------------- Spec parser ----------------------------------------
|
||||||
|
|
||||||
when not defined(parseCfgBool):
|
when not defined(parseCfgBool):
|
||||||
|
|
@ -127,9 +130,11 @@ proc `$`(x: TResults): string =
|
||||||
"Tests skipped: $2 / $3 <br />\n") %
|
"Tests skipped: $2 / $3 <br />\n") %
|
||||||
[$x.passed, $x.skipped, $x.total]
|
[$x.passed, $x.skipped, $x.total]
|
||||||
|
|
||||||
proc colorBool(b: bool): string =
|
proc colorResult(r: TResultEnum): string =
|
||||||
if b: result = "<span style=\"color:green\">yes</span>"
|
case r
|
||||||
else: result = "<span style=\"color:red\">no</span>"
|
of reFailure: result = "<span style=\"color:red\">no</span>"
|
||||||
|
of reIgnored: result = "<span style=\"color:fuchsia\">ignored</span>"
|
||||||
|
of reSuccess: result = "<span style=\"color:green\">yes</span>"
|
||||||
|
|
||||||
const
|
const
|
||||||
TableHeader4 = "<table border=\"1\"><tr><td>Test</td><td>Expected</td>" &
|
TableHeader4 = "<table border=\"1\"><tr><td>Test</td><td>Expected</td>" &
|
||||||
|
|
@ -139,14 +144,14 @@ const
|
||||||
TableFooter = "</table>\n"
|
TableFooter = "</table>\n"
|
||||||
|
|
||||||
proc addResult(r: var TResults, test, expected, given: string,
|
proc addResult(r: var TResults, test, expected, given: string,
|
||||||
success: bool) =
|
success: TResultEnum) =
|
||||||
r.data.addf("<tr><td>$#</td><td>$#</td><td>$#</td><td>$#</td></tr>\n", [
|
r.data.addf("<tr><td>$#</td><td>$#</td><td>$#</td><td>$#</td></tr>\n", [
|
||||||
test, expected, given, success.colorBool])
|
test, expected, given, success.colorResult])
|
||||||
|
|
||||||
proc addResult(r: var TResults, test, given: string,
|
proc addResult(r: var TResults, test, given: string,
|
||||||
success: bool) =
|
success: TResultEnum) =
|
||||||
r.data.addf("<tr><td>$#</td><td>$#</td><td>$#</td></tr>\n", [
|
r.data.addf("<tr><td>$#</td><td>$#</td><td>$#</td></tr>\n", [
|
||||||
test, given, success.colorBool])
|
test, given, success.colorResult])
|
||||||
|
|
||||||
proc listResults(reject, compile, run: TResults) =
|
proc listResults(reject, compile, run: TResults) =
|
||||||
var s = "<html>"
|
var s = "<html>"
|
||||||
|
|
@ -166,15 +171,14 @@ proc listResults(reject, compile, run: TResults) =
|
||||||
close(outp)
|
close(outp)
|
||||||
|
|
||||||
proc cmpMsgs(r: var TResults, expected, given: TSpec, test: string) =
|
proc cmpMsgs(r: var TResults, expected, given: TSpec, test: string) =
|
||||||
inc(r.total)
|
|
||||||
if strip(expected.msg) notin strip(given.msg):
|
if strip(expected.msg) notin strip(given.msg):
|
||||||
r.addResult(test, expected.msg, given.msg, false)
|
r.addResult(test, expected.msg, given.msg, reFailure)
|
||||||
elif expected.file != given.file:
|
elif extractFilename(expected.file) != extractFilename(given.file):
|
||||||
r.addResult(test, expected.file, given.file, false)
|
r.addResult(test, expected.file, given.file, reFailure)
|
||||||
elif expected.line != given.line:
|
elif expected.line != given.line:
|
||||||
r.addResult(test, $expected.line, $given.line, false)
|
r.addResult(test, $expected.line, $given.line, reFailure)
|
||||||
else:
|
else:
|
||||||
r.addResult(test, expected.msg, given.msg, true)
|
r.addResult(test, expected.msg, given.msg, reSuccess)
|
||||||
inc(r.passed)
|
inc(r.passed)
|
||||||
|
|
||||||
proc reject(r: var TResults, dir, options: string) =
|
proc reject(r: var TResults, dir, options: string) =
|
||||||
|
|
@ -184,7 +188,9 @@ proc reject(r: var TResults, dir, options: string) =
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
echo t
|
echo t
|
||||||
var expected = parseSpec(test)
|
var expected = parseSpec(test)
|
||||||
if expected.disabled: inc(r.skipped)
|
if expected.disabled:
|
||||||
|
r.addResult(t, "", "", reIgnored)
|
||||||
|
inc(r.skipped)
|
||||||
else:
|
else:
|
||||||
var given = callCompiler(test, options)
|
var given = callCompiler(test, options)
|
||||||
cmpMsgs(r, expected, given, t)
|
cmpMsgs(r, expected, given, t)
|
||||||
|
|
@ -195,7 +201,7 @@ proc compile(r: var TResults, pattern, options: string) =
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
echo t
|
echo t
|
||||||
var given = callCompiler(test, options)
|
var given = callCompiler(test, options)
|
||||||
r.addResult(t, given.msg, not given.err)
|
r.addResult(t, given.msg, if given.err: reFailure else: reSuccess)
|
||||||
if not given.err: inc(r.passed)
|
if not given.err: inc(r.passed)
|
||||||
|
|
||||||
proc run(r: var TResults, dir, options: string) =
|
proc run(r: var TResults, dir, options: string) =
|
||||||
|
|
@ -204,20 +210,23 @@ proc run(r: var TResults, dir, options: string) =
|
||||||
echo t
|
echo t
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
var expected = parseSpec(test)
|
var expected = parseSpec(test)
|
||||||
if expected.disabled: inc(r.skipped)
|
if expected.disabled:
|
||||||
|
r.addResult(t, "", "", reIgnored)
|
||||||
|
inc(r.skipped)
|
||||||
else:
|
else:
|
||||||
var given = callCompiler(test, options)
|
var given = callCompiler(test, options)
|
||||||
if given.err:
|
if given.err:
|
||||||
r.addResult(t, "", given.msg, not given.err)
|
r.addResult(t, "", given.msg, reFailure)
|
||||||
else:
|
else:
|
||||||
var exeFile = changeFileExt(test, ExeExt)
|
var exeFile = changeFileExt(test, ExeExt)
|
||||||
if existsFile(exeFile):
|
if existsFile(exeFile):
|
||||||
var buf = myExec(exeFile)
|
var buf = myExec(exeFile)
|
||||||
var success = strip(buf) == strip(expected.outp)
|
var success = strip(buf) == strip(expected.outp)
|
||||||
if success: inc(r.passed)
|
if success: inc(r.passed)
|
||||||
r.addResult(t, expected.outp, buf, success)
|
r.addResult(t, expected.outp,
|
||||||
|
buf, if success: reSuccess else: reFailure)
|
||||||
else:
|
else:
|
||||||
r.addResult(t, expected.outp, "executable not found", false)
|
r.addResult(t, expected.outp, "executable not found", reFailure)
|
||||||
|
|
||||||
var options = ""
|
var options = ""
|
||||||
var rejectRes = initResults()
|
var rejectRes = initResults()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue