diff options
author | Jake Leahy <jake@leahy.dev> | 2021-12-21 03:29:03 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-20 17:29:03 +0100 |
commit | 4da7dbffc504db9159285ca59e2cdfe9b103afb8 (patch) | |
tree | 430e1b8bff6df81f100e134eb1f765d229cb9ce6 /tests | |
parent | ea475a4e98bc1cfc861f870baf6f2cc4c979ac7a (diff) | |
download | Nim-4da7dbffc504db9159285ca59e2cdfe9b103afb8.tar.gz |
Extract runnables that specify `doccmd` (#19275) [backport:1.6]
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/tmacros.nim | 20 |
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 |