mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 11:54:11 +00:00
* fix nim js cmp fails at CT * follow up #17486 * test more branches * better
This commit is contained in:
45
tests/iter/t16076.nim
Normal file
45
tests/iter/t16076.nim
Normal file
@@ -0,0 +1,45 @@
|
||||
discard """
|
||||
targets: "c js"
|
||||
"""
|
||||
|
||||
proc main() =
|
||||
block: # bug #17485
|
||||
type
|
||||
O = ref object
|
||||
i: int
|
||||
|
||||
iterator t(o: O): int =
|
||||
if o != nil:
|
||||
yield o.i
|
||||
yield 0
|
||||
|
||||
proc m =
|
||||
var data = ""
|
||||
for i in t(nil):
|
||||
data.addInt i
|
||||
|
||||
doAssert data == "0"
|
||||
|
||||
m()
|
||||
|
||||
|
||||
block: # bug #16076
|
||||
type
|
||||
R = ref object
|
||||
z: int
|
||||
|
||||
var data = ""
|
||||
|
||||
iterator foo(x: int; y: R = nil): int {.inline.} =
|
||||
if y == nil:
|
||||
yield x
|
||||
else:
|
||||
yield y.z
|
||||
|
||||
for b in foo(10):
|
||||
data.addInt b
|
||||
|
||||
doAssert data == "10"
|
||||
|
||||
static: main()
|
||||
main()
|
||||
Reference in New Issue
Block a user