diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-05-16 04:09:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-16 13:09:18 +0200 |
commit | c777f2fb608e1f42daf31d314dda0050f6354acd (patch) | |
tree | 1fa2341dda9dc9da49fc5745360c81cc023d5b26 /tests/misc/mbackend.nim | |
parent | c32e1378eb7d62d59c9e24322c282556c821030a (diff) | |
download | Nim-c777f2fb608e1f42daf31d314dda0050f6354acd.tar.gz |
fix some issues with --backend (#14363)
* fix some issues with --backend * fix https://github.com/timotheecour/Nim/issues/175; improve upon #14306
Diffstat (limited to 'tests/misc/mbackend.nim')
-rw-r--r-- | tests/misc/mbackend.nim | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/misc/mbackend.nim b/tests/misc/mbackend.nim new file mode 100644 index 000000000..e38eb2d3e --- /dev/null +++ b/tests/misc/mbackend.nim @@ -0,0 +1,31 @@ +#[ +We can't merge this test inside a `when defined(cpp)` because some bug that was +fixed would not trigger in that case. +]# + +import std/compilesettings +import std/unittest + +static: + ## bugfix 1: this used to CT error with: Error: unhandled exception: mimportcpp.nim(6, 18) `defined(cpp)` + doAssert defined(cpp) + doAssert querySetting(backend) == "cpp" + + ## checks that `--backend:c` has no side effect (ie, can be overridden by subsequent commands) + doAssert not defined(c) + doAssert not defined(js) + doAssert not defined(js) + +type + std_exception {.importcpp: "std::exception", header: "<exception>".} = object +proc what(s: std_exception): cstring {.importcpp: "((char *)#.what())".} + +var isThrown = false +try: + ## bugfix 2: this used to CT error with: Error: only a 'ref object' can be raised + raise std_exception() +except std_exception as ex: + doAssert ex.what().len > 0 + isThrown = true + +doAssert isThrown |