fix #10731 ; runnableExamples "-b:cpp --run:off": code works (#14384)

* runnableExamples "-b:cpp -r:off": code
This commit is contained in:
Timothee Cour 2020-05-20 00:45:34 -07:00 • committed by GitHub
commit 3d20f14193
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 104 additions and 37 deletions

View file

@ -117,7 +117,7 @@ else:
Ordinal* = OrdinalImpl | uint | uint64
when defined(nimHasRunnableExamples):
proc runnableExamples*(body: untyped) {.magic: "RunnableExamples".}
proc runnableExamples*(rdoccmd = "", body: untyped) {.magic: "RunnableExamples".}
## A section you should use to mark `runnable example`:idx: code with.
##
## - In normal debug and release builds code within
@ -139,10 +139,15 @@ when defined(nimHasRunnableExamples):
## assert double(5) == 10
## block: ## at block scope
## defer: echo "done"
##
## result = 2 * x
## runnableExamples "-d:foo -b:cpp":
## import std/compilesettings
## doAssert querySetting(backend) == "cpp"
## runnableExamples "-r:off": ## this one is only compiled
## import std/browsers
## openDefaultBrowser "https://forum.nim-lang.org/"
else:
template runnableExamples*(body: untyped) =
template runnableExamples*(doccmd = "", body: untyped) =
discard
proc declared*(x: untyped): bool {.magic: "Defined", noSideEffect, compileTime.}