Skip to content

Commit

Permalink
Properly resolve enum type of class enums
Browse files Browse the repository at this point in the history
  • Loading branch information
wlav committed Aug 13, 2021
1 parent 5059ac8 commit 4827f76
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ master: 2.2.0
-------------

* Migrated repos to github/wlav
* Properly resolve enum type of class enums
* Fix sometimes PCH uninstall issue


Expand Down
45 changes: 41 additions & 4 deletions test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,44 @@ def test31_enum_in_dir(self):
required = {'prod', 'a', 'b', 'smth', 'my_enum'}
assert all_names.intersection(required) == required

def test32_explicit_template_in_namespace(self):
def test32_typedef_class_enum(self):
"""Use of class enum with typedef'd type"""

import cppyy

cppyy.cppdef("""\
namespace typedef_typed_enum {
enum class Foo1 : uint16_t { BAZ = 1, BAR = 2 };
enum class Foo2 : unsigned short { BAZ = 3, BAR = 4 };
enum Foo3 { BAZ = 5, BAR = 6 };
template<typename ENUMTYPE>
struct Info {
ENUMTYPE x;
uint8_t y;
}; } """)

ns = cppyy.gbl.typedef_typed_enum

Info = ns.Info

for Foo in [ns.Foo1, ns.Foo2, ns.Foo3]:
o = Info[Foo]()
o.x = Foo.BAR
o.y = 0

assert o.x == Foo.BAR
assert o.y == 0

o.y = 1
assert o.x == Foo.BAR
assert o.y == 1

o.x = Foo.BAZ
assert o.x == Foo.BAZ
assert o.y == 1

def test33_explicit_template_in_namespace(self):
"""Lookup of explicit template in namespace"""

import cppyy
Expand Down Expand Up @@ -951,7 +988,7 @@ class ReferenceWavefunction {};
pt_type = cppyy.gbl.property_types.ReferenceWavefunction['double']
assert cppyy.gbl.std.get[0](cppyy.gbl.property_types.run_as[pt_type]()) == 20.

def test33_print_empty_collection(self):
def test34_print_empty_collection(self):
"""Print empty collection through Cling"""

import cppyy
Expand All @@ -960,7 +997,7 @@ def test33_print_empty_collection(self):
v = cppyy.gbl.std.vector[int]()
str(v)

def test34_filesytem(self):
def test35_filesytem(self):
"""Static path object used to crash on destruction"""

import cppyy
Expand All @@ -977,7 +1014,7 @@ def test34_filesytem(self):

assert cppyy.gbl.stack_std_path() == '"/usr"'

def test35_ctypes_sizeof(self):
def test36_ctypes_sizeof(self):
"""cppyy.sizeof forwards to ctypes.sizeof where necessary"""

import cppyy, ctypes
Expand Down

0 comments on commit 4827f76

Please sign in to comment.