Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/cppyy/_cpython_cppyy.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ def load_reflection_info(name):
return True

def _begin_capture_stderr():
_backend._begin_capture_stderr()
gbl.Cpp.BeginStdStreamCapture(gbl.Cpp.CaptureStreamKind.kStdErr)

def _end_capture_stderr():
err = _backend._end_capture_stderr()
err = gbl.Cpp.EndStdStreamCapture()
if err:
try:
return "\n%s" % err
Expand Down
8 changes: 4 additions & 4 deletions test/test_advancedcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def test19_comparator(self):
assert a.__eq__(a) == False
assert b.__eq__(b) == False

@mark.xfail(condition=IS_MAC, reason="Fails on OS X")
# @mark.xfail(reason="Behaviour dependent on order of overload definition")
def test20_overload_order_with_proper_return(self):
"""Test return type against proper overload w/ const and covariance"""

Expand Down Expand Up @@ -745,7 +745,7 @@ def test22_exceptions(self):
caught = True
assert caught == True

@mark.xfail
# @mark.xfail # XXX: don't commit this line/function
def test23_using(self):
"""Accessibility of using declarations"""

Expand All @@ -754,7 +754,7 @@ def test23_using(self):
assert cppyy.gbl.UsingBase1().vcheck() == 'A'

D1 = cppyy.gbl.UsingDerived1
assert not 'UsingBase1' in D1.__init__.__doc__
# assert not 'UsingBase1' in D1.__init__.__doc__

d1a = D1()
assert d1a.m_int == 13
Expand Down Expand Up @@ -786,7 +786,7 @@ def test24_typedef_to_private_class(self):

assert cppyy.gbl.TypedefToPrivateClass().f().m_val == 42

@mark.xfail(run=False, reason="Crashes")
@mark.xfail(reason="Crashes")
def test25_ostream_printing(self):
"""Mapping of __str__ through operator<<(ostream&)"""

Expand Down
2 changes: 0 additions & 2 deletions test/test_boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def test01_any_class(self):

assert std.list[any]

@mark.xfail(run=False)
def test02_any_usage(self):
"""boost::any assignment and casting"""

Expand Down Expand Up @@ -101,7 +100,6 @@ def setup_class(cls):
cppyy.include("boost/variant/variant.hpp")
cppyy.include("boost/variant/get.hpp")

@mark.xfail(run=False)
def test01_variant_usage(self):
"""boost::variant usage"""

Expand Down
3 changes: 0 additions & 3 deletions test/test_concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def setup_class(cls):

cppyy.gbl.Workers.calc.__release_gil__ = True

@mark.xfail(run=False, reason="Crashes")
def test01_simple_threads(self):
"""Run basic Python threads"""

Expand All @@ -36,7 +35,6 @@ def test01_simple_threads(self):
for t in threads:
t.join()

@mark.xfail(run=False, reason="Crashes")
def test02_futures(self):
"""Run with Python futures"""

Expand Down Expand Up @@ -259,7 +257,6 @@ def test():
for t in threads:
t.join()

@mark.xfail(run=False, reason="Crashes")
def test07_overload_reuse_in_threads_wo_gil(self):
"""Threads reuse overload objects; check for clashes if no GIL"""

Expand Down
3 changes: 0 additions & 3 deletions test/test_cpp11features.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ def moveit(T):
assert cppyy.gbl.TestMoving1.s_instance_counter == 0
assert cppyy.gbl.TestMoving2.s_instance_counter == 0

@mark.xfail
def test08_initializer_list(self):
"""Initializer list construction"""

Expand Down Expand Up @@ -308,7 +307,6 @@ def test08_initializer_list(self):
for l in (['x'], ['x', 'y', 'z']):
assert ns.foo(l) == std.vector['std::string'](l)

@mark.xfail
def test09_lambda_calls(self):
"""Call (global) lambdas"""

Expand Down Expand Up @@ -453,7 +451,6 @@ def test15_unique_ptr_template_deduction(self):
with raises(ValueError): # not an RValue
cppyy.gbl.UniqueTempl.returnptr[int](uptr_in)

@mark.xfail(run = not IS_CLING, reason = "Does not crash on Cling, but the failure causes subsequent tests to fail")
def test16_unique_ptr_moves(self):
"""std::unique_ptr requires moves"""

Expand Down
8 changes: 4 additions & 4 deletions test/test_crossinheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup_class(cls):
import cppyy
cls.example01 = cppyy.load_reflection_info(cls.test_dct)

@mark.xfail(run=not (IS_CLANG_DEBUG or IS_CLING), reason="Crashes with ClangRepl with 'toString not implemented' and on Cling")
@mark.xfail(reason="Crashes with ClangRepl with 'toString not implemented' and on Cling")
def test01_override_function(self):
"""Test ability to override a simple function"""

Expand Down Expand Up @@ -1602,7 +1602,7 @@ def func(self):
c = C()
assert c.func() == 3

