diff options
Diffstat (limited to 'tests/cpp')
-rw-r--r-- | tests/cpp/tcppraise.nim | 17 | ||||
-rw-r--r-- | tests/cpp/tget_subsystem.nim (renamed from tests/cpp/get_subsystem.nim) | 3 | ||||
-rw-r--r-- | tests/cpp/tvector_iterator.nim (renamed from tests/cpp/vector_iterator.nim) | 0 | ||||
-rw-r--r-- | tests/cpp/tvectorseq.nim | 38 |
4 files changed, 57 insertions, 1 deletions
diff --git a/tests/cpp/tcppraise.nim b/tests/cpp/tcppraise.nim new file mode 100644 index 000000000..a9ea8e6ce --- /dev/null +++ b/tests/cpp/tcppraise.nim @@ -0,0 +1,17 @@ +discard """ + cmd: "nim cpp $file" + output: '''foo +bar +Need odd and >= 3 digits## +baz''' +""" + +# bug #1888 +echo "foo" +try: + echo "bar" + raise newException(ValueError, "Need odd and >= 3 digits") +# echo "baz" +except ValueError: + echo getCurrentExceptionMsg(), "##" +echo "baz" diff --git a/tests/cpp/get_subsystem.nim b/tests/cpp/tget_subsystem.nim index 38593b03a..461914739 100644 --- a/tests/cpp/get_subsystem.nim +++ b/tests/cpp/tget_subsystem.nim @@ -16,7 +16,8 @@ struct SystemManager { """.} type Input {.importcpp: "System::Input".} = object -proc getSubsystem*[T](): ptr T {.importcpp: "SystemManager::getSubsystem<'*0>()".} +proc getSubsystem*[T](): ptr T {. + importcpp: "SystemManager::getSubsystem<'*0>()", nodecl.} let input: ptr Input = getSubsystem[Input]() diff --git a/tests/cpp/vector_iterator.nim b/tests/cpp/tvector_iterator.nim index cb5ab33af..cb5ab33af 100644 --- a/tests/cpp/vector_iterator.nim +++ b/tests/cpp/tvector_iterator.nim diff --git a/tests/cpp/tvectorseq.nim b/tests/cpp/tvectorseq.nim new file mode 100644 index 000000000..6eb5dc9e4 --- /dev/null +++ b/tests/cpp/tvectorseq.nim @@ -0,0 +1,38 @@ +discard """ + output: '''(x: 1.0) +(x: 0.0)''' + cmd: "nim cpp $file" + disabled: "true" +""" + +# This cannot work yet because we omit type information for importcpp'ed types. +# Fixing this is not hard, but also requires fixing Urhonimo. + +# bug #2536 + +{.emit: """/*TYPESECTION*/ +struct Vector3 { +public: + Vector3(): x(5) {} + Vector3(float x_): x(x_) {} + float x; +}; +""".} + +type Vector3 {.importcpp: "Vector3", nodecl} = object + x: cfloat + +proc constructVector3(a: cfloat): Vector3 {.importcpp: "Vector3(@)", nodecl} + +# hack around another codegen issue: Generics are attached to where they came +# from: +proc `$!`(v: seq[Vector3]): string = "(x: " & $v[0].x & ")" + +proc vec3List*(): seq[Vector3] = + let s = @[constructVector3(cfloat(1))] + echo($!s) + result = s + echo($!result) + +let f = vec3List() +#echo($!f) |