Merge branch 'devel' into araq-misc
This commit is contained in:
commit
a0cde8cee6
13 changed files with 90 additions and 20 deletions
|
|
@ -1130,8 +1130,8 @@ proc genAsgn(p: BProc, e: PNode, fastAsgn: bool) =
|
||||||
patchAsgnStmtListExpr(patchedTree, e, ri)
|
patchAsgnStmtListExpr(patchedTree, e, ri)
|
||||||
genStmts(p, patchedTree)
|
genStmts(p, patchedTree)
|
||||||
return
|
return
|
||||||
|
|
||||||
var a: TLoc
|
var a: TLoc
|
||||||
|
discard getTypeDesc(p.module, le.typ.skipTypes(skipPtrs))
|
||||||
if le.kind in {nkDerefExpr, nkHiddenDeref}:
|
if le.kind in {nkDerefExpr, nkHiddenDeref}:
|
||||||
genDeref(p, le, a, enforceDeref=true)
|
genDeref(p, le, a, enforceDeref=true)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1820,6 +1820,10 @@ proc userConvMatch(c: PContext, m: var TCandidate, f, a: PType,
|
||||||
let srca = typeRel(m, src, a)
|
let srca = typeRel(m, src, a)
|
||||||
if srca notin {isEqual, isGeneric, isSubtype}: continue
|
if srca notin {isEqual, isGeneric, isSubtype}: continue
|
||||||
|
|
||||||
|
let constraint = c.converters[i].typ.n[1].sym.constraint
|
||||||
|
if not constraint.isNil and not matchNodeKinds(constraint, arg):
|
||||||
|
continue
|
||||||
|
|
||||||
let destIsGeneric = containsGenericType(dest)
|
let destIsGeneric = containsGenericType(dest)
|
||||||
if destIsGeneric:
|
if destIsGeneric:
|
||||||
dest = generateTypeInstance(c, m.bindings, arg, dest)
|
dest = generateTypeInstance(c, m.bindings, arg, dest)
|
||||||
|
|
|
||||||
|
|
@ -539,11 +539,8 @@ proc transformFor(c: PTransf, n: PNode): PTransNode =
|
||||||
if call.kind notin nkCallKinds or call.sons[0].kind != nkSym or
|
if call.kind notin nkCallKinds or call.sons[0].kind != nkSym or
|
||||||
call.sons[0].typ.callConv == ccClosure:
|
call.sons[0].typ.callConv == ccClosure:
|
||||||
n.sons[length-1] = transformLoopBody(c, n.sons[length-1]).PNode
|
n.sons[length-1] = transformLoopBody(c, n.sons[length-1]).PNode
|
||||||
if not c.tooEarly:
|
n.sons[length-2] = transform(c, n.sons[length-2]).PNode
|
||||||
n.sons[length-2] = transform(c, n.sons[length-2]).PNode
|
result[1] = lambdalifting.liftForLoop(c.graph, n, getCurrOwner(c)).PTransNode
|
||||||
result[1] = lambdalifting.liftForLoop(c.graph, n, getCurrOwner(c)).PTransNode
|
|
||||||
else:
|
|
||||||
result[1] = newNode(nkEmpty).PTransNode
|
|
||||||
discard c.breakSyms.pop
|
discard c.breakSyms.pop
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
||||||
3
koch.nim
3
koch.nim
|
|
@ -57,7 +57,8 @@ Commands for core developers:
|
||||||
zip builds the installation zip package
|
zip builds the installation zip package
|
||||||
xz builds the installation tar.xz package
|
xz builds the installation tar.xz package
|
||||||
testinstall test tar.xz package; Unix only!
|
testinstall test tar.xz package; Unix only!
|
||||||
tests [options] run the testsuite
|
tests [options] run the testsuite (run a subset of tests by
|
||||||
|
specifying a category, e.g. `tests cat async`)
|
||||||
temp options creates a temporary compiler for testing
|
temp options creates a temporary compiler for testing
|
||||||
winrelease creates a Windows release
|
winrelease creates a Windows release
|
||||||
pushcsource push generated C sources to its repo
|
pushcsource push generated C sources to its repo
|
||||||
|
|
|
||||||
|
|
@ -621,12 +621,13 @@ iterator rsplit*(s: string, sep: string, maxsplit: int = -1,
|
||||||
## Substrings are separated from the right by the string `sep`
|
## Substrings are separated from the right by the string `sep`
|
||||||
rsplitCommon(s, sep, maxsplit, sep.len)
|
rsplitCommon(s, sep, maxsplit, sep.len)
|
||||||
|
|
||||||
iterator splitLines*(s: string): string =
|
iterator splitLines*(s: string, keepEol = false): string =
|
||||||
## Splits the string `s` into its containing lines.
|
## Splits the string `s` into its containing lines.
|
||||||
##
|
##
|
||||||
## Every `character literal <manual.html#character-literals>`_ newline
|
## Every `character literal <manual.html#character-literals>`_ newline
|
||||||
## combination (CR, LF, CR-LF) is supported. The result strings contain no
|
## combination (CR, LF, CR-LF) is supported. The result strings contain no
|
||||||
## trailing ``\n``.
|
## trailing end of line characters unless parameter ``keepEol`` is set to
|
||||||
|
## ``true``.
|
||||||
##
|
##
|
||||||
## Example:
|
## Example:
|
||||||
##
|
##
|
||||||
|
|
@ -646,22 +647,30 @@ iterator splitLines*(s: string): string =
|
||||||
## ""
|
## ""
|
||||||
var first = 0
|
var first = 0
|
||||||
var last = 0
|
var last = 0
|
||||||
|
var eolpos = 0
|
||||||
while true:
|
while true:
|
||||||
while last < s.len and s[last] notin {'\c', '\l'}: inc(last)
|
while last < s.len and s[last] notin {'\c', '\l'}: inc(last)
|
||||||
yield substr(s, first, last-1)
|
|
||||||
# skip newlines:
|
eolpos = last
|
||||||
if last >= s.len: break
|
if last < s.len:
|
||||||
if s[last] == '\l': inc(last)
|
if s[last] == '\l': inc(last)
|
||||||
elif s[last] == '\c':
|
elif s[last] == '\c':
|
||||||
inc(last)
|
inc(last)
|
||||||
if last < s.len and s[last] == '\l': inc(last)
|
if last < s.len and s[last] == '\l': inc(last)
|
||||||
|
|
||||||
|
yield substr(s, first, if keepEol: last-1 else: eolpos-1)
|
||||||
|
|
||||||
|
# no eol characters consumed means that the string is over
|
||||||
|
if eolpos == last:
|
||||||
|
break
|
||||||
|
|
||||||
first = last
|
first = last
|
||||||
|
|
||||||
proc splitLines*(s: string): seq[string] {.noSideEffect,
|
proc splitLines*(s: string, keepEol = false): seq[string] {.noSideEffect,
|
||||||
rtl, extern: "nsuSplitLines".} =
|
rtl, extern: "nsuSplitLines".} =
|
||||||
## The same as the `splitLines <#splitLines.i,string>`_ iterator, but is a
|
## The same as the `splitLines <#splitLines.i,string>`_ iterator, but is a
|
||||||
## proc that returns a sequence of substrings.
|
## proc that returns a sequence of substrings.
|
||||||
accumulateResult(splitLines(s))
|
accumulateResult(splitLines(s, keepEol=keepEol))
|
||||||
|
|
||||||
proc countLines*(s: string): int {.noSideEffect,
|
proc countLines*(s: string): int {.noSideEffect,
|
||||||
rtl, extern: "nsuCountLines".} =
|
rtl, extern: "nsuCountLines".} =
|
||||||
|
|
|
||||||
2
tests/ccgbugs/pkg8616/rtarray.nim
Normal file
2
tests/ccgbugs/pkg8616/rtarray.nim
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
proc head*[T](pp: var array[1,T]): var T =
|
||||||
|
result = pp[0]
|
||||||
10
tests/ccgbugs/pkg8616/scheduler.nim
Normal file
10
tests/ccgbugs/pkg8616/scheduler.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import rtarray
|
||||||
|
|
||||||
|
type
|
||||||
|
T = tuple[x:int]
|
||||||
|
|
||||||
|
var
|
||||||
|
arr: array[1,T]
|
||||||
|
|
||||||
|
proc init*() =
|
||||||
|
discard head(arr)
|
||||||
4
tests/ccgbugs/t8616.nim
Normal file
4
tests/ccgbugs/t8616.nim
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
import pkg8616 / scheduler
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
init()
|
||||||
12
tests/closure/t8550.nim
Normal file
12
tests/closure/t8550.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
discard """
|
||||||
|
output: "@[\"42\"]"
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc chk_fail(): seq[string] =
|
||||||
|
iterator x(): int {.closure.} = yield 42
|
||||||
|
proc f(cl: iterator(): int {.closure.}): seq[string] =
|
||||||
|
result = @[]
|
||||||
|
for i in cl(): result.add($i)
|
||||||
|
result = f(x)
|
||||||
|
|
||||||
|
echo(chk_fail())
|
||||||
20
tests/converter/tconverter_with_constraint.nim
Normal file
20
tests/converter/tconverter_with_constraint.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
discard """
|
||||||
|
file: "tconverter_with_constraint.nim"
|
||||||
|
line: 20
|
||||||
|
errormsg: "type mismatch: got <int>"
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
MyType = distinct int
|
||||||
|
|
||||||
|
converter to_mytype(m: int{lit}): MyType =
|
||||||
|
m.MyType
|
||||||
|
|
||||||
|
proc myproc(m: MyType) =
|
||||||
|
echo m.int, ".MyType"
|
||||||
|
|
||||||
|
myproc(1) # call by literal is ok
|
||||||
|
|
||||||
|
var x: int = 12
|
||||||
|
myproc(x) # should fail
|
||||||
|
|
@ -199,6 +199,12 @@ proc testRFind =
|
||||||
assert "0123456789ABCDEFGAH".rfind({'A'..'C'}, 13) == 12
|
assert "0123456789ABCDEFGAH".rfind({'A'..'C'}, 13) == 12
|
||||||
assert "0123456789ABCDEFGAH".rfind({'G'..'H'}, 13) == -1
|
assert "0123456789ABCDEFGAH".rfind({'G'..'H'}, 13) == -1
|
||||||
|
|
||||||
|
proc testSplitLines() =
|
||||||
|
let fixture = "a\nb\rc\r\nd"
|
||||||
|
assert len(fixture.splitLines) == 4
|
||||||
|
assert splitLines(fixture) == @["a", "b", "c", "d"]
|
||||||
|
assert splitLines(fixture, keepEol=true) == @["a\n", "b\r", "c\r\n", "d"]
|
||||||
|
|
||||||
proc testCountLines =
|
proc testCountLines =
|
||||||
proc assertCountLines(s: string) = assert s.countLines == s.splitLines.len
|
proc assertCountLines(s: string) = assert s.countLines == s.splitLines.len
|
||||||
assertCountLines("")
|
assertCountLines("")
|
||||||
|
|
@ -252,6 +258,7 @@ proc testParseInts =
|
||||||
testDelete()
|
testDelete()
|
||||||
testFind()
|
testFind()
|
||||||
testRFind()
|
testRFind()
|
||||||
|
testSplitLines()
|
||||||
testCountLines()
|
testCountLines()
|
||||||
testParseInts()
|
testParseInts()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -527,5 +527,9 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
|
||||||
# We can't test it because it depends on a third party.
|
# We can't test it because it depends on a third party.
|
||||||
discard # TODO: Move untestable tests to someplace else, i.e. nimble repo.
|
discard # TODO: Move untestable tests to someplace else, i.e. nimble repo.
|
||||||
else:
|
else:
|
||||||
|
var testsRun = 0
|
||||||
for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"):
|
for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"):
|
||||||
testSpec r, makeTest(name, options, cat)
|
testSpec r, makeTest(name, options, cat)
|
||||||
|
inc testsRun
|
||||||
|
if testsRun == 0:
|
||||||
|
echo "[Warning] - Invalid category specified \"", cat.string, "\", no tests were run"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ const
|
||||||
|
|
||||||
Command:
|
Command:
|
||||||
all run all tests
|
all run all tests
|
||||||
c|category <category> run all the tests of a certain category
|
c|cat|category <category> run all the tests of a certain category
|
||||||
r|run <test> run single test file
|
r|run <test> run single test file
|
||||||
html generate $1 from the database
|
html generate $1 from the database
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue