Files
Nim/tests/misc/mbackend.nim
Timothee Cour e909486e5c trunner was not actually being tested in non-CTFFI mode; minor testament cleanups (#14377)
* use check
* trunner now works with cpp
* cleanup: move compiler/unittest_light => stdtest/unittest_light
* fix tests/readme.md
* remove deadcode references to rodfiles
* fix for windows
2020-05-19 09:41:31 +02:00

31 lines
901 B
Nim

#[
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
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