summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJake Leahy <jake@leahy.dev>2021-12-21 03:29:03 +1100
committerGitHub <noreply@github.com>2021-12-20 17:29:03 +0100
commit4da7dbffc504db9159285ca59e2cdfe9b103afb8 (patch)
tree430e1b8bff6df81f100e134eb1f765d229cb9ce6 /tests
parentea475a4e98bc1cfc861f870baf6f2cc4c979ac7a (diff)
downloadNim-4da7dbffc504db9159285ca59e2cdfe9b103afb8.tar.gz
Extract runnables that specify `doccmd` (#19275) [backport:1.6]
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tmacros.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/stdlib/tmacros.nim b/tests/stdlib/tmacros.nim
index 64a474743..299eac49b 100644
--- a/tests/stdlib/tmacros.nim
+++ b/tests/stdlib/tmacros.nim
@@ -124,3 +124,23 @@ block: # SameType
     assert not testTensorInt(x1)
     assert testTensorInt(x2)
     assert not testTensorInt(x3)
+
+block: # extractDocCommentsAndRunnables
+  macro checkRunnables(prc: untyped) =
+    let runnables = prc.body.extractDocCommentsAndRunnables()
+    doAssert runnables[0][0].eqIdent("runnableExamples")
+
+  macro checkComments(comment: static[string], prc: untyped) =
+    let comments = prc.body.extractDocCommentsAndRunnables()
+    doAssert comments[0].strVal == comment
+    
+  proc a() {.checkRunnables.} =
+    runnableExamples: discard
+    discard
+
+  proc b() {.checkRunnables.} =
+    runnableExamples "-d:ssl": discard
+    discard
+    
+  proc c() {.checkComments("Hello world").} =
+    ## Hello world