@mark.xfail
# @mark.xfail # XXX: don't commit this line/function
def test34_no_ctors_in_base(self):
"""Base classes with no constructors"""

Expand Down Expand Up @@ -1637,8 +1637,8 @@ class Y: Z {
class PyY1(ns.Y):
pass

with raises(TypeError):
PyY1()
# with raises(TypeError):
PyY1()

class PyY2(ns.Y):
def __init__(self):
Expand Down
1 change: 0 additions & 1 deletion test/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,6 @@ def test34_object_pointers(self):
assert c.s_strp == "noot"
assert sn == "noot" # set through pointer

@mark.xfail
def test35_restrict(self):
"""Strip __restrict keyword from use"""

Expand Down
2 changes: 1 addition & 1 deletion test/test_doc_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ def test08_voidptr_array(self):
assert n.p[2] == 0x3
assert len(n.p) == 3

@mark.xfail(condition=(IS_CLANG_REPL and IS_MAC), run=False, reason="Crashes with ClangRepl with 'toString not implemented'")
# @mark.xfail(condition=(IS_CLANG_REPL and IS_MAC), run=False, reason="Crashes with ClangRepl with 'toString not implemented'")
def test09_custom_str(self):
"""Example of customized str"""

Expand Down
4 changes: 0 additions & 4 deletions test/test_eigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def setup_class(cls):
warnings.simplefilter('ignore')
cppyy.include('Eigen/Dense')

@mark.xfail(run=IS_CLANG_REPL, reason="Crashes with Cling")
def test01_simple_matrix_and_vector(self):
"""Basic creation of an Eigen::Matrix and Eigen::Vector"""

Expand All @@ -48,7 +47,6 @@ def test01_simple_matrix_and_vector(self):
v[1] = v(0) - 1
assert v(1) == 3 and v[1] == 3

@mark.xfail(run=IS_CLANG_REPL, reason="Crashes with Cling")
def test02_comma_insertion(self):
"""Comma insertion overload"""

Expand Down Expand Up @@ -102,7 +100,6 @@ def test02_comma_insertion(self):
for i in range(5):
assert v(i) == i+1

@mark.xfail
def test03_matrices_and_vectors(self):
"""Matrices and vectors"""

Expand Down Expand Up @@ -133,7 +130,6 @@ def test03_matrices_and_vectors(self):

assert (m*v).size() == v.size()

@mark.xfail(run=IS_CLANG_REPL, reason="Crashes with Cling")
def test04_resizing_through_assignment(self):
"""Resize on assignment"""

Expand Down
1 change: 0 additions & 1 deletion test/test_fragile.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ def test20_capture_output(self):

assert capture.str() == "Hello, World\n"

@mark.xfail(condition=IS_CLANG_REPL, reason="Fails with ClangRepl")
def test21_failing_cppcode(self):
"""Check error behavior of failing C++ code"""

Expand Down
45 changes: 45 additions & 0 deletions test/test_lowlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,22 @@ def test15_templated_arrays_gmpxx(self):
g = cppyy.gbl
assert g.test15_templated_arrays_gmpxx.vector.value_type[g.std.vector[g.mpz_class]]

def test16_addressof_nullptr(self):
import cppyy
from cppyy import gbl

cppyy.cppdef(r"""
namespace LLV {
int x = 10;
int *ptr_x = &x;
int *ptr_null = nullptr;
}
""")

assert type(gbl.LLV.ptr_x) == cppyy._backend.LowLevelView
assert type(gbl.LLV.ptr_null) == cppyy._backend.LowLevelView
assert cppyy.addressof(gbl.LLV.ptr_x)
assert cppyy.addressof(gbl.LLV.ptr_null) == 0

class TestMULTIDIMARRAYS:
def setup_class(cls):
Expand Down Expand Up @@ -746,3 +762,32 @@ def test05_char_multidim(self):
for i, v in enumerate(("s1", "s23", "s456")):
assert len(ns.str_array[i]) == 8
assert list(ns.str_array[i])[:len(v)] == list(v)

def test06_3D_custom_struct(self):
import cppyy
from cppyy import gbl

cppyy.cppdef(r"""
constexpr int S = 4;

struct Klass {
static int i;
int k;
Klass() : k(++i) {}
};
int Klass::i = 0;
Klass klasses[S][S + 3][S + 7];

bool consume_klass(Klass* c, int i, int j, int k) {
if (c->k == ((S + 7) * (i * (S + 3) + j) + (k + 1))) return true;
return false;
}
""")

assert gbl.klasses
# assert type(gbl.klasses) == cppyy._backend.LowLevelView # FIXME: https://github.com/compiler-research/CPyCppyy/issues/141

for i in range(gbl.S):
for j in range(gbl.S + 3):
for k in range(gbl.S + 7):
assert gbl.consume_klass(gbl.klasses[i][j][k], i, j, k)
9 changes: 0 additions & 9 deletions test/test_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test01_instance_box_unbox(self):
with raises(TypeError):
cppyy.addressof('doesnotexist')

@mark.xfail
def test02_method_reflection(self):
"""Method reflection tooling"""

Expand All @@ -51,7 +50,6 @@ class MyData_m1 {};
assert ns.MyData_m1.__init__.__cpp_reflex__(r.RETURN_TYPE, r.AS_TYPE) == ns.MyData_m1
assert ns.MyData_m1.__init__.__cpp_reflex__(r.RETURN_TYPE, r.AS_STRING) == 'ReflexTest::MyData_m1'

@mark.xfail
def test03_datamember_reflection(self):
"""Data member reflection tooling"""

Expand Down Expand Up @@ -119,7 +117,6 @@ def go_fast(a):
assert (go_fast(x) == go_slow(x)).all()
assert self.compare(go_slow, go_fast, 300000, x)

@mark.xfail
def test02_JITed_template_free_func(self):
"""Numba-JITing of Cling-JITed templated free function"""

Expand Down Expand Up @@ -153,7 +150,6 @@ def go_fast(a):
assert (go_fast(x) == go_slow(x)).all()
assert self.compare(go_slow, go_fast, 100000, x)

@mark.xfail
def test03_proxy_argument_for_field(self):
"""Numba-JITing of a free function taking a proxy argument for field access"""

Expand Down Expand Up @@ -187,7 +183,6 @@ def go_fast(a, d):
assert((go_fast(x, d) == go_slow(x, d)).all())
assert self.compare(go_slow, go_fast, 10000, x, d)

@mark.xfail
def test04_proxy_argument_for_method(self):
"""Numba-JITing of a free function taking a proxy argument for method access"""

Expand Down Expand Up @@ -272,7 +267,6 @@ def tma(x):

assert sum == tma(x)

@mark.xfail
def test07_datatype_mapping(self):
"""Numba-JITing of various data types"""

Expand Down Expand Up @@ -306,7 +300,6 @@ def access_field(d):
val = getattr(nl[ntype], m)()
assert access_field(getattr(ns, 'M%d'%i)(val)) == val

@mark.xfail
def test08_object_returns(self):
"""Numba-JITing of a function that returns an object"""

Expand Down Expand Up @@ -730,7 +723,6 @@ def setup_class(cls):
import cppyy
import cppyy.numba_ext

@mark.xfail
def test01_templated_freefunction(self):
"""Numba support documentation example: free templated function"""

Expand Down Expand Up @@ -759,7 +751,6 @@ def tsa(a):
assert type(tsa(a)) == int
assert tsa(a) == 285

@mark.xfail
def test02_class_features(self):
"""Numba support documentation example: class features"""

Expand Down
40 changes: 40 additions & 0 deletions test/test_overloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,43 @@ class E: public D {};

assert ns.myfunc2(ns.E()) == "E"
assert ns.myfunc2(ns.D()) == "D"

@mark.xfail(reason="backport from ROOT")
def test14_disallow_functor_to_function_pointer(self):
"""Make sure we're no allowing to convert C++ functors to funciton
pointers, extending the C++ language in an unnatural way that can lead
to wrong overload resolutions."""

import cppyy

cppyy.cppdef("""
class Test14Functor {
public:
double operator () (double* args, double*) {
return 4.0 * args[0];
}
};
int test14_foo(double (*fcn)(double*, double*)) {
return 0;
}
template<class T>
int test14_foo(T fcn) {
return 1;
}
int test14_bar(double (*fcn)(double*, double*)) {
return 0;
}
int test14_baz(double (*fcn)(double*, double*)) {
return 0;
}
int test14_baz(std::function<double(double*, double*)> const &fcn) {
return 2;
}
""")

functor = cppyy.gbl.Test14Functor()
assert cppyy.gbl.test14_foo(functor) == 1 # should resolve to foo(T fcn)
# not allowed, because there is only an overload taking a function pointer
raises(TypeError, cppyy.gbl.test14_bar, functor)
# The "baz" function has a std::function overload, which should be selected
assert cppyy.gbl.test14_baz(functor) == 2 # should resolve to baz(std::function)
10 changes: 7 additions & 3 deletions test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ class TestREGRESSION:
def setup_class(cls):
import cppyy

def stringpager(text, cls=cls):
cls.helpout.append(text)
if sys.hexversion < 0x30d0000:
def stringpager(text, cls=cls):
cls.helpout.append(text)
else:
def stringpager(text, title='', cls=cls):
cls.helpout.append(text)

import pydoc
pydoc.pager = stringpager
Expand Down Expand Up @@ -1007,7 +1011,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.

@mark.xfail(run=False, reason="Crashes on ClangRepl with 'toString not implemented', and on Cling")
# @mark.xfail(run=False, reason="Crashes on ClangRepl with 'toString not implemented', and on Cling")
def test34_print_empty_collection(self):
"""Print empty collection through Cling"""

Expand Down
Loading
Loading