mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-14 15:43:45 +00:00
adds regression tests (#25906)
closes #22842, closes #21252, closes #19312, closes #16956, closes #16416, closes #14913, closes #13296, closes #12424, closes #10902, closes #9892, closes #9617
This commit is contained in:
19
tests/arc/t19312.nim
Normal file
19
tests/arc/t19312.nim
Normal file
@@ -0,0 +1,19 @@
|
||||
discard """
|
||||
matrix: "--mm:orc"
|
||||
output: '''(val: 1)
|
||||
(val: 1)'''
|
||||
"""
|
||||
# Issue #19312: copied ref object is converted to nil if not used in declaration module under ARC/ORC
|
||||
# https://github.com/nim-lang/Nim/issues/19312
|
||||
|
||||
type
|
||||
Wrapper* = object
|
||||
val: int
|
||||
RefWrapper* = ref Wrapper
|
||||
|
||||
let
|
||||
a* = RefWrapper(val: 1)
|
||||
b* = a
|
||||
|
||||
echo b[]
|
||||
echo a[]
|
||||
17
tests/async/t16416.nim
Normal file
17
tests/async/t16416.nim
Normal file
@@ -0,0 +1,17 @@
|
||||
discard """
|
||||
output: '''done'''
|
||||
"""
|
||||
# Issue #16416: Can't call closure iterator from inside an async function
|
||||
# https://github.com/nim-lang/Nim/issues/16416
|
||||
|
||||
import asyncdispatch
|
||||
|
||||
iterator x(): int {.closure.} =
|
||||
yield 1
|
||||
|
||||
proc y() {.async.} =
|
||||
for z in x():
|
||||
discard
|
||||
|
||||
waitFor y()
|
||||
echo "done"
|
||||
23
tests/concepts/t14913.nim
Normal file
23
tests/concepts/t14913.nim
Normal file
@@ -0,0 +1,23 @@
|
||||
discard """
|
||||
output: '''done'''
|
||||
"""
|
||||
# Issue #14913: Compiler crash when using a default parameter value for a parameter whose type is a concept
|
||||
# https://github.com/nim-lang/Nim/issues/14913
|
||||
|
||||
type
|
||||
State = object
|
||||
MoreState = object
|
||||
StringRecord = concept x, type T
|
||||
for k, v in fieldPairs(x):
|
||||
k is string
|
||||
v is string
|
||||
StateStrings = object
|
||||
a, b: string
|
||||
|
||||
proc combine(a: State, b: MoreState): StateStrings = discard
|
||||
|
||||
proc whoops[T: StringRecord](a: State, b: MoreState, c: T = a.combine(b)) =
|
||||
discard
|
||||
|
||||
whoops(State(), MoreState())
|
||||
echo "done"
|
||||
20
tests/destructor/t9617.nim
Normal file
20
tests/destructor/t9617.nim
Normal file
@@ -0,0 +1,20 @@
|
||||
discard """
|
||||
output: '''done'''
|
||||
"""
|
||||
# Issue #9617: Compiler error with sequences of destructible types
|
||||
# https://github.com/nim-lang/Nim/issues/9617
|
||||
|
||||
type
|
||||
Foo* = object
|
||||
|
||||
Bar = ref object
|
||||
s: seq[Foo]
|
||||
|
||||
proc `=destroy`*(self: var Foo) = echo "hi"
|
||||
|
||||
proc test(b: Bar) =
|
||||
for i in b.s:
|
||||
discard
|
||||
|
||||
test(Bar())
|
||||
echo "done"
|
||||
11
tests/errmsgs/t16956.nim
Normal file
11
tests/errmsgs/t16956.nim
Normal file
@@ -0,0 +1,11 @@
|
||||
discard """
|
||||
action: "reject"
|
||||
errormsg: "invalid type: 'iterator (a: int, b: int, step: Positive): int{.inline, noSideEffect, gcsafe.}' for const"
|
||||
line: 9
|
||||
"""
|
||||
# Issue #16956: Error: not unused depending on unrelated code changes
|
||||
# https://github.com/nim-lang/Nim/issues/16956
|
||||
|
||||
const f2 = case true
|
||||
of true: countup[int]
|
||||
of false: countdown[int]
|
||||
35
tests/generics/t21252.nim
Normal file
35
tests/generics/t21252.nim
Normal file
@@ -0,0 +1,35 @@
|
||||
discard """
|
||||
output: '''done'''
|
||||
"""
|
||||
# Issue #21252: Compiler SIGSEGV when not instantiating generic proc correctly
|
||||
# https://github.com/nim-lang/Nim/issues/21252
|
||||
|
||||
type
|
||||
Addr = object
|
||||
layerIdx: int
|
||||
|
||||
type Msg0 = object
|
||||
address: Addr
|
||||
selSample: tuple[inArrays: seq[seq[float64]], target: seq[float64], gradientStrength: float64]
|
||||
|
||||
type WeightUpdate = object
|
||||
address: Addr
|
||||
|
||||
proc workerThread[
|
||||
layer0StimulusWidth: static int
|
||||
]() =
|
||||
discard
|
||||
|
||||
proc z*[
|
||||
layer0StimulusWidth: static int,
|
||||
nUnitsPerLayer: static seq[int],
|
||||
targetLen: static int
|
||||
]() =
|
||||
workerThread[layer0StimulusWidth]()
|
||||
|
||||
when isMainModule:
|
||||
const layer0StimulusWidth: int = 5*29
|
||||
const nUnitsPerLayer: seq[int] = @[50, 5]
|
||||
const targetLen: int = 5
|
||||
z[layer0StimulusWidth, nUnitsPerLayer, targetLen]()
|
||||
echo "done"
|
||||
31
tests/macros/t10902.nim
Normal file
31
tests/macros/t10902.nim
Normal file
@@ -0,0 +1,31 @@
|
||||
discard """
|
||||
output: '''done'''
|
||||
"""
|
||||
# Issue #10902: cannot instantiate T when generating AST from macro
|
||||
# https://github.com/nim-lang/Nim/issues/10902
|
||||
|
||||
import macros
|
||||
|
||||
type
|
||||
Base[T] = ref object
|
||||
|
||||
macro genCloneProc(typeWithGenArg: untyped): untyped =
|
||||
result = newProc(
|
||||
ident "clone", [
|
||||
typeWithGenArg,
|
||||
newIdentDefs(
|
||||
ident "self",
|
||||
typeWithGenArg,
|
||||
)
|
||||
],
|
||||
newStmtList(
|
||||
newNimNode(nnkDiscardStmt).add(newEmptyNode())
|
||||
)
|
||||
)
|
||||
let genericParamIdent = typeWithGenArg[1]
|
||||
result[2] = newNimNode(nnkGenericParams)
|
||||
result[2].add(newIdentDefs(genericParamIdent, newEmptyNode()))
|
||||
|
||||
genCloneProc(Base[T])
|
||||
|
||||
echo "done"
|
||||
21
tests/macros/t13296.nim
Normal file
21
tests/macros/t13296.nim
Normal file
@@ -0,0 +1,21 @@
|
||||
discard """
|
||||
output: '''done'''
|
||||
"""
|
||||
# Issue #13296: Error: not unused with a macro
|
||||
# https://github.com/nim-lang/Nim/issues/13296
|
||||
|
||||
import macros
|
||||
macro dType(body: untyped) =
|
||||
if body.kind == nnkCall:
|
||||
var typ = newNimNode(nnkStmtList)
|
||||
typ.add quote do:
|
||||
discard
|
||||
elif body.kind == nnkTypeSection:
|
||||
result = newStmtList(
|
||||
body
|
||||
)
|
||||
|
||||
dType:
|
||||
echo "hi"
|
||||
|
||||
echo "done"
|
||||
16
tests/macros/t9892.nim
Normal file
16
tests/macros/t9892.nim
Normal file
@@ -0,0 +1,16 @@
|
||||
discard """
|
||||
output: '''1'''
|
||||
"""
|
||||
# Issue #9892: Incorrect "Error: not unused" from else branch in macro
|
||||
# https://github.com/nim-lang/Nim/issues/9892
|
||||
|
||||
import macros
|
||||
|
||||
macro foo(x: typed): untyped =
|
||||
result = newNimNode(nnkStmtListExpr)
|
||||
if x.kind == nnkStmtListExpr:
|
||||
result.add x
|
||||
else:
|
||||
result = x
|
||||
|
||||
echo foo(1)
|
||||
8
tests/pragmas/t12424.nim
Normal file
8
tests/pragmas/t12424.nim
Normal file
@@ -0,0 +1,8 @@
|
||||
discard """
|
||||
nimout: '''t12424.nim(8, 10) Warning: This is a test warning from user code [User]'''
|
||||
"""
|
||||
# Issue #12424: Warning and Hint Pragmas do not print to console when declared from a std lib module
|
||||
# https://github.com/nim-lang/Nim/issues/12424
|
||||
# This test verifies that warning pragmas in user code work correctly.
|
||||
|
||||
{.warning: "This is a test warning from user code".}
|
||||
11
tests/typerel/t22842.nim
Normal file
11
tests/typerel/t22842.nim
Normal file
@@ -0,0 +1,11 @@
|
||||
discard """
|
||||
output: '''done'''
|
||||
"""
|
||||
# Issue #22842: internal error: getTypeDescAux(tyAnything) with auto in proc type
|
||||
# https://github.com/nim-lang/Nim/issues/22842
|
||||
|
||||
proc register(cb: proc (e: auto): void) = discard
|
||||
|
||||
register(proc (e: int) = echo e)
|
||||
|
||||
echo "done"
|
||||
Reference in New Issue
Block a user