small bugfixes to make more tests green
This commit is contained in:
parent
84c473a890
commit
1f6725e59e
11 changed files with 40 additions and 11 deletions
|
|
@ -19,6 +19,7 @@ type
|
||||||
errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong,
|
errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong,
|
||||||
errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter,
|
errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter,
|
||||||
errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected,
|
errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected,
|
||||||
|
errNewlineExpected,
|
||||||
errInvalidModuleName,
|
errInvalidModuleName,
|
||||||
errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected,
|
errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected,
|
||||||
errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected,
|
errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected,
|
||||||
|
|
@ -128,6 +129,7 @@ const
|
||||||
errClosingBracketExpected: "closing ']' expected, but end of file reached",
|
errClosingBracketExpected: "closing ']' expected, but end of file reached",
|
||||||
errMissingFinalQuote: "missing final \'",
|
errMissingFinalQuote: "missing final \'",
|
||||||
errIdentifierExpected: "identifier expected, but found \'$1\'",
|
errIdentifierExpected: "identifier expected, but found \'$1\'",
|
||||||
|
errNewlineExpected: "newline expected, but found \'$1\'",
|
||||||
errInvalidModuleName: "invalid module name: '$1'",
|
errInvalidModuleName: "invalid module name: '$1'",
|
||||||
errOperatorExpected: "operator expected, but found \'$1\'",
|
errOperatorExpected: "operator expected, but found \'$1\'",
|
||||||
errTokenExpected: "\'$1\' expected",
|
errTokenExpected: "\'$1\' expected",
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,10 @@ proc optInd(p: var TParser, n: PNode) =
|
||||||
skipComment(p, n)
|
skipComment(p, n)
|
||||||
skipInd(p)
|
skipInd(p)
|
||||||
|
|
||||||
|
proc ExpectNl(p: TParser) =
|
||||||
|
if p.tok.tokType notin {tkEof, tkSad, tkInd, tkDed}:
|
||||||
|
lexMessage(p.lex, errNewlineExpected, prettyTok(p.tok))
|
||||||
|
|
||||||
proc expectIdentOrKeyw(p: TParser) =
|
proc expectIdentOrKeyw(p: TParser) =
|
||||||
if p.tok.tokType != tkSymbol and not isKeyword(p.tok.tokType):
|
if p.tok.tokType != tkSymbol and not isKeyword(p.tok.tokType):
|
||||||
lexMessage(p.lex, errIdentifierExpected, prettyTok(p.tok))
|
lexMessage(p.lex, errIdentifierExpected, prettyTok(p.tok))
|
||||||
|
|
@ -761,6 +765,7 @@ proc parseImportOrIncludeStmt(p: var TParser, kind: TNodeKind): PNode =
|
||||||
if p.tok.tokType != tkComma: break
|
if p.tok.tokType != tkComma: break
|
||||||
getTok(p)
|
getTok(p)
|
||||||
optInd(p, a)
|
optInd(p, a)
|
||||||
|
expectNl(p)
|
||||||
|
|
||||||
proc parseFromStmt(p: var TParser): PNode =
|
proc parseFromStmt(p: var TParser): PNode =
|
||||||
var a: PNode
|
var a: PNode
|
||||||
|
|
@ -798,6 +803,7 @@ proc parseFromStmt(p: var TParser): PNode =
|
||||||
if p.tok.tokType != tkComma: break
|
if p.tok.tokType != tkComma: break
|
||||||
getTok(p)
|
getTok(p)
|
||||||
optInd(p, a)
|
optInd(p, a)
|
||||||
|
expectNl(p)
|
||||||
|
|
||||||
proc parseReturnOrRaise(p: var TParser, kind: TNodeKind): PNode =
|
proc parseReturnOrRaise(p: var TParser, kind: TNodeKind): PNode =
|
||||||
result = newNodeP(kind, p)
|
result = newNodeP(kind, p)
|
||||||
|
|
@ -1299,6 +1305,7 @@ proc parseBind(p: var TParser): PNode =
|
||||||
if p.tok.tokType != tkComma: break
|
if p.tok.tokType != tkComma: break
|
||||||
getTok(p)
|
getTok(p)
|
||||||
optInd(p, a)
|
optInd(p, a)
|
||||||
|
expectNl(p)
|
||||||
|
|
||||||
proc simpleStmt(p: var TParser): PNode =
|
proc simpleStmt(p: var TParser): PNode =
|
||||||
case p.tok.tokType
|
case p.tok.tokType
|
||||||
|
|
|
||||||
|
|
@ -253,8 +253,10 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
addDecl(c, newSym(skUnknown, getIdent("result"), nil))
|
addDecl(c, newSym(skUnknown, getIdent("result"), nil))
|
||||||
n.sons[paramsPos] = semGenericStmt(c, n.sons[paramsPos], flags, toBind)
|
n.sons[paramsPos] = semGenericStmt(c, n.sons[paramsPos], flags, toBind)
|
||||||
n.sons[pragmasPos] = semGenericStmt(c, n.sons[pragmasPos], flags, toBind)
|
n.sons[pragmasPos] = semGenericStmt(c, n.sons[pragmasPos], flags, toBind)
|
||||||
var s = n.sons[namePos].sym
|
var body: PNode
|
||||||
n.sons[bodyPos] = semGenericStmtScope(c, s.getBody, flags, toBind)
|
if n.sons[namePos].kind == nkSym: body = n.sons[namePos].sym.getBody
|
||||||
|
else: body = n.sons[bodyPos]
|
||||||
|
n.sons[bodyPos] = semGenericStmtScope(c, body, flags, toBind)
|
||||||
closeScope(c.tab)
|
closeScope(c.tab)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
|
|
|
||||||
|
|
@ -735,7 +735,8 @@ proc SameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||||
result = sameObjectStructures(a, b, c)
|
result = sameObjectStructures(a, b, c)
|
||||||
of tyDistinct:
|
of tyDistinct:
|
||||||
CycleCheck()
|
CycleCheck()
|
||||||
result = sameTypeAux(a.sons[0], b.sons[0], c)
|
if c.cmp == dcEq: result = sameDistinctTypes(a, b)
|
||||||
|
else: result = sameTypeAux(a.sons[0], b.sons[0], c)
|
||||||
of tyEnum, tyForward, tyProxy:
|
of tyEnum, tyForward, tyProxy:
|
||||||
# XXX generic enums do not make much sense, but require structural checking
|
# XXX generic enums do not make much sense, but require structural checking
|
||||||
result = a.id == b.id
|
result = a.id == b.id
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@ proc unidecode*(s: string): string =
|
||||||
## Example:
|
## Example:
|
||||||
##
|
##
|
||||||
## ..code-block:: nimrod
|
## ..code-block:: nimrod
|
||||||
## unidecode("\\x53\\x17\\x4E\\xB0")
|
##
|
||||||
|
## unidecode("\x53\x17\x4E\xB0")
|
||||||
##
|
##
|
||||||
## Results in: "Bei Jing"
|
## Results in: "Bei Jing"
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,9 @@ proc printStatus*(s: TestStatus, name: string) =
|
||||||
styledEcho styleBright, color, "[", $s, "] ", fgWhite, name, "\n"
|
styledEcho styleBright, color, "[", $s, "] ", fgWhite, name, "\n"
|
||||||
|
|
||||||
template test*(name: expr, body: stmt): stmt =
|
template test*(name: expr, body: stmt): stmt =
|
||||||
if bind shouldRun(name):
|
bind shouldRun, checkPoints
|
||||||
bind checkpoints = @[]
|
if shouldRun(name):
|
||||||
|
checkpoints = @[]
|
||||||
var TestStatusIMPL = OK
|
var TestStatusIMPL = OK
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -67,7 +68,8 @@ proc checkpoint*(msg: string) =
|
||||||
# TODO: add support for something like SCOPED_TRACE from Google Test
|
# TODO: add support for something like SCOPED_TRACE from Google Test
|
||||||
|
|
||||||
template fail* =
|
template fail* =
|
||||||
for msg in items(bind checkpoints):
|
bind checkpoints
|
||||||
|
for msg in items(checkpoints):
|
||||||
echo msg
|
echo msg
|
||||||
|
|
||||||
if AbortOnError: quit(1)
|
if AbortOnError: quit(1)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ var
|
||||||
lastId = 0
|
lastId = 0
|
||||||
|
|
||||||
template genId*: expr =
|
template genId*: expr =
|
||||||
inc(bind lastId)
|
bind lastId
|
||||||
|
inc(lastId)
|
||||||
lastId
|
lastId
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@ discard """
|
||||||
proc p1(x: int8, y: int): int = return x + y
|
proc p1(x: int8, y: int): int = return x + y
|
||||||
|
|
||||||
template tempBind(x, y: expr): expr =
|
template tempBind(x, y: expr): expr =
|
||||||
bind p1(x, y)
|
bind p1
|
||||||
|
p1(x, y)
|
||||||
|
|
||||||
proc p1(x: int, y: int8): int = return x - y
|
proc p1(x: int, y: int8): int = return x - y
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ discard """
|
||||||
|
|
||||||
import unidecode
|
import unidecode
|
||||||
|
|
||||||
assert unidecode("\\x53\\x17\\x4E\\xB0") == "Bei Jing"
|
loadUnidecodeTable("lib/pure/unidecode/unidecode.dat")
|
||||||
|
|
||||||
|
assert unidecode("\x53\x17\x4E\xB0") == "Bei Jing"
|
||||||
echo unidecode("Äußerst")
|
echo unidecode("Äußerst")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ proc p1(x: int8, y: int): int = return x + y
|
||||||
proc p1(x: int, y: int8): int = return x - y
|
proc p1(x: int, y: int8): int = return x - y
|
||||||
|
|
||||||
template tempBind(x, y: expr): expr =
|
template tempBind(x, y: expr): expr =
|
||||||
bind p1(x, y) #ERROR_MSG ambiguous call
|
(bind p1(x, y)) #ERROR_MSG ambiguous call
|
||||||
|
|
||||||
echo tempBind(1'i8, 2'i8)
|
echo tempBind(1'i8, 2'i8)
|
||||||
|
|
||||||
|
|
|
||||||
10
tests/reject/tmissingnl.nim
Normal file
10
tests/reject/tmissingnl.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
file: "tmissingnl.nim"
|
||||||
|
line: 7
|
||||||
|
errormsg: "newline expected, but found 'keyword var'"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import strutils var s: seq[int] = @[0, 1, 2, 3, 4, 5, 6]
|
||||||
|
|
||||||
|
#s[1..3] = @[]
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue