summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bradshaw <robertwb@gmail.com>2014-10-29 10:48:35 -0700
committerRobert Bradshaw <robertwb@gmail.com>2014-10-29 10:48:35 -0700
commitc62cd65514b6ec726f60af3091f40cf280ec7122 (patch)
tree34a3d05e4276e5ca72b016029d3b99a1a8ecf59f
parente22c29ee379a1bbcd65d46cf15a8947cb6581eb6 (diff)
downloadcython-c62cd65514b6ec726f60af3091f40cf280ec7122.tar.gz
Test for non-default constructor in bases.
-rw-r--r--tests/run/cpp_classes.pyx5
-rw-r--r--tests/run/shapes.h14
2 files changed, 14 insertions, 5 deletions
diff --git a/tests/run/cpp_classes.pyx b/tests/run/cpp_classes.pyx
index 5f2dbf83f..927192c21 100644
--- a/tests/run/cpp_classes.pyx
+++ b/tests/run/cpp_classes.pyx
@@ -7,7 +7,10 @@ cdef extern from "shapes.h" namespace "shapes":
cdef cppclass Shape:
float area()
- cdef cppclass Circle(Shape):
+ cdef cppclass Ellipse(Shape):
+ Ellipse(int a, int b) except +
+
+ cdef cppclass Circle(Ellipse):
int radius
Circle(int r) except +
diff --git a/tests/run/shapes.h b/tests/run/shapes.h
index 45dc77e0b..5ed202b7b 100644
--- a/tests/run/shapes.h
+++ b/tests/run/shapes.h
@@ -40,11 +40,17 @@ namespace shapes {
Square(int side) : Rectangle(side, side) { this->side = side; }
int side;
};
-
- class Circle : public Shape {
+
+ class Ellipse : public Shape {
+ public:
+ Ellipse(int a, int b) { this->a = a; this->b = b; }
+ float area() const { return 3.1415926535897931f * a * b; }
+ int a, b;
+ };
+
+ class Circle : public Ellipse {
public:
- Circle(int radius) { this->radius = radius; }
- float area() const { return 3.1415926535897931f * radius; }
+ Circle(int radius) : Ellipse(radius, radius) { this->radius = radius; }
int radius;
};