diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2021-04-11 21:41:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-11 21:41:24 +0200 |
commit | cae183915490846a0ec7dbcd52b29a74c7c59f05 (patch) | |
tree | c57bb4b996586a0cedfa5f16dd346e89610ccf40 | |
parent | e710b9cf33939fa20230ab3029ceb735e0a669ad (diff) | |
download | Nim-cae183915490846a0ec7dbcd52b29a74c7c59f05.tar.gz |
IC: added tcompiletime_counter test case (#17698)
-rw-r--r-- | tests/ic/mcompiletime_counter.nim | 15 | ||||
-rw-r--r-- | tests/ic/tcompiletime_counter.nim | 24 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/ic/mcompiletime_counter.nim b/tests/ic/mcompiletime_counter.nim new file mode 100644 index 000000000..6fc7b3f2a --- /dev/null +++ b/tests/ic/mcompiletime_counter.nim @@ -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 + + diff --git a/tests/ic/tcompiletime_counter.nim b/tests/ic/tcompiletime_counter.nim new file mode 100644 index 000000000..695a6ec27 --- /dev/null +++ b/tests/ic/tcompiletime_counter.nim @@ -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 + |