From 5a0a4534b404ffaf917204a3cdb1b0fc9bcbc3b4 Mon Sep 17 00:00:00 2001 From: Andrew Wells Date: Thu, 19 Mar 2026 18:20:04 +0000 Subject: [PATCH 1/3] Add more integration tests for PyAnalyzeLaurel --- .../test_boolean_logic.expected | 56 ++++++++++++++++++ .../test_class_methods.expected | 38 ++++++++++++ .../test_class_with_methods.expected | 36 ++++++++++++ .../test_default_params.expected | 39 +++++++++++++ .../test_dict_operations.expected | 58 +++++++++++++++++++ .../expected_laurel/test_for_loop.expected | 38 ++++++++++++ .../expected_laurel/test_if_elif.expected | 40 +++++++++++++ .../test_module_level.expected | 43 ++++++++++++++ .../test_multi_function.expected | 40 +++++++++++++ .../test_multiple_except.expected | 34 +++++++++++ .../test_nested_calls.expected | 35 +++++++++++ .../test_return_types.expected | 37 ++++++++++++ .../test_variable_reassign.expected | 45 ++++++++++++++ .../expected_laurel/test_while_loop.expected | 47 +++++++++++++++ .../Python/tests/test_boolean_logic.py | 40 +++++++++++++ .../Python/tests/test_class_methods.py | 33 +++++++++++ .../Python/tests/test_class_with_methods.py | 31 ++++++++++ .../Python/tests/test_default_params.py | 27 +++++++++ .../Python/tests/test_dict_operations.py | 27 +++++++++ .../Languages/Python/tests/test_for_loop.py | 26 +++++++++ .../Languages/Python/tests/test_if_elif.py | 25 ++++++++ .../Python/tests/test_module_level.py | 15 +++++ .../Python/tests/test_multi_function.py | 29 ++++++++++ .../Python/tests/test_multiple_except.py | 32 ++++++++++ .../Python/tests/test_nested_calls.py | 21 +++++++ .../Python/tests/test_return_types.py | 32 ++++++++++ .../Python/tests/test_variable_reassign.py | 35 +++++++++++ .../Languages/Python/tests/test_while_loop.py | 28 +++++++++ 28 files changed, 987 insertions(+) create mode 100644 StrataTest/Languages/Python/expected_laurel/test_boolean_logic.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_class_methods.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_class_with_methods.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_default_params.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_dict_operations.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_for_loop.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_if_elif.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_module_level.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_multi_function.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_multiple_except.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_nested_calls.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_return_types.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_variable_reassign.expected create mode 100644 StrataTest/Languages/Python/expected_laurel/test_while_loop.expected create mode 100644 StrataTest/Languages/Python/tests/test_boolean_logic.py create mode 100644 StrataTest/Languages/Python/tests/test_class_methods.py create mode 100644 StrataTest/Languages/Python/tests/test_class_with_methods.py create mode 100644 StrataTest/Languages/Python/tests/test_default_params.py create mode 100644 StrataTest/Languages/Python/tests/test_dict_operations.py create mode 100644 StrataTest/Languages/Python/tests/test_for_loop.py create mode 100644 StrataTest/Languages/Python/tests/test_if_elif.py create mode 100644 StrataTest/Languages/Python/tests/test_module_level.py create mode 100644 StrataTest/Languages/Python/tests/test_multi_function.py create mode 100644 StrataTest/Languages/Python/tests/test_multiple_except.py create mode 100644 StrataTest/Languages/Python/tests/test_nested_calls.py create mode 100644 StrataTest/Languages/Python/tests/test_return_types.py create mode 100644 StrataTest/Languages/Python/tests/test_variable_reassign.py create mode 100644 StrataTest/Languages/Python/tests/test_while_loop.py diff --git a/StrataTest/Languages/Python/expected_laurel/test_boolean_logic.expected b/StrataTest/Languages/Python/expected_laurel/test_boolean_logic.expected new file mode 100644 index 000000000..3668b3612 --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_boolean_logic.expected @@ -0,0 +1,56 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(73)_calls_PAnd_0: ✅ pass (at line 5, col 4) +assert_assert(73)_calls_Any_to_bool_1: ✅ pass (at line 5, col 4) +assert(73): ✅ pass (at line 5, col 4) +assert_assert(124)_calls_PAnd_0: ✅ pass (at line 6, col 4) +assert_assert(124)_calls_Any_to_bool_1: ✅ pass (at line 6, col 4) +assert(124): ✅ pass (at line 6, col 4) +assert_assert(201)_calls_POr_0: ✅ pass (at line 9, col 4) +assert_assert(201)_calls_Any_to_bool_1: ✅ pass (at line 9, col 4) +assert(201): ✅ pass (at line 9, col 4) +assert_assert(251)_calls_POr_0: ✅ pass (at line 10, col 4) +assert_assert(251)_calls_Any_to_bool_1: ✅ pass (at line 10, col 4) +assert(251): ✅ pass (at line 10, col 4) +assert_assert(320)_calls_Any_to_bool_0: ✅ pass (at line 13, col 4) +assert(320): ✅ pass (at line 13, col 4) +assert_assert(365)_calls_Any_to_bool_0: ✅ pass (at line 14, col 4) +assert(365): ✅ pass (at line 14, col 4) +ite_cond_calls_PAnd_0: ✅ pass +ite_cond_calls_Any_to_bool_1: ✅ pass +assert_assert(570)_calls_Any_to_bool_0: ✅ pass (at line 25, col 4) +assert(570): ✅ pass (at line 25, col 4) +ite_cond_calls_POr_0: ✅ pass +ite_cond_calls_Any_to_bool_1: ✅ pass +assert_assert(700)_calls_Any_to_bool_0: ✅ pass (at line 31, col 4) +assert(700): ✅ pass (at line 31, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass +assert_assert(825)_calls_Any_to_bool_0: ✅ pass (at line 37, col 4) +assert(825): ✅ pass (at line 37, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass diff --git a/StrataTest/Languages/Python/expected_laurel/test_class_methods.expected b/StrataTest/Languages/Python/expected_laurel/test_class_methods.expected new file mode 100644 index 000000000..4d2511919 --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_class_methods.expected @@ -0,0 +1,38 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(445)_calls_Any_to_bool_0: ✅ pass (at line 21, col 4) +assert(445): ❓ unknown (at line 21, col 4) +assert_assert(539)_calls_Any_to_bool_0: ✅ pass (at line 24, col 4) +assert(539): ❓ unknown (at line 24, col 4) +assert_assert(654)_calls_Any_to_bool_0: ✅ pass (at line 28, col 4) +assert(654): ❓ unknown (at line 28, col 4) +(Origin_test_helper_procedure_Requires)req_name_is_foo: ✅ pass (in prelude file) +(Origin_test_helper_procedure_Requires)req_opt_name_none_or_str: ✅ pass (in prelude file) +(Origin_test_helper_procedure_Requires)req_opt_name_none_or_bar: ✅ pass (in prelude file) +ite_cond_calls_Any_to_bool_0: ✅ pass diff --git a/StrataTest/Languages/Python/expected_laurel/test_class_with_methods.expected b/StrataTest/Languages/Python/expected_laurel/test_class_with_methods.expected new file mode 100644 index 000000000..b67246932 --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_class_with_methods.expected @@ -0,0 +1,36 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(459)_calls_Any_to_bool_0: ✅ pass (at line 23, col 4) +assert(459): ❓ unknown (at line 23, col 4) +assert_assert(544)_calls_Any_to_bool_0: ✅ pass (at line 26, col 4) +assert(544): ❓ unknown (at line 26, col 4) +(Origin_test_helper_procedure_Requires)req_name_is_foo: ✅ pass (in prelude file) +(Origin_test_helper_procedure_Requires)req_opt_name_none_or_str: ✅ pass (in prelude file) +(Origin_test_helper_procedure_Requires)req_opt_name_none_or_bar: ✅ pass (in prelude file) +ite_cond_calls_Any_to_bool_0: ✅ pass diff --git a/StrataTest/Languages/Python/expected_laurel/test_default_params.expected b/StrataTest/Languages/Python/expected_laurel/test_default_params.expected new file mode 100644 index 000000000..a3d4163de --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_default_params.expected @@ -0,0 +1,39 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +loop_guard_calls_Any_to_bool_0: ❓ unknown +loop_guard_end_calls_Any_to_bool_0: ✅ pass +assert_assert(325)_calls_Any_to_bool_0: ✅ pass (at line 15, col 4) +assert(325): ❓ unknown (at line 15, col 4) +assert_assert(421)_calls_Any_to_bool_0: ✅ pass (at line 18, col 4) +assert(421): ❓ unknown (at line 18, col 4) +assert_assert(501)_calls_Any_to_bool_0: ✅ pass (at line 21, col 4) +assert(501): ❓ unknown (at line 21, col 4) +assert_assert(571)_calls_Any_to_bool_0: ✅ pass (at line 24, col 4) +assert(571): ❓ unknown (at line 24, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass diff --git a/StrataTest/Languages/Python/expected_laurel/test_dict_operations.expected b/StrataTest/Languages/Python/expected_laurel/test_dict_operations.expected new file mode 100644 index 000000000..ce06d8d10 --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_dict_operations.expected @@ -0,0 +1,58 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(81)_calls_Any_get_0: ✅ pass (at line 7, col 0) +assert_assert(81)_calls_Any_to_bool_1: ✅ pass (at line 7, col 0) +assert(81): ✅ pass (at line 7, col 0) +assert_assert(118)_calls_Any_get_0: ✅ pass (at line 8, col 0) +assert_assert(118)_calls_Any_to_bool_1: ✅ pass (at line 8, col 0) +assert(118): ✅ pass (at line 8, col 0) +assert_assert(172)_calls_Any_get_0: ✅ pass (at line 11, col 0) +assert_assert(172)_calls_Any_to_bool_1: ✅ pass (at line 11, col 0) +assert(172): ✅ pass (at line 11, col 0) +assert_assert(204)_calls_PIn_0: ✅ pass (at line 13, col 0) +assert_assert(204)_calls_Any_to_bool_1: ✅ pass (at line 13, col 0) +assert(204): ✅ pass (at line 13, col 0) +assert_assert(228)_calls_PNotIn_0: ✅ pass (at line 14, col 0) +assert_assert(228)_calls_Any_to_bool_1: ✅ pass (at line 14, col 0) +assert(228): ✅ pass (at line 14, col 0) +assert_assert(403)_calls_Any_get_0: ✅ pass (at line 23, col 0) +assert_assert(403)_calls_Any_get_1: ✅ pass (at line 23, col 0) +assert_assert(403)_calls_Any_get_2: ✅ pass (at line 23, col 0) +assert_assert(403)_calls_Any_to_bool_3: ✅ pass (at line 23, col 0) +assert(403): ✅ pass (at line 23, col 0) +assert_assert(457)_calls_Any_get_0: ✅ pass (at line 24, col 0) +assert_assert(457)_calls_Any_get_1: ✅ pass (at line 24, col 0) +assert_assert(457)_calls_Any_get_2: ✅ pass (at line 24, col 0) +assert_assert(457)_calls_Any_to_bool_3: ✅ pass (at line 24, col 0) +assert(457): ✅ pass (at line 24, col 0) +assert_assert(557)_calls_Any_get_0: ✅ pass (at line 27, col 0) +assert_assert(557)_calls_Any_get_1: ✅ pass (at line 27, col 0) +assert_assert(557)_calls_Any_get_2: ✅ pass (at line 27, col 0) +assert_assert(557)_calls_Any_to_bool_3: ✅ pass (at line 27, col 0) +assert(557): ✅ pass (at line 27, col 0) diff --git a/StrataTest/Languages/Python/expected_laurel/test_for_loop.expected b/StrataTest/Languages/Python/expected_laurel/test_for_loop.expected new file mode 100644 index 000000000..0a1fbdeab --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_for_loop.expected @@ -0,0 +1,38 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(129)_calls_Any_to_bool_0: ✅ pass (at line 6, col 4) +assert(129): ❓ unknown (at line 6, col 4) +ite_cond_calls_Any_to_bool_0: ❓ unknown +assert_assert(361)_calls_Any_to_bool_0: ✅ pass (at line 15, col 4) +assert(361): ❓ unknown (at line 15, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass +assert_assert(611)_calls_Any_to_bool_0: ✅ pass (at line 25, col 4) +assert(611): ✅ pass (at line 25, col 4) +assert_assert(611)_calls_Any_to_bool_0: ✅ pass (at line 25, col 4) +assert(611): ❓ unknown (at line 25, col 4) diff --git a/StrataTest/Languages/Python/expected_laurel/test_if_elif.expected b/StrataTest/Languages/Python/expected_laurel/test_if_elif.expected new file mode 100644 index 000000000..97e98c4b7 --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_if_elif.expected @@ -0,0 +1,40 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +ite_cond_calls_Any_to_bool_0: ❓ unknown +ite_cond_calls_Any_to_bool_0: ✅ pass +ite_cond_calls_Any_to_bool_0: ❓ unknown +assert_assert(225)_calls_Any_to_bool_0: ✅ pass (at line 13, col 4) +assert(225): ❓ unknown (at line 13, col 4) +assert_assert(302)_calls_Any_to_bool_0: ✅ pass (at line 16, col 4) +assert(302): ❓ unknown (at line 16, col 4) +assert_assert(371)_calls_Any_to_bool_0: ✅ pass (at line 19, col 4) +assert(371): ❓ unknown (at line 19, col 4) +assert_assert(444)_calls_Any_to_bool_0: ✅ pass (at line 22, col 4) +assert(444): ❓ unknown (at line 22, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass diff --git a/StrataTest/Languages/Python/expected_laurel/test_module_level.expected b/StrataTest/Languages/Python/expected_laurel/test_module_level.expected new file mode 100644 index 000000000..772f2b04e --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_module_level.expected @@ -0,0 +1,43 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(115)_calls_Any_get_0: ✅ pass (at line 9, col 0) +assert_assert(115)_calls_Any_to_bool_1: ✅ pass (at line 9, col 0) +assert(115): ✅ pass (at line 9, col 0) +assert_assert(145)_calls_Any_get_0: ✅ pass (at line 10, col 0) +assert_assert(145)_calls_Any_to_bool_1: ✅ pass (at line 10, col 0) +assert(145): ✅ pass (at line 10, col 0) +assert_assert(201)_calls_Any_get_0: ✅ pass (at line 13, col 0) +assert_assert(201)_calls_Any_to_bool_1: ✅ pass (at line 13, col 0) +assert(201): ✅ pass (at line 13, col 0) +assert_assert(236)_calls_PIn_0: ✅ pass (at line 14, col 0) +assert_assert(236)_calls_Any_to_bool_1: ✅ pass (at line 14, col 0) +assert(236): ✅ pass (at line 14, col 0) +assert_assert(258)_calls_PNotIn_0: ✅ pass (at line 15, col 0) +assert_assert(258)_calls_Any_to_bool_1: ✅ pass (at line 15, col 0) +assert(258): ✅ pass (at line 15, col 0) diff --git a/StrataTest/Languages/Python/expected_laurel/test_multi_function.expected b/StrataTest/Languages/Python/expected_laurel/test_multi_function.expected new file mode 100644 index 000000000..a5d051efe --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_multi_function.expected @@ -0,0 +1,40 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +ite_cond_calls_PNotIn_0: ❓ unknown +ite_cond_calls_Any_to_bool_1: ✅ pass +ite_cond_calls_PNotIn_0: ❓ unknown +ite_cond_calls_Any_to_bool_1: ✅ pass +ite_cond_calls_Any_to_bool_0: ❓ unknown +set_LaurelResult_calls_Any_get_0: ❓ unknown +assert_assert(651)_calls_Any_to_bool_0: ✅ pass (at line 24, col 4) +assert(651): ❓ unknown (at line 24, col 4) +(Origin_test_helper_procedure_Requires)req_name_is_foo: ✅ pass (in prelude file) +(Origin_test_helper_procedure_Requires)req_opt_name_none_or_str: ✅ pass (in prelude file) +(Origin_test_helper_procedure_Requires)req_opt_name_none_or_bar: ✅ pass (in prelude file) +ite_cond_calls_Any_to_bool_0: ✅ pass diff --git a/StrataTest/Languages/Python/expected_laurel/test_multiple_except.expected b/StrataTest/Languages/Python/expected_laurel/test_multiple_except.expected new file mode 100644 index 000000000..8e13a2d55 --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_multiple_except.expected @@ -0,0 +1,34 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(170)_calls_Any_to_bool_0: ✅ pass (at line 8, col 4) +assert(170): ❓ unknown (at line 8, col 4) +assert_assert(471)_calls_Any_to_bool_0: ✅ pass (at line 21, col 4) +assert(471): ❓ unknown (at line 21, col 4) +assert_assert(693)_calls_Any_to_bool_0: ✅ pass (at line 31, col 4) +assert(693): ✅ pass (at line 31, col 4) diff --git a/StrataTest/Languages/Python/expected_laurel/test_nested_calls.expected b/StrataTest/Languages/Python/expected_laurel/test_nested_calls.expected new file mode 100644 index 000000000..aea998fc4 --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_nested_calls.expected @@ -0,0 +1,35 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(153)_calls_Any_to_bool_0: ✅ pass (at line 10, col 4) +assert(153): ❓ unknown (at line 10, col 4) +assert_assert(254)_calls_Any_to_bool_0: ✅ pass (at line 14, col 4) +assert(254): ❓ unknown (at line 14, col 4) +assert_assert(356)_calls_Any_to_bool_0: ✅ pass (at line 18, col 4) +assert(356): ❓ unknown (at line 18, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass diff --git a/StrataTest/Languages/Python/expected_laurel/test_return_types.expected b/StrataTest/Languages/Python/expected_laurel/test_return_types.expected new file mode 100644 index 000000000..7a26c86ce --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_return_types.expected @@ -0,0 +1,37 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(304)_calls_Any_to_bool_0: ✅ pass (at line 20, col 4) +assert(304): ❓ unknown (at line 20, col 4) +assert_assert(387)_calls_Any_to_bool_0: ✅ pass (at line 23, col 4) +assert(387): ❓ unknown (at line 23, col 4) +assert_assert(474)_calls_Any_to_bool_0: ✅ pass (at line 26, col 4) +assert(474): ❓ unknown (at line 26, col 4) +assert_assert(558)_calls_Any_to_bool_0: ✅ pass (at line 29, col 4) +assert(558): ❓ unknown (at line 29, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass diff --git a/StrataTest/Languages/Python/expected_laurel/test_variable_reassign.expected b/StrataTest/Languages/Python/expected_laurel/test_variable_reassign.expected new file mode 100644 index 000000000..16826b760 --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_variable_reassign.expected @@ -0,0 +1,45 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +assert_assert(59)_calls_Any_to_bool_0: ✅ pass (at line 4, col 4) +assert(59): ✅ pass (at line 4, col 4) +assert_assert(104)_calls_Any_to_bool_0: ✅ pass (at line 6, col 4) +assert(104): ✅ pass (at line 6, col 4) +assert_assert(158)_calls_Any_to_bool_0: ✅ pass (at line 8, col 4) +assert(158): ✅ pass (at line 8, col 4) +loop_guard_calls_Any_to_bool_0: ✅ pass +loop_guard_end_calls_Any_to_bool_0: ✅ pass +assert_assert(318)_calls_Any_to_bool_0: ✅ pass (at line 16, col 4) +assert(318): ❓ unknown (at line 16, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass +assert_assert(496)_calls_Any_to_bool_0: ✅ pass (at line 25, col 4) +assert(496): ✅ pass (at line 25, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass +assert_assert(612)_calls_Any_to_bool_0: ✅ pass (at line 32, col 4) +assert(612): ✅ pass (at line 32, col 4) +ite_cond_calls_Any_to_bool_0: ✅ pass diff --git a/StrataTest/Languages/Python/expected_laurel/test_while_loop.expected b/StrataTest/Languages/Python/expected_laurel/test_while_loop.expected new file mode 100644 index 000000000..322cda6b1 --- /dev/null +++ b/StrataTest/Languages/Python/expected_laurel/test_while_loop.expected @@ -0,0 +1,47 @@ + +==== Verification Results ==== +List_get_body_calls_List_get_0: ✅ pass +List_take_body_calls_List_take_0: ✅ pass +List_drop_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_drop_0: ✅ pass +List_slice_body_calls_List_take_1: ✅ pass +List_set_body_calls_List_set_0: ✅ pass +DictStrAny_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_DictStrAny_get_0: ✅ pass +Any_get_body_calls_List_get_1: ✅ pass +Any_get!_body_calls_DictStrAny_get_0: ✅ pass +Any_get!_body_calls_List_get_1: ✅ pass +Any_set_body_calls_List_set_0: ✅ pass +Any_set!_body_calls_List_set_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_0: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_1: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_2: ✅ pass +PFloorDiv_body_calls_Int.SafeDiv_3: ✅ pass +PAnd_body_calls_Any_to_bool_0: ✅ pass +POr_body_calls_Any_to_bool_0: ✅ pass +ret_type: ✅ pass (in prelude file) +ret_type: ✅ pass (in prelude file) +ret_pos: ✅ pass (in prelude file) +assert_name_is_foo: ✅ pass (in prelude file) +assert_opt_name_none_or_str: ✅ pass (in prelude file) +assert_opt_name_none_or_bar: ✅ pass (in prelude file) +ensures_maybe_except_none: ✅ pass (in prelude file) +loop_guard_calls_Any_to_bool_0: ✅ pass +loop_guard_end_calls_Any_to_bool_0: ✅ pass +assert_assert(134)_calls_Any_to_bool_0: ✅ pass (at line 7, col 4) +assert(134): ❓ unknown (at line 7, col 4) +loop_guard_calls_Any_to_bool_0: ✅ pass +ite_cond_calls_Any_to_bool_0: ✅ pass +assert_assert(344)_calls_Any_to_bool_0: ✅ pass (at line 16, col 4) +assert(344): ✅ pass (at line 16, col 4) +loop_guard_end_calls_Any_to_bool_0: ✅ pass +assert_assert(344)_calls_Any_to_bool_0: ✅ pass (at line 16, col 4) +assert(344): ✅ pass (at line 16, col 4) +loop_guard_calls_Any_to_bool_0: ✅ pass +ite_cond_calls_Any_to_bool_0: ✅ pass +loop_guard_end_calls_Any_to_bool_0: ✅ pass +assert_assert(589)_calls_Any_to_bool_0: ✅ pass (at line 27, col 4) +assert(589): ❓ unknown (at line 27, col 4) +loop_guard_end_calls_Any_to_bool_0: ✅ pass +assert_assert(589)_calls_Any_to_bool_0: ✅ pass (at line 27, col 4) +assert(589): ❓ unknown (at line 27, col 4) diff --git a/StrataTest/Languages/Python/tests/test_boolean_logic.py b/StrataTest/Languages/Python/tests/test_boolean_logic.py new file mode 100644 index 000000000..87eafb5b0 --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_boolean_logic.py @@ -0,0 +1,40 @@ +def main(): + # Boolean and + a: bool = True + b: bool = False + assert a and a, "True and True should be True" + assert not (a and b), "True and False should be False" + + # Boolean or + assert a or b, "True or False should be True" + assert not (b or b), "False or False should be False" + + # Not + assert not b, "not False should be True" + assert not not a, "not not True should be True" + + # Combined conditions + c: int = 10 + d: int = 20 + result: int = 0 + + if c > 5 and d > 15: + result = 1 + else: + result = 0 + assert result == 1, "combined and condition failed" + + if c > 15 or d > 15: + result = 2 + else: + result = 0 + assert result == 2, "combined or condition failed" + + if not (c > 20): + result = 3 + else: + result = 0 + assert result == 3, "not condition failed" + +if __name__ == "__main__": + main() diff --git a/StrataTest/Languages/Python/tests/test_class_methods.py b/StrataTest/Languages/Python/tests/test_class_methods.py new file mode 100644 index 000000000..3fc24f4ec --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_class_methods.py @@ -0,0 +1,33 @@ +import test_helper + +class Account: + def __init__(self, owner: str, balance: int): + self.owner: str = owner + self.balance: int = balance + + def get_owner(self) -> str: + return self.owner + + def get_balance(self) -> int: + return self.balance + + def set_balance(self, amount: int) -> None: + self.balance = amount + +def main(): + acc: Account = Account("Alice", 100) + + name: str = acc.get_owner() + assert name == "Alice", "get_owner should return Alice" + + bal: int = acc.get_balance() + assert bal == 100, "get_balance should return 100" + + acc.set_balance(200) + bal2: int = acc.get_balance() + assert bal2 == 200, "set_balance should update balance" + + test_helper.procedure("foo") + +if __name__ == "__main__": + main() diff --git a/StrataTest/Languages/Python/tests/test_class_with_methods.py b/StrataTest/Languages/Python/tests/test_class_with_methods.py new file mode 100644 index 000000000..65d6cdfe7 --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_class_with_methods.py @@ -0,0 +1,31 @@ +import test_helper + +class DataStore: + def __init__(self, name: str): + self.name: str = name + self.count: int = 0 + + def add(self, amount: int) -> None: + self.count = self.count + amount + + def get_count(self) -> int: + return self.count + + def get_name(self) -> str: + return self.name + +def main(): + store: DataStore = DataStore("mystore") + store.add(10) + store.add(20) + + val: int = store.get_count() + assert val == 30, "get_count should return 30" + + name: str = store.get_name() + assert name == "mystore", "get_name should return mystore" + + test_helper.procedure("foo") + +if __name__ == "__main__": + main() diff --git a/StrataTest/Languages/Python/tests/test_default_params.py b/StrataTest/Languages/Python/tests/test_default_params.py new file mode 100644 index 000000000..ce4f89a7b --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_default_params.py @@ -0,0 +1,27 @@ +def greet(name: str, greeting: str = "Hello") -> str: + result: str = greeting + " " + name + return result + +def power(base: int, exp: int = 2) -> int: + result: int = 1 + i: int = 0 + while i < exp: + result = result * base + i = i + 1 + return result + +def main(): + msg1: str = greet("Alice") + assert msg1 == "Hello Alice", "default greeting failed" + + msg2: str = greet("Bob", "Hi") + assert msg2 == "Hi Bob", "explicit greeting failed" + + sq: int = power(3) + assert sq == 9, "default power failed" + + cu: int = power(2, 3) + assert cu == 8, "explicit power failed" + +if __name__ == "__main__": + main() diff --git a/StrataTest/Languages/Python/tests/test_dict_operations.py b/StrataTest/Languages/Python/tests/test_dict_operations.py new file mode 100644 index 000000000..414804e12 --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_dict_operations.py @@ -0,0 +1,27 @@ +config: dict = { + "host": "localhost", + "port": 8080, + "debug": True +} + +assert config["host"] == "localhost" +assert config["port"] == 8080 + +config["timeout"] = 30 +assert config["timeout"] == 30 + +assert "host" in config +assert "missing" not in config + +nested: dict = { + "database": { + "primary": {"host": "db1", "port": 5432}, + "replica": {"host": "db2", "port": 5433} + } +} + +assert nested["database"]["primary"]["host"] == "db1" +assert nested["database"]["replica"]["port"] == 5433 + +nested["database"]["primary"]["host"] = "db3" +assert nested["database"]["primary"]["host"] == "db3" diff --git a/StrataTest/Languages/Python/tests/test_for_loop.py b/StrataTest/Languages/Python/tests/test_for_loop.py new file mode 100644 index 000000000..730830430 --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_for_loop.py @@ -0,0 +1,26 @@ +def test_for_sum() -> Any: + items: Any = [1, 2, 3, 4, 5] + total: int = 0 + for x in items: + total = total + x + assert total == 15, "sum of list should be 15" + return total + +def test_for_with_conditional() -> Any: + items: Any = [1, 2, 3, 4, 5, 6] + count: int = 0 + for x in items: + if x > 3: + count = count + 1 + assert count == 3, "should count 3 items greater than 3" + return count + +def test_for_with_break() -> Any: + items: Any = [10, 20, 30, 40, 50] + found: int = 0 + for x in items: + if x == 30: + found = 1 + break + assert found == 1, "should have found 30" + return found diff --git a/StrataTest/Languages/Python/tests/test_if_elif.py b/StrataTest/Languages/Python/tests/test_if_elif.py new file mode 100644 index 000000000..6b206530b --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_if_elif.py @@ -0,0 +1,25 @@ +def classify(x: int) -> str: + if x < 0: + return "negative" + elif x == 0: + return "zero" + elif x < 10: + return "small" + else: + return "large" + +def main(): + r1: str = classify(-5) + assert r1 == "negative", "should be negative" + + r2: str = classify(0) + assert r2 == "zero", "should be zero" + + r3: str = classify(7) + assert r3 == "small", "should be small" + + r4: str = classify(100) + assert r4 == "large", "should be large" + +if __name__ == "__main__": + main() diff --git a/StrataTest/Languages/Python/tests/test_module_level.py b/StrataTest/Languages/Python/tests/test_module_level.py new file mode 100644 index 000000000..d24a2c6e5 --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_module_level.py @@ -0,0 +1,15 @@ +from typing import Dict, Any + +data: Dict[str, Any] = { + "name": "test", + "version": 1, + "active": True +} + +assert data["name"] == "test" +assert data["version"] == 1 + +data["status"] = "running" +assert data["status"] == "running" +assert "name" in data +assert "missing" not in data diff --git a/StrataTest/Languages/Python/tests/test_multi_function.py b/StrataTest/Languages/Python/tests/test_multi_function.py new file mode 100644 index 000000000..edb512748 --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_multi_function.py @@ -0,0 +1,29 @@ +import test_helper +from typing import Dict, Any + +def create_config(name: str, value: int) -> Dict[str, Any]: + config: Dict[str, Any] = {"name": name, "value": value, "active": True} + return config + +def validate_config(config: Dict[str, Any]) -> bool: + if "name" not in config: + return False + if "value" not in config: + return False + return True + +def process_config(name: str, value: int) -> Any: + config: Dict[str, Any] = create_config(name, value) + valid: bool = validate_config(config) + if not valid: + return None + return config["value"] + +def main(): + result: Any = process_config("test", 100) + assert result == 100, "process_config should return value" + + test_helper.procedure("foo") + +if __name__ == "__main__": + main() diff --git a/StrataTest/Languages/Python/tests/test_multiple_except.py b/StrataTest/Languages/Python/tests/test_multiple_except.py new file mode 100644 index 000000000..1a00ce7fe --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_multiple_except.py @@ -0,0 +1,32 @@ +def test_except_with_as() -> Any: + result: Any = 0 + try: + raise Exception("test error") + result = 1 + except Exception as e: + result = 2 + assert result == 2, "except as should have caught exception" + return result + +def test_bare_raise() -> Any: + result: Any = 0 + try: + try: + raise Exception("inner") + except Exception: + result = 1 + raise + except Exception: + result = 2 + assert result == 2, "bare raise should have re-raised" + return result + +def test_try_except_else_like() -> Any: + result: Any = 0 + try: + x: Any = 1 + except Exception: + result = 2 + result = x + assert result == 1, "x should be set from try body" + return result diff --git a/StrataTest/Languages/Python/tests/test_nested_calls.py b/StrataTest/Languages/Python/tests/test_nested_calls.py new file mode 100644 index 000000000..450030b98 --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_nested_calls.py @@ -0,0 +1,21 @@ +def double(x: int) -> int: + return x * 2 + +def add_one(x: int) -> int: + return x + 1 + +def main(): + a: int = double(3) + b: int = double(a) + assert b == 12, "double(double(3)) should be 12" + + c: int = double(5) + d: int = add_one(c) + assert d == 11, "add_one(double(5)) should be 11" + + e: int = add_one(4) + f: int = double(e) + assert f == 10, "double(add_one(4)) should be 10" + +if __name__ == "__main__": + main() diff --git a/StrataTest/Languages/Python/tests/test_return_types.py b/StrataTest/Languages/Python/tests/test_return_types.py new file mode 100644 index 000000000..76f1e9c36 --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_return_types.py @@ -0,0 +1,32 @@ +def get_number() -> int: + return 42 + +def get_greeting() -> str: + return "hello" + +def get_flag() -> bool: + return True + +def get_nothing() -> None: + x: int = 1 + return None + +def add(a: int, b: int) -> int: + result: int = a + b + return result + +def main(): + n: int = get_number() + assert n == 42, "get_number returned wrong value" + + s: str = get_greeting() + assert s == "hello", "get_greeting returned wrong value" + + b: bool = get_flag() + assert b == True, "get_flag returned wrong value" + + total: int = add(10, 20) + assert total == 30, "add returned wrong value" + +if __name__ == "__main__": + main() diff --git a/StrataTest/Languages/Python/tests/test_variable_reassign.py b/StrataTest/Languages/Python/tests/test_variable_reassign.py new file mode 100644 index 000000000..e44a937e8 --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_variable_reassign.py @@ -0,0 +1,35 @@ +def main(): + # Variable reassignment + x: int = 1 + assert x == 1, "initial value" + x = 2 + assert x == 2, "after reassignment" + x = x + 3 + assert x == 5, "after increment" + + # Reassignment in loop + total: int = 0 + i: int = 0 + while i < 5: + total = total + i + i = i + 1 + assert total == 10, "loop sum should be 10" + + # Conditional reassignment + val: int = 0 + flag: bool = True + if flag: + val = 100 + else: + val = 200 + assert val == 100, "should be 100" + + flag = False + if flag: + val = 100 + else: + val = 200 + assert val == 200, "should be 200" + +if __name__ == "__main__": + main() diff --git a/StrataTest/Languages/Python/tests/test_while_loop.py b/StrataTest/Languages/Python/tests/test_while_loop.py new file mode 100644 index 000000000..c492562be --- /dev/null +++ b/StrataTest/Languages/Python/tests/test_while_loop.py @@ -0,0 +1,28 @@ +def test_while_countdown() -> int: + n: int = 5 + total: int = 0 + while n > 0: + total = total + n + n = n - 1 + assert total == 15, "countdown sum should be 15" + return total + +def test_while_true_break() -> int: + count: int = 0 + while True: + count = count + 1 + if count == 10: + break + assert count == 10, "should have counted to 10" + return count + +def test_while_with_continue() -> int: + i: int = 0 + total: int = 0 + while i < 10: + i = i + 1 + if i == 5: + continue + total = total + i + assert total == 50, "sum excluding 5 should be 50" + return total From f3b269c77e3e6c4c4da89e7f671ac766ebbdd190 Mon Sep 17 00:00:00 2001 From: Andrew Wells Date: Thu, 19 Mar 2026 21:01:43 +0000 Subject: [PATCH 2/3] Skip Laurel-only tests when testing SARIF --- .../Languages/Python/run_py_analyze_sarif.py | 2 +- .../Languages/Python/tests/cbmc_expected.txt | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/StrataTest/Languages/Python/run_py_analyze_sarif.py b/StrataTest/Languages/Python/run_py_analyze_sarif.py index eedda433e..2f313aa6d 100755 --- a/StrataTest/Languages/Python/run_py_analyze_sarif.py +++ b/StrataTest/Languages/Python/run_py_analyze_sarif.py @@ -20,7 +20,7 @@ ) BOTH_SKIP = {"test_foo_client_folder", "test_invalid_client_type", "test_unsupported_config"} -SKIP_TESTS = BOTH_SKIP | {"test_class_field_use", "test_list", "test_subscription", "test_with_statement", "test_class_field_init", "test_break_continue", "test_try_except", "test_try_except_scoping"} +SKIP_TESTS = BOTH_SKIP | {"test_class_field_use", "test_list", "test_subscription", "test_with_statement", "test_class_field_init", "test_break_continue", "test_try_except", "test_try_except_scoping", "test_return_types", "test_default_params", "test_dict_operations", "test_class_methods", "test_boolean_logic", "test_multiple_except", "test_for_loop", "test_while_loop", "test_nested_calls", "test_multi_function", "test_class_with_methods", "test_module_level", "test_if_elif", "test_variable_reassign"} SKIP_TESTS_LAUREL = BOTH_SKIP diff --git a/StrataTest/Languages/Python/tests/cbmc_expected.txt b/StrataTest/Languages/Python/tests/cbmc_expected.txt index 641aa4b1e..329ef0743 100644 --- a/StrataTest/Languages/Python/tests/cbmc_expected.txt +++ b/StrataTest/Languages/Python/tests/cbmc_expected.txt @@ -17,3 +17,17 @@ test_datetime.py.ion SKIP test_foo_client_folder.py.ion SKIP test_invalid_client_type.py.ion SKIP test_unsupported_config.py.ion SKIP +test_return_types.py.ion SKIP +test_default_params.py.ion SKIP +test_dict_operations.py.ion SKIP +test_class_methods.py.ion SKIP +test_boolean_logic.py.ion SKIP +test_multiple_except.py.ion SKIP +test_for_loop.py.ion SKIP +test_while_loop.py.ion SKIP +test_nested_calls.py.ion SKIP +test_multi_function.py.ion SKIP +test_class_with_methods.py.ion SKIP +test_module_level.py.ion SKIP +test_if_elif.py.ion SKIP +test_variable_reassign.py.ion SKIP From 5b99218da215844ecb1d55fc9e71792da57b2d8b Mon Sep 17 00:00:00 2001 From: Andrew Wells Date: Fri, 20 Mar 2026 16:21:52 +0000 Subject: [PATCH 3/3] fix merge conflict --- StrataTest/Languages/Python/run_py_analyze_sarif.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/StrataTest/Languages/Python/run_py_analyze_sarif.py b/StrataTest/Languages/Python/run_py_analyze_sarif.py index e0021a49c..410147acd 100755 --- a/StrataTest/Languages/Python/run_py_analyze_sarif.py +++ b/StrataTest/Languages/Python/run_py_analyze_sarif.py @@ -20,7 +20,8 @@ ) BOTH_SKIP = {"test_foo_client_folder", "test_invalid_client_type", "test_unsupported_config"} -SKIP_TESTS = BOTH_SKIP | {"test_class_field_use", "test_list", "test_subscription", "test_with_statement", "test_class_field_init", "test_break_continue", "test_try_except", "test_try_except_scoping", "test_augmented_assign", +SKIP_TESTS = BOTH_SKIP | {"test_class_field_use", + "test_list", "test_subscription", "test_with_statement", "test_class_field_init", "test_break_continue", "test_try_except", "test_try_except_scoping", "test_augmented_assign", "test_return_types", "test_default_params", "test_dict_operations", "test_class_methods", "test_boolean_logic", "test_multiple_except", "test_for_loop", "test_while_loop", "test_nested_calls", "test_multi_function", "test_class_with_methods", "test_module_level", "test_if_elif", "test_variable_reassign"} SKIP_TESTS_LAUREL = BOTH_SKIP