Merge branch 'devel' into fix_issues_9126
This commit is contained in:
commit
e867c8e5c3
29 changed files with 219 additions and 114 deletions
|
|
@ -9,6 +9,7 @@ import os, asyncfile, asyncdispatch
|
|||
const F = "test_async.txt"
|
||||
|
||||
removeFile(F)
|
||||
defer: removeFile(F)
|
||||
let f = openAsync(F, fmWrite)
|
||||
var futs = newSeq[Future[void]]()
|
||||
for i in 1..3:
|
||||
|
|
|
|||
33
tests/destructor/tprevent_assign.nim
Normal file
33
tests/destructor/tprevent_assign.nim
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
discard """
|
||||
errormsg: "'=' is not available for type <Foo>; requires a copy because it's not the last read of 'otherTree'"
|
||||
line: 29
|
||||
"""
|
||||
|
||||
type
|
||||
Foo = object
|
||||
x: int
|
||||
|
||||
proc `=destroy`(f: var Foo) = f.x = 0
|
||||
proc `=`(a: var Foo; b: Foo) {.error.} # = a.x = b.x
|
||||
proc `=sink`(a: var Foo; b: Foo) = a.x = b.x
|
||||
|
||||
proc createTree(x: int): Foo =
|
||||
Foo(x: x)
|
||||
|
||||
proc take2(a, b: sink Foo) =
|
||||
echo a.x, " ", b.x
|
||||
|
||||
proc allowThis() =
|
||||
# all these temporary lets are harmless:
|
||||
let otherTree = createTree(44)
|
||||
let b = otherTree
|
||||
let c = b
|
||||
take2(createTree(34), c)
|
||||
|
||||
proc preventThis() =
|
||||
let otherTree = createTree(44)
|
||||
let b = otherTree
|
||||
take2(createTree(34), otherTree)
|
||||
|
||||
allowThis()
|
||||
preventThis()
|
||||
31
tests/generics/t8694.nim
Normal file
31
tests/generics/t8694.nim
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
discard """
|
||||
output: '''
|
||||
true
|
||||
true
|
||||
true
|
||||
'''
|
||||
"""
|
||||
|
||||
when true:
|
||||
# Error: undeclared identifier: '|'
|
||||
proc bar[T](t:T): bool =
|
||||
runnableExamples:
|
||||
type Foo = int | float
|
||||
true
|
||||
echo bar(0)
|
||||
|
||||
when true:
|
||||
# ok
|
||||
proc bar(t:int): bool =
|
||||
runnableExamples:
|
||||
type Foo = int | float
|
||||
true
|
||||
echo bar(0)
|
||||
|
||||
when true:
|
||||
# Error: undeclared identifier: '|'
|
||||
proc bar(t:typedesc): bool =
|
||||
runnableExamples:
|
||||
type Foo = int | float
|
||||
true
|
||||
echo bar(int)
|
||||
33
tests/generics/t9130.nim
Normal file
33
tests/generics/t9130.nim
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
when true:
|
||||
# stack overflow
|
||||
template baz1*(iter: untyped): untyped =
|
||||
runnableExamples:
|
||||
import sugar
|
||||
proc fun(a: proc(x:int): int) = discard
|
||||
baz1(fun(x:int => x))
|
||||
discard
|
||||
|
||||
proc foo1[A](ts: A) =
|
||||
baz1(ts)
|
||||
|
||||
when true:
|
||||
# ok
|
||||
template baz2*(iter: untyped): untyped =
|
||||
runnableExamples:
|
||||
import sugar
|
||||
proc fun(a: proc(x:int): int) = discard
|
||||
baz2(fun(x:int => x))
|
||||
discard
|
||||
|
||||
proc foo2(ts: int) =
|
||||
baz2(ts)
|
||||
|
||||
when true:
|
||||
# stack overflow
|
||||
template baz3*(iter: untyped): untyped =
|
||||
runnableExamples:
|
||||
baz3(fun(x:int => x))
|
||||
discard
|
||||
|
||||
proc foo3[A](ts: A) =
|
||||
baz3(ts)
|
||||
|
|
@ -218,7 +218,7 @@ proc ioTests(r: var TResults, cat: Category, options: string) =
|
|||
# dummy compile result:
|
||||
var c = initResults()
|
||||
testSpec c, makeTest("tests/system/helpers/readall_echo", options, cat)
|
||||
testSpec r, makeTest("tests/system/io", options, cat)
|
||||
testSpec r, makeTest("tests/system/tio", options, cat)
|
||||
|
||||
# ------------------------- async tests ---------------------------------------
|
||||
proc asyncTests(r: var TResults, cat: Category, options: string) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue