Skip to content

Commit

Permalink
Add testcase with constexpr constructor and trampoline
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Nov 20, 2024
1 parent 77fce67 commit 37cf8d4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/cpp/rpytest/ft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ClassWithFields,
ClassWithIgnored,
ClassWithTrampoline,
ConstexprTrampoline,
DocAppendClass,
DocAppendEnum,
DocClass,
Expand Down Expand Up @@ -123,6 +124,7 @@
"ClassWithFields",
"ClassWithIgnored",
"ClassWithTrampoline",
"ConstexprTrampoline",
"DocAppendClass",
"DocAppendEnum",
"DocClass",
Expand Down
16 changes: 16 additions & 0 deletions tests/cpp/rpytest/ft/include/trampoline.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,19 @@ struct ClassWithTrampoline {
// bug: ensure this doesn't get forwarded
ClassWithTrampoline(const int &name) {}
};


struct ConstexprTrampoline {
constexpr ConstexprTrampoline() = default;
constexpr virtual ~ConstexprTrampoline() = default;
constexpr virtual int fn() const = 0;
};

struct ChildConstexprTrampoline : ConstexprTrampoline {
constexpr ChildConstexprTrampoline(int i) : something(i) {}
constexpr int fn() const override {
return 1;
}

int something;
};
6 changes: 5 additions & 1 deletion tests/test_ft_trampoline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from rpytest.ft import ClassWithTrampoline
from rpytest.ft import ClassWithTrampoline, ConstexprTrampoline


def test_class_with_trampoline():
Expand All @@ -25,3 +25,7 @@ def fnWithMoveOnlyParam(self, i):

c = PyClassWithTrampoline()
assert ClassWithTrampoline.check_moveonly(c) == 8


def test_constexpr_trampoline():
ConstexprTrampoline()

0 comments on commit 37cf8d4

Please sign in to comment.