added test cases from strange loop event
This commit is contained in:
parent
429d337ef6
commit
9ab1a3c724
6 changed files with 152 additions and 0 deletions
22
tests/showoff/tonce.nim
Normal file
22
tests/showoff/tonce.nim
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
discard """
|
||||
output: '''first call of p
|
||||
some call of p
|
||||
new instantiation
|
||||
some call of p'''
|
||||
"""
|
||||
|
||||
template once(body: stmt) =
|
||||
var x {.global.} = false
|
||||
if not x:
|
||||
x = true
|
||||
body
|
||||
|
||||
proc p() =
|
||||
once:
|
||||
echo "first call of p"
|
||||
echo "some call of p"
|
||||
|
||||
p()
|
||||
once:
|
||||
echo "new instantiation"
|
||||
p()
|
||||
Loading…
Add table
Add a link
Reference in a new issue