summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-04-11 21:41:24 +0200
committerGitHub <noreply@github.com>2021-04-11 21:41:24 +0200
commitcae183915490846a0ec7dbcd52b29a74c7c59f05 (patch)
treec57bb4b996586a0cedfa5f16dd346e89610ccf40
parente710b9cf33939fa20230ab3029ceb735e0a669ad (diff)
downloadNim-cae183915490846a0ec7dbcd52b29a74c7c59f05.tar.gz
IC: added tcompiletime_counter test case (#17698)
-rw-r--r--tests/ic/mcompiletime_counter.nim15
-rw-r--r--tests/ic/tcompiletime_counter.nim24
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
+