diff options
author | Jason Lowe-Power <jason@lowepower.com> | 2017-11-17 17:02:05 -0800 |
---|---|---|
committer | Jason Lowe-Power <jason@lowepower.com> | 2017-12-14 00:27:59 +0000 |
commit | f07d5069d86e31ecf195664850f79fb00c445bd3 (patch) | |
tree | f54ac06896fa828f873d199a0e9b25bd94911c79 /ext/pybind11/tests/test_eval.cpp | |
parent | 3f64b374c49491f18dc2ca538ed8c8597e4aac83 (diff) | |
download | gem5-f07d5069d86e31ecf195664850f79fb00c445bd3.tar.xz |
ext: Upgrade PyBind11 to version 2.2.1
This upgrade is necessary for pybind to build with GCC 7.2.
We still need to add the patch for stl.h. MSC_FULL_VER change is no longer
needed.
See https://gem5-review.googlesource.com/c/public/gem5/+/2230
Change-Id: I806729217d022070583994c2dfcaa74476aef30f
Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-on: https://gem5-review.googlesource.com/5801
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'ext/pybind11/tests/test_eval.cpp')
-rw-r--r-- | ext/pybind11/tests/test_eval.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/ext/pybind11/tests/test_eval.cpp b/ext/pybind11/tests/test_eval.cpp index ed4c226fe..e09482191 100644 --- a/ext/pybind11/tests/test_eval.cpp +++ b/ext/pybind11/tests/test_eval.cpp @@ -11,7 +11,9 @@ #include <pybind11/eval.h> #include "pybind11_tests.h" -test_initializer eval([](py::module &m) { +TEST_SUBMODULE(eval_, m) { + // test_evals + auto global = py::dict(py::module::import("__main__").attr("__dict__")); m.def("test_eval_statements", [global]() { @@ -20,14 +22,24 @@ test_initializer eval([](py::module &m) { return 42; }); - auto result = py::eval<py::eval_statements>( - "print('Hello World!');\n" - "x = call_test();", + // Regular string literal + py::exec( + "message = 'Hello World!'\n" + "x = call_test()", global, local ); + + // Multi-line raw string literal + py::exec(R"( + if x == 42: + print(message) + else: + raise RuntimeError + )", global, local + ); auto x = local["x"].cast<int>(); - return result == py::none() && x == 42; + return x == 42; }); m.def("test_eval", [global]() { @@ -45,7 +57,7 @@ test_initializer eval([](py::module &m) { auto result = py::eval<py::eval_single_statement>("x = call_test()", py::dict(), local); auto x = local["x"].cast<int>(); - return result == py::none() && x == 42; + return result.is_none() && x == 42; }); m.def("test_eval_file", [global](py::str filename) { @@ -56,7 +68,7 @@ test_initializer eval([](py::module &m) { local["call_test2"] = py::cpp_function([&](int value) { val_out = value; }); auto result = py::eval_file(filename, global, local); - return val_out == 43 && result == py::none(); + return val_out == 43 && result.is_none(); }); m.def("test_eval_failure", []() { @@ -76,4 +88,4 @@ test_initializer eval([](py::module &m) { } return false; }); -}); +} |