From 2b9656e077697f2cab8f21cc58b0c1a3d012e2db Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Thu, 23 Jan 2025 14:27:47 +0530 Subject: [PATCH] fix: typos when using `Cpp::Evaluate` (#124) * fix: typos when using `Cpp::Evaluate` * update tests tags --- python/cppyy/__init__.py | 2 +- test/test_cpp11features.py | 5 +++-- test/test_datatypes.py | 8 ++++---- test/test_fragile.py | 2 +- test/test_regression.py | 4 ++-- test/test_stltypes.py | 4 ++-- test/test_templates.py | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/python/cppyy/__init__.py b/python/cppyy/__init__.py index 579a37f6..dc00b0d6 100644 --- a/python/cppyy/__init__.py +++ b/python/cppyy/__init__.py @@ -389,7 +389,7 @@ def sizeof(tt): try: sz = ctypes.sizeof(tt) except TypeError: - sz = gbl.Cpp.Evaluate("sizeof(%s);" % (_get_name(tt),)) + sz = gbl.Cpp.Evaluate("sizeof(%s)" % (_get_name(tt),)) _sizes[tt] = sz return sz diff --git a/test/test_cpp11features.py b/test/test_cpp11features.py index a4dde9f6..b32bff9c 100644 --- a/test/test_cpp11features.py +++ b/test/test_cpp11features.py @@ -320,7 +320,7 @@ def test09_lambda_calls(self): assert cppyy.gbl.gMyLambda(2) == 42 assert cppyy.gbl.gMyLambda(40) == 80 - if cppyy.gbl.Cpp.Evaluate("__cplusplus;") >= 201402: + if cppyy.gbl.Cpp.Evaluate("__cplusplus") >= 201402: cppyy.cppdef("auto gime_a_lambda1() { return []() { return 42; }; }") l1 = cppyy.gbl.gime_a_lambda1() assert l1 @@ -336,12 +336,13 @@ def test09_lambda_calls(self): assert l3 assert l3(2) == 48 + @mark.xfail def test10_optional(self): """Use of optional and nullopt""" import cppyy - if 201703 <= cppyy.gbl.Cpp.Evaluate("__cplusplus;"): + if 201703 <= cppyy.gbl.Cpp.Evaluate("__cplusplus"): assert cppyy.gbl.std.optional assert cppyy.gbl.std.nullopt diff --git a/test/test_datatypes.py b/test/test_datatypes.py index be83e5d2..8daa08b1 100644 --- a/test/test_datatypes.py +++ b/test/test_datatypes.py @@ -17,7 +17,7 @@ def setup_class(cls): import cppyy cls.datatypes = cppyy.load_reflection_info(cls.test_dct) cls.N = 5 #cppyy.gbl.N - at_least_17 = 201402 < cppyy.gbl.Cpp.Evaluate("__cplusplus;") + at_least_17 = 201402 < cppyy.gbl.Cpp.Evaluate("__cplusplus") cls.has_byte = at_least_17 cls.has_optional = at_least_17 @@ -193,7 +193,7 @@ def test01_instance_data_read_access(self): c.__destruct__() - @mark.xfail(condition=not IS_CLANG_REPL, reason="fails with Cling") + @mark.xfail def test02_instance_data_write_access(self): """Test write access to instance public data and verify values""" @@ -378,7 +378,7 @@ def test03_array_passing(self): c.__destruct__() - @mark.xfail(condition= not(IS_CLANG_REPL), reason="Fails on with Cling") + @mark.xfail def test04_class_read_access(self): """Test read access to class public data and verify values""" @@ -442,7 +442,7 @@ def test04_class_read_access(self): c.__destruct__() - @mark.xfail(condition = not(IS_CLANG_REPL), reason="Fails on Cling") + @mark.xfail def test05_class_data_write_access(self): """Test write access to class public data and verify values""" diff --git a/test/test_fragile.py b/test/test_fragile.py index bab11b98..f795b63f 100644 --- a/test/test_fragile.py +++ b/test/test_fragile.py @@ -669,7 +669,7 @@ def test01_abortive_signals(self): class TestSTDNOTINGLOBAL: def setup_class(cls): import cppyy - cls.has_byte = 201402 < cppyy.gbl.Cpp.Evaluate("__cplusplus;") + cls.has_byte = 201402 < cppyy.gbl.Cpp.Evaluate("__cplusplus") def test01_stl_in_std(self): """STL classes should live in std:: only""" diff --git a/test/test_regression.py b/test/test_regression.py index 23f9d6f4..fa97be82 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -1015,7 +1015,7 @@ def test34_print_empty_collection(self): v = cppyy.gbl.std.vector[int]() str(v) - @mark.skipif(not IS_CLANG_REPL, reason="Crashes on Cling") + @mark.xfail(run=IS_CLANG_REPL, reason="Crashes on Cling") def test35_filesytem(self): """Static path object used to crash on destruction""" @@ -1025,7 +1025,7 @@ def test35_filesytem(self): import cppyy - if cppyy.gbl.Cpp.Evaluate("__cplusplus;") > 201402: + if cppyy.gbl.Cpp.Evaluate("__cplusplus") > 201402: cppyy.cppdef("""\ #include std::string stack_std_path() { diff --git a/test/test_stltypes.py b/test/test_stltypes.py index 04e086c9..5232ba7d 100644 --- a/test/test_stltypes.py +++ b/test/test_stltypes.py @@ -1599,12 +1599,12 @@ def setup_class(cls): import cppyy cls.stltypes = cppyy.load_reflection_info(cls.test_dct) - @mark.xfail(condition=not IS_CLANG_REPL, reason="xfail on Cling") + @mark.xfail def test01_string_through_string_view(self): """Usage of std::string_view as formal argument""" import cppyy - if cppyy.gbl.Cpp.Evaluate("__cplusplus;") <= 201402: + if cppyy.gbl.Cpp.Evaluate("__cplusplus") <= 201402: # string_view exists as of C++17 return countit = cppyy.gbl.StringViewTest.count diff --git a/test/test_templates.py b/test/test_templates.py index e1eaa6c2..1627e7a3 100644 --- a/test/test_templates.py +++ b/test/test_templates.py @@ -306,7 +306,7 @@ def test12_template_aliases(self): assert iavec[5] == 5 # with variadic template - if cppyy.gbl.Cpp.Evaluate("__cplusplus;") > 201402: + if cppyy.gbl.Cpp.Evaluate("__cplusplus") > 201402: assert nsup.matryoshka[int, 3].type assert nsup.matryoshka[int, 3, 4].type assert nsup.make_vector[int , 3]