diff options
Diffstat (limited to 'tests/run/cpp_classes_def.pyx')
-rw-r--r-- | tests/run/cpp_classes_def.pyx | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/run/cpp_classes_def.pyx b/tests/run/cpp_classes_def.pyx index 0377fc1f6..855de7051 100644 --- a/tests/run/cpp_classes_def.pyx +++ b/tests/run/cpp_classes_def.pyx @@ -1,5 +1,5 @@ # mode: run -# tag: cpp, werror, cpp11 +# tag: cpp, werror, cpp11, no-cpp-locals # cython: experimental_cpp_class_def=True cdef double pi @@ -9,6 +9,7 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector from cython.operator cimport dereference as deref +import cython cdef extern from "shapes.h" namespace "shapes": cdef cppclass Shape: @@ -20,9 +21,14 @@ cdef cppclass RegularPolygon(Shape): __init__(int n, float radius): this.n = n this.radius = radius - float area() const: + float area() noexcept const: cdef double theta = pi / this.n return this.radius * this.radius * sin(theta) * cos(theta) * this.n + void do_with() except *: + # only a compile test - the file doesn't actually have to exist + # "with" was broken by https://github.com/cython/cython/issues/4212 + with open("doesnt matter") as f: + return def test_Poly(int n, float radius=1): """ @@ -249,3 +255,17 @@ def test_uncopyable_constructor_argument(): cdef UncopyableConstructorArgument *c = new UncopyableConstructorArgument( unique_ptr[vector[int]](new vector[int]())) del c + +cdef cppclass CppClassWithDocstring: + """ + This is a docstring ! + """ + +def test_CppClassWithDocstring(): + """ + >>> test_CppClassWithDocstring() + OK + """ + cdef CppClassWithDocstring *c = new CppClassWithDocstring() + del c + print "OK" |