[GIT] ppl/ppl(master): Added tests to the OCaml interface for new functions

Module: ppl/ppl Branch: master Commit: c9fd6d302f987aed452b463c418f9aab7a530460 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=c9fd6d302f987...
Author: Patricia Hill p.m.hill@leeds.ac.uk Date: Mon Apr 12 16:04:04 2010 +0100
Added tests to the OCaml interface for new functions wrap_assign(), drop_some_non_integer_points() and termination_test_*. Bug in termination_test_*. fixed and test showing these added to termination1.cc
---
.../OCaml/ppl_interface_generator_ocaml_cc_code.m4 | 3 +- .../OCaml/ppl_interface_generator_ocaml_ml_code.m4 | 3 +- .../ppl_interface_generator_ocaml_mli_code.m4 | 12 +++- .../ppl_interface_generator_ocaml_test_ml_code.m4 | 80 ++++++++++++++++++++ ...face_generator_prolog_generated_test_pl_code.m4 | 39 ++++++++++ src/termination.cc | 6 +- tests/Polyhedron/termination1.cc | 7 ++ 7 files changed, 145 insertions(+), 5 deletions(-)
diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4 index ad58ad4..8903dd4 100644 --- a/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4 +++ b/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4 @@ -1477,11 +1477,12 @@ ppl_@CLASS@_wrap_assign_native } CATCH_ALL
+extern "C" CAMLprim value ppl_@CLASS@_wrap_assign_bytecode(value * argv, int) { return ppl_@CLASS@_wrap_assign_native(argv[0], argv[1], argv[2], argv[3], - argv[4], argv[5], argv[6], argv[7]); + argv[4], argv[5], argv[6], argv[7]); }
') diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4 index 160121b..10241c8 100644 --- a/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4 +++ b/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4 @@ -638,11 +638,12 @@ external ppl_all_affine_quasi_ranking_functions_MS_@TOPOLOGY@@CLASS@_2: m4_define(`ppl_@CLASS@_wrap_assign_code', `dnl external ppl_@CLASS@_wrap_assign: @!CLASS@ + -> int list -> bounded_integer_type_width -> bounded_integer_type_representation -> bounded_integer_type_overflow -> constraint_system - -> int list -> int -> int -> unit + -> int -> int -> unit = "ppl_@CLASS@_wrap_assign_bytecode" "ppl_@CLASS@_wrap_assign_native"
diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4 index df7eb0e..bed44cf 100644 --- a/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4 +++ b/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4 @@ -503,6 +503,13 @@ val ppl_@CLASS@_approximate_@PARTITION@:
')
+m4_define(`ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@_code', +`dnl +val ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@: + @!CLASS@ -> bool + +') + m4_define(`ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@_2_code', `dnl val ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@_2: @@ -552,11 +559,14 @@ val ppl_all_affine_quasi_ranking_functions_MS_@TOPOLOGY@@CLASS@_2:
')
+m4_define(`ppl_@CLASS@_wrap_assign_code', +`dnl val ppl_@CLASS@_wrap_assign: @!CLASS@ + -> int list -> bounded_integer_type_width -> bounded_integer_type_representation -> bounded_integer_type_overflow -> constraint_system - -> int list -> int -> int -> unit + -> int -> int -> unit
') diff --git a/interfaces/OCaml/tests/ppl_interface_generator_ocaml_test_ml_code.m4 b/interfaces/OCaml/tests/ppl_interface_generator_ocaml_test_ml_code.m4 index 4c606b1..c5b3035 100644 --- a/interfaces/OCaml/tests/ppl_interface_generator_ocaml_test_ml_code.m4 +++ b/interfaces/OCaml/tests/ppl_interface_generator_ocaml_test_ml_code.m4 @@ -884,3 +884,83 @@ let out in (print_string_if_noisy out);; print_string_if_noisy "\n";; ') + +m4_define(`ppl_@CLASS@_drop_some_non_integer_points_code', +` +print_string_if_noisy "testing ppl_@CLASS@_drop_some_non_integer_points: ";; +let copy01 + = ppl_new_@TOPOLOGY@@CLASS@_from_@TOPOLOGY@@CLASS@(@!TOPOLOGY@@!CLASS@01);; +let u = ppl_@CLASS@_drop_some_non_integer_points copy01 Any_Complexity ;; +let out = if (u = () & ppl_@CLASS@_OK copy01) + then "success" else "failed" + in (print_string_if_noisy out);; +print_string_if_noisy "\n";; +') + +m4_define(`ppl_@CLASS@_drop_some_non_integer_points_2_code', +` +print_string_if_noisy "testing ppl_@CLASS@_drop_some_non_integer_points: ";; +let copy01 + = ppl_new_@TOPOLOGY@@CLASS@_from_@TOPOLOGY@@CLASS@(@!TOPOLOGY@@!CLASS@01);; +let dimensions_integer = [1];; +let u = ppl_@CLASS@_drop_some_non_integer_points_2 copy01 dimensions_integer Any_Complexity ;; +let out = if (u = () & ppl_@CLASS@_OK copy01) + then "success" else "failed" + in (print_string_if_noisy out);; +print_string_if_noisy "\n";; +') + +m4_define(`ppl_@CLASS@_wrap_assign_code', +` +print_string_if_noisy "testing ppl_@CLASS@_wrap_assign: ";; +let copy01 + = ppl_new_@TOPOLOGY@@CLASS@_from_@TOPOLOGY@@CLASS@(@!TOPOLOGY@@!CLASS@01);; +let dimensions_integer = [1];; +let u = ppl_@CLASS@_wrap_assign copy01 [] Bits_8 Unsigned Overflow_Wraps + [] 0 1;; +let out = if (u = () & ppl_@CLASS@_OK copy01) + then "success" else "failed" + in (print_string_if_noisy out);; +print_string_if_noisy "\n";; +') + +m4_define(`ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@_code', +` +print_string_if_noisy + "testing ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@: ";; +let copy01 + = ppl_new_@TOPOLOGY@@CLASS@_from_@TOPOLOGY@@CLASS@(@!TOPOLOGY@@!CLASS@01);; +let univ + = ppl_new_@TOPOLOGY@@CLASS@_from_space_dimension 2 Universe;; +let u = ppl_@CLASS@_concatenate_assign copy01 @!TOPOLOGY@@!CLASS@01;; +let result1 = ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@ univ;; +let result2 + = ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@ copy01;; +let out = if (not result1 & not result2 & ppl_@CLASS@_OK copy01) + then "success" else "failed" + in (print_string_if_noisy out);; +print_string_if_noisy "\n";; +') + +m4_define(`ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@_2_code', +` +print_string_if_noisy + "testing ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@_2: ";; +let copy01 + = ppl_new_@TOPOLOGY@@CLASS@_from_@TOPOLOGY@@CLASS@(@!TOPOLOGY@@!CLASS@01);; +let copy02 + = ppl_new_@TOPOLOGY@@CLASS@_from_@TOPOLOGY@@CLASS@(@!TOPOLOGY@@!CLASS@02);; +let u = ppl_@CLASS@_concatenate_assign copy02 @!TOPOLOGY@@!CLASS@02;; +let result1 + = ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@_2 copy01 copy02;; +let univ01 + = ppl_new_@TOPOLOGY@@CLASS@_from_space_dimension 2 Universe;; +let univ02 + = ppl_new_@TOPOLOGY@@CLASS@_from_space_dimension 4 Universe;; +let result2 + = ppl_termination_test_@TERMINATION_ID@_@TOPOLOGY@@CLASS@_2 univ01 univ02;; +let out = if (not result1 & not result2 & ppl_@CLASS@_OK copy01) + then "success" else "failed" + in (print_string_if_noisy out);; +print_string_if_noisy "\n";; +') diff --git a/interfaces/Prolog/tests/ppl_interface_generator_prolog_generated_test_pl_code.m4 b/interfaces/Prolog/tests/ppl_interface_generator_prolog_generated_test_pl_code.m4 index 4ed6891..10764e6 100644 --- a/interfaces/Prolog/tests/ppl_interface_generator_prolog_generated_test_pl_code.m4 +++ b/interfaces/Prolog/tests/ppl_interface_generator_prolog_generated_test_pl_code.m4 @@ -1731,4 +1731,43 @@ ppl_@CLASS@_wrap_assign_8_test :-
')
+m4_define(`ppl_@CLASS@_drop_some_non_integer_points_code', +` +ppl_@CLASS@_drop_some_non_integer_points_2_test :- + ( + choose_test(TEST_DATA, Dim), + ( + ppl_@TOPOLOGY@@CLASS@_build_test_object(TEST_DATA, PS, Dim), + ppl_new_@TOPOLOGY@@CLASS@_from_@TOPOLOGY@@CLASS@(PS, PS_Copy), + ppl_@CLASS@_drop_some_non_integer_points(PS, any_complexity), + ppl_@CLASS@_equals_@CLASS@(PS, PS_Copy), + ppl_@CLASS@_OK(PS), + ppl_delete_@CLASS@(PS), + ppl_delete_@CLASS@(PS_Copy) + -> + fail ; true) + ). + +') + +m4_define(`ppl_@CLASS@_drop_some_non_integer_points_code', +` +ppl_@CLASS@_drop_some_non_integer_points_2_3_test :- + ( + choose_test(TEST_DATA, Dim), + ( + ppl_@TOPOLOGY@@CLASS@_build_test_object(TEST_DATA, PS, Dim), + ppl_new_@TOPOLOGY@@CLASS@_from_@TOPOLOGY@@CLASS@(PS, PS_Copy), + make_vars(Dim, Var_List), + ppl_@CLASS@_drop_some_non_integer_points_2(PS, Var_List, any_complexity), + ppl_@CLASS@_equals_@CLASS@(PS, PS_Copy), + ppl_@CLASS@_OK(PS), + ppl_delete_@CLASS@(PS), + ppl_delete_@CLASS@(PS_Copy) + -> + fail ; true) + ). + +') + dnl ppl_@CLASS@_@NARROWING@_narrowing_assign/2, diff --git a/src/termination.cc b/src/termination.cc index 3ba1213..e2749ab 100644 --- a/src/termination.cc +++ b/src/termination.cc @@ -362,7 +362,8 @@ fill_constraint_system_PR(const Constraint_System& cs_before, const dimension_type m = r + s;
// Make sure linear expressions are not reallocated multiple times. - le_out = 0 * Variable(m + r - 1); + if (m > 0) + le_out = 0 * Variable(m + r - 1); std::vector<Linear_Expression> les_eq(2*n, le_out);
dimension_type row_index = 0; @@ -436,7 +437,8 @@ fill_constraint_system_PR_original(const Constraint_System& cs, const dimension_type m = distance(cs.begin(), cs.end());
// Make sure linear expressions are not reallocated multiple times. - le_out = 0 * Variable(2*m - 1); + if (m > 0) + le_out = 0 * Variable(2*m - 1); std::vector<Linear_Expression> les_eq(3*n, le_out);
dimension_type row_index = 0; diff --git a/tests/Polyhedron/termination1.cc b/tests/Polyhedron/termination1.cc index 0d86c03..0bbe66e 100644 --- a/tests/Polyhedron/termination1.cc +++ b/tests/Polyhedron/termination1.cc @@ -491,6 +491,12 @@ test20() { return known_result == witness; }
+bool +test21() { + C_Polyhedron ph(2); + return !termination_test_PR(ph); +} + } // namespace
BEGIN_MAIN @@ -514,4 +520,5 @@ BEGIN_MAIN DO_TEST(test18); DO_TEST(test19); DO_TEST(test20); + DO_TEST(test21); END_MAIN
participants (1)
-
Patricia Hill