mbackend.nim 901 B

12345678910111213141516171819202122232425262728293031
  1. #[
  2. We can't merge this test inside a `when defined(cpp)` because some bug that was
  3. fixed would not trigger in that case.
  4. ]#
  5. import std/compilesettings
  6. static:
  7. ## bugfix 1: this used to CT error with: Error: unhandled exception: mimportcpp.nim(6, 18) `defined(cpp)`
  8. doAssert defined(cpp)
  9. doAssert querySetting(backend) == "cpp"
  10. ## checks that `--backend:c` has no side effect (ie, can be overridden by subsequent commands)
  11. doAssert not defined(c)
  12. doAssert not defined(js)
  13. doAssert not defined(js)
  14. type
  15. std_exception {.importcpp: "std::exception", header: "<exception>".} = object
  16. proc what(s: std_exception): cstring {.importcpp: "((char *)#.what())".}
  17. var isThrown = false
  18. try:
  19. ## bugfix 2: this used to CT error with: Error: only a 'ref object' can be raised
  20. raise std_exception()
  21. except std_exception as ex:
  22. doAssert ex.what().len > 0
  23. isThrown = true
  24. doAssert isThrown