Skip to content

Commit

Permalink
tests for hidden enums
Browse files Browse the repository at this point in the history
  • Loading branch information
wlav committed Apr 7, 2022
1 parent fe0b19d commit 2365d39
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ master: 2.4.0
* Special cases for __repr__/__str__ returning C++ stringy types
* Fix lookup of templates of function with template args
* Correct typing of int8_t/uint8_t enums
* Basic support for hidden enums


2022-04-03: 2.3.1
Expand Down
35 changes: 35 additions & 0 deletions test/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2239,3 +2239,38 @@ def test46_small_int_enums(self):
assert ns.func_int8() == -1
assert ns.func_uint8() == 255

def test47_hidden_name_enum(self):
"""Usage of hidden name enum"""

import cppyy
cppyy.cppdef(r"""
namespace EnumFunctionSameName {
enum foo { FOO = 42 };
void foo() {}
unsigned int bar(enum foo f) { return (unsigned int)f; }
struct Bar { Bar(enum foo f) : fFoo(f) {} enum foo fFoo; };
}""")

ns = cppyy.gbl.EnumFunctionSameName

assert ns.bar(ns.FOO) == 42
assert ns.Bar(ns.FOO)
assert ns.Bar(ns.FOO).fFoo == 42

# TODO:
cppyy.cppdef(r"""
namespace EnumFunctionSameName {
template<enum foo>
struct BarT {};
}""")
#ns.BarT[ns.FOO]()

# TODO:
cppyy.cppdef(r"""
namespace EnumFunctionSameName {
enum class Foo : int8_t { FOO };
void Foo() {}
void bar(enum Foo) {}
}""")
#ns.bar(ns.Foo.FOO)

0 comments on commit 2365d39

Please sign in to comment.