diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-02-24 05:01:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-24 14:01:06 +0100 |
commit | 11a7fa68f646777214a81cddaf3043d642c94c6b (patch) | |
tree | 16c56f6cf4bf1cdfc8d4b22cb37f7504145bf789 /testament | |
parent | 3021252ad44b60a35a58deb4abe4e001146dd09d (diff) | |
download | Nim-11a7fa68f646777214a81cddaf3043d642c94c6b.tar.gz |
fix #17159 items(cstring) works in VM (#17160)
* fix #17159 items(cstring) works in VM * improve test coverage tests/stdlib/tcstring.nim; add helpers: whenRuntimeJs, whenVMorJs * document items(cstring) * address comments
Diffstat (limited to 'testament')
-rw-r--r-- | testament/lib/stdtest/testutils.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testament/lib/stdtest/testutils.nim b/testament/lib/stdtest/testutils.nim index 50dda22e2..36f951272 100644 --- a/testament/lib/stdtest/testutils.nim +++ b/testament/lib/stdtest/testutils.nim @@ -42,3 +42,27 @@ template enableRemoteNetworking*: bool = ## process calls, e.g. `testament all` calls itself, which in turns invokes ## a `nim` invocation (possibly via additional intermediate processes). getEnv("NIM_TESTAMENT_REMOTE_NETWORKING") == "1" + +template whenRuntimeJs*(bodyIf, bodyElse) = + ##[ + Behaves as `when defined(js) and not nimvm` (which isn't legal yet). + pending improvements to `nimvm`, this sugar helps; use as follows: + + whenRuntimeJs: + doAssert defined(js) + when nimvm: doAssert false + else: discard + do: + discard + ]## + when nimvm: bodyElse + else: + when defined(js): bodyIf + else: bodyElse + +template whenVMorJs*(bodyIf, bodyElse) = + ## Behaves as: `when defined(js) or nimvm` + when nimvm: bodyIf + else: + when defined(js): bodyIf + else: bodyElse |