Skip to content

Commit

Permalink
IC: added tcompiletime_counter test case (nim-lang#17698)
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq authored Apr 11, 2021
1 parent e710b9c commit cae1839
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/ic/mcompiletime_counter.nim
Original file line number Diff line number Diff line change
@@ -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


24 changes: 24 additions & 0 deletions tests/ic/tcompiletime_counter.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
discard """
output: '''id 4'''
"""

import mcompiletime_counter

const intId = getUniqueId()

echo "id ", intId

#!EDIT!#

discard """
output: '''id 4 5'''
"""

import mcompiletime_counter

const
intId = getUniqueId()
floatId = getUniqueId()

echo "id ", intId, " ", floatId

0 comments on commit cae1839

Please sign in to comment.