IC: added tcompiletime_counter test case (#17698)
This commit is contained in:
parent
e710b9cf33
commit
cae1839154
2 changed files with 39 additions and 0 deletions
15
tests/ic/mcompiletime_counter.nim
Normal file
15
tests/ic/mcompiletime_counter.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
import std/macros
|
||||
import std/macrocache
|
||||
|
||||
const myCounter = CacheCounter"myCounter"
|
||||
|
||||
proc getUniqueId*(): int {.compileTime.} =
|
||||
inc myCounter
|
||||
result = myCounter.value
|
||||
|
||||
static:
|
||||
myCounter.inc(3)
|
||||
assert myCounter.value == 3
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue