diff options
Diffstat (limited to 'tests/exception/tcpp_imported_exc.nim')
-rw-r--r-- | tests/exception/tcpp_imported_exc.nim | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/tests/exception/tcpp_imported_exc.nim b/tests/exception/tcpp_imported_exc.nim index c8349f7d5..55a58440f 100644 --- a/tests/exception/tcpp_imported_exc.nim +++ b/tests/exception/tcpp_imported_exc.nim @@ -1,6 +1,8 @@ discard """ +matrix: "--mm:refc" targets: "cpp" -output: '''caught as std::exception +output: ''' +caught as std::exception expected finally1 finally2 @@ -12,9 +14,10 @@ finally 2 expected cpp exception caught ''' +disabled: "windows" # pending bug #18011 """ -type +type std_exception* {.importcpp: "std::exception", header: "<exception>".} = object std_runtime_error* {.importcpp: "std::runtime_error", header: "<stdexcept>".} = object std_string* {.importcpp: "std::string", header: "<string>".} = object @@ -25,7 +28,7 @@ proc constructRuntimeError(s: stdstring): std_runtime_error {.importcpp: "std::r proc what(ex: std_runtime_error): cstring {.importcpp: "((char *)#.what())".} -proc myexception = +proc myexception = raise constructRuntimeError(constructStdString("cpp_exception")) try: @@ -41,17 +44,17 @@ except std_exception: doAssert(getCurrentException() == nil) -proc earlyReturn = +proc earlyReturn = try: try: - myexception() + myexception() finally: echo "finally1" except: return finally: echo "finally2" - + earlyReturn() doAssert(getCurrentException() == nil) @@ -74,7 +77,7 @@ doAssert(getCurrentException() == nil) # raise by pointer and also generic type type - std_vector {.importcpp"std::vector", header"<vector>".} [T] = object + std_vector[T] {.importcpp"std::vector", header"<vector>".} = object proc newVector[T](len: int): ptr std_vector[T] {.importcpp: "new std::vector<'1>(@)".} proc deleteVector[T](v: ptr std_vector[T]) {.importcpp: "delete @; @ = NIM_NIL;".} @@ -118,16 +121,15 @@ try: echo "finally 2" except: echo "expected" - - + doAssert(getCurrentException() == nil) try: - try: - myexception() - except std_runtime_error as ex: - echo "cpp exception caught" - raise newException(ValueError, "rewritten " & $ex.what()) + try: + myexception() + except std_runtime_error as ex: + echo "cpp exception caught" + raise newException(ValueError, "rewritten " & $ex.what()) except: doAssert(getCurrentExceptionMsg() == "rewritten cpp_exception") |