Skip to content

Commit 37cf8d4

Browse files
committed
Add testcase with constexpr constructor and trampoline
1 parent 77fce67 commit 37cf8d4

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

tests/cpp/rpytest/ft/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
ClassWithFields,
88
ClassWithIgnored,
99
ClassWithTrampoline,
10+
ConstexprTrampoline,
1011
DocAppendClass,
1112
DocAppendEnum,
1213
DocClass,
@@ -123,6 +124,7 @@
123124
"ClassWithFields",
124125
"ClassWithIgnored",
125126
"ClassWithTrampoline",
127+
"ConstexprTrampoline",
126128
"DocAppendClass",
127129
"DocAppendEnum",
128130
"DocClass",

tests/cpp/rpytest/ft/include/trampoline.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,19 @@ struct ClassWithTrampoline {
3838
// bug: ensure this doesn't get forwarded
3939
ClassWithTrampoline(const int &name) {}
4040
};
41+
42+
43+
struct ConstexprTrampoline {
44+
constexpr ConstexprTrampoline() = default;
45+
constexpr virtual ~ConstexprTrampoline() = default;
46+
constexpr virtual int fn() const = 0;
47+
};
48+
49+
struct ChildConstexprTrampoline : ConstexprTrampoline {
50+
constexpr ChildConstexprTrampoline(int i) : something(i) {}
51+
constexpr int fn() const override {
52+
return 1;
53+
}
54+
55+
int something;
56+
};

tests/test_ft_trampoline.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from rpytest.ft import ClassWithTrampoline
1+
from rpytest.ft import ClassWithTrampoline, ConstexprTrampoline
22

33

44
def test_class_with_trampoline():
@@ -25,3 +25,7 @@ def fnWithMoveOnlyParam(self, i):
2525

2626
c = PyClassWithTrampoline()
2727
assert ClassWithTrampoline.check_moveonly(c) == 8
28+
29+
30+
def test_constexpr_trampoline():
31+
ConstexprTrampoline()

0 commit comments

Comments
 (0)