From ed4505ca0538664c5db9bfc832b3f82bb54bdd43 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Wed, 21 Oct 2020 14:38:35 +0300 Subject: [PATCH] Make the generate_cpp17.py script python version agnostic and add smoke test that the script works (fixes #57) --- misc/generate_cpp17.py | 32 ++++++++++++++++---------------- test/Jamfile.v2 | 7 ++++++- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/misc/generate_cpp17.py b/misc/generate_cpp17.py index 4290d0c..ee94c32 100644 --- a/misc/generate_cpp17.py +++ b/misc/generate_cpp17.py @@ -79,33 +79,33 @@ constexpr void tie_as_tuple(T& /*val*/, size_t_) noexcept { indexes = " a" -print PROLOGUE +print(PROLOGUE) funcs_count = 100 if len(sys.argv) == 1 else int(sys.argv[1]) max_args_on_a_line = len(ascii_letters) -for i in xrange(1, funcs_count): +for i in range(1, funcs_count): if i % max_args_on_a_line == 0: indexes += ",\n " else: indexes += "," if i >= max_args_on_a_line: - indexes += ascii_letters[i / max_args_on_a_line - 1] + indexes += ascii_letters[i // max_args_on_a_line - 1] indexes += ascii_letters[i % max_args_on_a_line] - print "template " - print "constexpr auto tie_as_tuple(T& val, size_t_<" + str(i + 1) + ">) noexcept {" + print("template ") + print("constexpr auto tie_as_tuple(T& val, size_t_<" + str(i + 1) + ">) noexcept {") if i < max_args_on_a_line: - print " auto& [" + indexes.strip() + "] = val; // ====================> Boost.PFR: User-provided type is not a SimpleAggregate." - print " return ::boost::pfr::detail::make_tuple_of_references(" + indexes.strip() + ");" + print(" auto& [" + indexes.strip() + "] = val; // ====================> Boost.PFR: User-provided type is not a SimpleAggregate.") + print(" return ::boost::pfr::detail::make_tuple_of_references(" + indexes.strip() + ");") else: - print " auto& [" - print indexes - print " ] = val; // ====================> Boost.PFR: User-provided type is not a SimpleAggregate." - print "" - print " return ::boost::pfr::detail::make_tuple_of_references(" - print indexes - print " );" + print(" auto& [") + print(indexes) + print(" ] = val; // ====================> Boost.PFR: User-provided type is not a SimpleAggregate.") + print("") + print(" return ::boost::pfr::detail::make_tuple_of_references(") + print(indexes) + print(" );") - print "}\n" + print("}\n") -print EPILOGUE +print(EPILOGUE) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 68ecbb2..5e53d60 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -5,6 +5,7 @@ # http://www.boost.org/LICENSE_1_0.txt) # +import python ; import testing ; import ../../config/checks/config : requires ; @@ -16,7 +17,6 @@ project [ requires cxx14_constexpr ] ; - ########## BEGIN of helpers to detect Loophole trick support actions mp_simple_run_action @@ -125,3 +125,8 @@ for local source_file in [ glob ./compile-fail/*.cpp ] pfr_tests += [ compile-fail $(source_file) : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ; pfr_tests += [ compile-fail $(source_file) : $(CLASSIC_ENGINE) : $(target_name)_classic ] ; } + +if [ python.configured ] +{ + testing.make-test run-pyd : ../misc/generate_cpp17.py ; +}