make tests green again
This commit is contained in:
parent
ee13c8014b
commit
3e7b04683c
4 changed files with 30 additions and 11 deletions
|
|
@ -161,6 +161,10 @@ proc addTempDecl(c: PContext; n: PNode; kind: TSymKind) =
|
||||||
proc semGenericStmt(c: PContext, n: PNode,
|
proc semGenericStmt(c: PContext, n: PNode,
|
||||||
flags: TSemGenericFlags, ctx: var GenericCtx): PNode =
|
flags: TSemGenericFlags, ctx: var GenericCtx): PNode =
|
||||||
result = n
|
result = n
|
||||||
|
|
||||||
|
when defined(nimsuggest):
|
||||||
|
if withinTypeDesc in flags: inc c.inTypeContext
|
||||||
|
|
||||||
#if gCmd == cmdIdeTools: suggestStmt(c, n)
|
#if gCmd == cmdIdeTools: suggestStmt(c, n)
|
||||||
semIdeForTemplateOrGenericCheck(n, ctx.cursorInBody)
|
semIdeForTemplateOrGenericCheck(n, ctx.cursorInBody)
|
||||||
|
|
||||||
|
|
@ -458,6 +462,10 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
result.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
|
result.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
|
||||||
|
|
||||||
|
when defined(nimsuggest):
|
||||||
|
if withinTypeDesc in flags: dec c.inTypeContext
|
||||||
|
|
||||||
|
|
||||||
proc semGenericStmt(c: PContext, n: PNode): PNode =
|
proc semGenericStmt(c: PContext, n: PNode): PNode =
|
||||||
var ctx: GenericCtx
|
var ctx: GenericCtx
|
||||||
ctx.toMixin = initIntset()
|
ctx.toMixin = initIntset()
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,11 @@ proc semTemplSomeDecl(c: var TemplCtx, n: PNode, symKind: TSymKind; start=0) =
|
||||||
if (a.kind != nkIdentDefs) and (a.kind != nkVarTuple): illFormedAst(a)
|
if (a.kind != nkIdentDefs) and (a.kind != nkVarTuple): illFormedAst(a)
|
||||||
checkMinSonsLen(a, 3)
|
checkMinSonsLen(a, 3)
|
||||||
var L = sonsLen(a)
|
var L = sonsLen(a)
|
||||||
|
when defined(nimsuggest):
|
||||||
|
inc c.c.inTypeContext
|
||||||
a.sons[L-2] = semTemplBody(c, a.sons[L-2])
|
a.sons[L-2] = semTemplBody(c, a.sons[L-2])
|
||||||
|
when defined(nimsuggest):
|
||||||
|
dec c.c.inTypeContext
|
||||||
a.sons[L-1] = semTemplBody(c, a.sons[L-1])
|
a.sons[L-1] = semTemplBody(c, a.sons[L-1])
|
||||||
for j in countup(0, L-3):
|
for j in countup(0, L-3):
|
||||||
addLocalDecl(c, a.sons[j], symKind)
|
addLocalDecl(c, a.sons[j], symKind)
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,8 @@ proc filterSym(s: PSym; prefix: PNode): bool {.inline.} =
|
||||||
if n.len > 0:
|
if n.len > 0:
|
||||||
result = prefixMatch(s, n[0])
|
result = prefixMatch(s, n[0])
|
||||||
else: discard
|
else: discard
|
||||||
|
if result:
|
||||||
|
echo "indeed a prefix match ", n
|
||||||
if s.kind != skModule:
|
if s.kind != skModule:
|
||||||
result = prefix.isNil or prefixMatch(s, prefix)
|
result = prefix.isNil or prefixMatch(s, prefix)
|
||||||
|
|
||||||
|
|
@ -471,7 +473,10 @@ proc suggestExpr*(c: PContext, node: PNode) =
|
||||||
if n == nil: n = node
|
if n == nil: n = node
|
||||||
if n.kind == nkDotExpr:
|
if n.kind == nkDotExpr:
|
||||||
var obj = safeSemExpr(c, n.sons[0])
|
var obj = safeSemExpr(c, n.sons[0])
|
||||||
let prefix = if n.len == 2: n[1] else: nil
|
# it can happen that errnously we have collected the fieldname
|
||||||
|
# of the next line, so we check the 'field' is actually on the same
|
||||||
|
# line as the object to prevent this from happening:
|
||||||
|
let prefix = if n.len == 2 and n[1].info.line == n[0].info.line: n[1] else: nil
|
||||||
suggestFieldAccess(c, obj, prefix, outputs)
|
suggestFieldAccess(c, obj, prefix, outputs)
|
||||||
|
|
||||||
#if optIdeDebug in gGlobalOptions:
|
#if optIdeDebug in gGlobalOptions:
|
||||||
|
|
|
||||||
|
|
@ -212,8 +212,8 @@ proc doReport(filename, answer, resp: string; report: var string) =
|
||||||
var hasDiff = false
|
var hasDiff = false
|
||||||
for i in 0..min(resp.len-1, answer.len-1):
|
for i in 0..min(resp.len-1, answer.len-1):
|
||||||
if resp[i] != answer[i]:
|
if resp[i] != answer[i]:
|
||||||
report.add "\n Expected: " & resp.substr(i)
|
report.add "\n Expected: " & resp.substr(i, i+200)
|
||||||
report.add "\n But got: " & answer.substr(i)
|
report.add "\n But got: " & answer.substr(i, i+200)
|
||||||
hasDiff = true
|
hasDiff = true
|
||||||
break
|
break
|
||||||
if not hasDiff:
|
if not hasDiff:
|
||||||
|
|
@ -233,15 +233,17 @@ proc runEpcTest(filename: string): int =
|
||||||
let outp = p.outputStream
|
let outp = p.outputStream
|
||||||
let inp = p.inputStream
|
let inp = p.inputStream
|
||||||
var report = ""
|
var report = ""
|
||||||
#var a = newStringOfCap(120)
|
|
||||||
try:
|
try:
|
||||||
# read the port number:
|
# read the port number:
|
||||||
#discard outp.readLine(a)
|
when defined(posix):
|
||||||
var i = 0
|
var a = newStringOfCap(120)
|
||||||
while not osproc.hasData(p) and i < 100:
|
discard outp.readLine(a)
|
||||||
os.sleep(50)
|
else:
|
||||||
inc i
|
var i = 0
|
||||||
let a = outp.readAll().strip()
|
while not osproc.hasData(p) and i < 100:
|
||||||
|
os.sleep(50)
|
||||||
|
inc i
|
||||||
|
let a = outp.readAll().strip()
|
||||||
let port = parseInt(a)
|
let port = parseInt(a)
|
||||||
var socket = newSocket()
|
var socket = newSocket()
|
||||||
socket.connect("localhost", Port(port))
|
socket.connect("localhost", Port(port))
|
||||||
|
|
@ -298,7 +300,7 @@ proc runTest(filename: string): int =
|
||||||
proc main() =
|
proc main() =
|
||||||
var failures = 0
|
var failures = 0
|
||||||
when false:
|
when false:
|
||||||
let x = getAppDir() / "tests/twithin_macro.nim"
|
let x = getAppDir() / "tests/tdot1.nim"
|
||||||
let xx = expandFilename x
|
let xx = expandFilename x
|
||||||
failures += runEpcTest(xx)
|
failures += runEpcTest(xx)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue