def test03_fragile_class_based_overloads(self): """Test functions overloaded on void* and non-existing classes""" import cppyy MoreOverloads = cppyy.gbl.MoreOverloads # ROOT-specific ignores -- import ROOT oldval = ROOT.gErrorIgnoreLevel ROOT.gErrorIgnoreLevel = ROOT.kError OlAA = cppyy.gbl.OlAA OlBB = cppyy.gbl.OlBB OlCC = cppyy.gbl.OlCC OlDD = cppyy.gbl.OlDD from cppyy.gbl import get_OlBB, get_OlDD # first verify that BB and DD are indeed unknown raises(RuntimeError, OlBB) raises(RuntimeError, OlDD ) # then try overloads based on them assert MoreOverloads().call(OlAA()) == "OlAA" assert MoreOverloads().call(get_OlBB()) == "OlDD" # <- has an unknown + void* assert MoreOverloads().call(OlCC()) == "OlCC" assert MoreOverloads().call(get_OlDD()) == "OlDD" # <- has an unknown # -- ROOT-specific ignores ROOT.gErrorIgnoreLevel = oldval
def test03_fragile_class_based_overloads(self): """Test functions overloaded on void* and non-existing classes""" import cppyy MoreOverloads = cppyy.gbl.MoreOverloads # ROOT-specific ignores -- import ROOT oldval = ROOT.gErrorIgnoreLevel ROOT.gErrorIgnoreLevel = ROOT.kError OlAA = cppyy.gbl.OlAA OlBB = cppyy.gbl.OlBB OlCC = cppyy.gbl.OlCC OlDD = cppyy.gbl.OlDD from cppyy.gbl import get_OlBB, get_OlDD # first verify that BB and DD are indeed unknown raises(RuntimeError, OlBB) raises(RuntimeError, OlDD) # then try overloads based on them assert MoreOverloads().call(OlAA()) == "OlAA" assert MoreOverloads().call( get_OlBB()) == "OlDD" # <- has an unknown + void* assert MoreOverloads().call(OlCC()) == "OlCC" assert MoreOverloads().call(get_OlDD()) == "OlDD" # <- has an unknown # -- ROOT-specific ignores ROOT.gErrorIgnoreLevel = oldval
def test04_fully_fragile_overloads(self): """An unknown* is preferred over unknown&""" import cppyy MoreOverloads2 = cppyy.gbl.MoreOverloads2 # ROOT-specific ignores -- import ROOT oldval = ROOT.gErrorIgnoreLevel ROOT.gErrorIgnoreLevel = ROOT.kError from cppyy.gbl import get_OlBB, get_OlDD assert MoreOverloads2().call(get_OlBB()) == "OlBB*" assert MoreOverloads2().call(get_OlDD(), 1) == "OlDD*" # -- ROOT-specific ignores ROOT.gErrorIgnoreLevel = oldval
def test03_fragile_class_based_overloads(self): """Test functions overloaded on void* and non-existing classes""" import cppyy MoreOverloads = cppyy.gbl.MoreOverloads # ROOT-specific ignores -- import ROOT oldval = ROOT.gErrorIgnoreLevel ROOT.gErrorIgnoreLevel = ROOT.kError OlAA = cppyy.gbl.OlAA OlBB = cppyy.gbl.OlBB OlCC = cppyy.gbl.OlCC OlDD = cppyy.gbl.OlDD from cppyy.gbl import get_OlBB, get_OlDD # first verify that BB and DD are indeed unknown if not self.legacy_pyroot: # In new Cppyy, this raises a TypeError raises(TypeError, OlBB) raises(TypeError, OlDD) else: raises(RuntimeError, OlBB) raises(RuntimeError, OlDD) # then try overloads based on them assert MoreOverloads().call(OlAA()) == "OlAA" if not self.legacy_pyroot: # New Cppyy calls the same overload as C++: (const OlBB&, void*) get_olbb_res = "OlBB" else: get_olbb_res = "OlDD" # <- has an unknown + void* assert MoreOverloads().call(get_OlBB()) == get_olbb_res assert MoreOverloads().call(OlCC()) == "OlCC" assert MoreOverloads().call(get_OlDD()) == "OlDD" # <- has an unknown # -- ROOT-specific ignores ROOT.gErrorIgnoreLevel = oldval