From 6acea1f311cad3dc58821904dd9c5f3bcef5059f Mon Sep 17 00:00:00 2001 From: Myrza Danike Date: Sat, 3 Jan 2026 14:20:59 +0000 Subject: [PATCH] Add TSL files and update blackbox and whitebox test suites --- .gitignore | Bin 170 -> 224 bytes .../arithmetic_oper_test.tsl | 260 ------------------ .../arithmetic_operations.py | 61 ++-- ...c_oper_test => arithmetic_operations_test} | 3 - .../arithmetic_operations_test.tsl | 124 +++++++++ .../category_partitioning/break_loop.py | 14 +- .../category_partitioning/break_loop_test | 3 +- .../category_partitioning/break_loop_test.tsl | 51 ++++ ...omment_write_test => comment_writing_test} | 0 ...rite_test.tsl => comment_writing_test.tsl} | 36 +-- .../category_partitioning/comments_writing.py | 34 +-- .../category_partitioning/exit_statement.py | 22 +- .../exit_statement_test.tsl | 53 ++++ .../integer_reading_and_storing.py | 38 +-- ..._test => integer_reading_and_storing_test} | 0 .../integer_reading_and_storing_test.tsl | 86 ++++++ .../category_partitioning/logical_error.py | 36 +-- .../logical_error_test.tsl | 93 +++++++ .../category_partitioning/math_operations.py | 49 ++-- ...th_operation_test => math_operations_test} | 0 .../math_operations_test.tsl | 143 ++++++++++ ...th_oper_test => nest_math_operations_test} | 0 .../nest_math_operations_test.tsl | 0 .../branch_testing/arithmetic_operations.py | 37 +-- .../whitebox/branch_testing/break_loop.py | 10 +- .../branch_testing/comments_writing.py | 10 +- .../whitebox/branch_testing/exit_statement.py | 14 +- .../integer_reading_and_storing.py | 14 +- .../whitebox/branch_testing/logical_error.py | 26 +- .../branch_testing/nest_math_operations.py | 24 +- .../whitebox/branch_testing/type_functions.py | 16 +- .../concolic_testing/type_function.py | 56 ++++ .../arithmetic_operations.py | 6 - .../integer_reading_and_storing.py | 46 +--- .../condition_testing/logical_error.py | 30 -- .../loop_testing/arithmetic_operations.py | 9 +- .../test/whitebox/loop_testing/break_loop.py | 6 +- .../whitebox/loop_testing/exit_statement.py | 6 +- .../integer_reading_and_storing.py | 6 +- .../whitebox/loop_testing/logical_error.py | 9 +- .../whitebox/loop_testing/math_operations.py | 6 +- .../loop_testing/nest_math_operations.py | 8 +- .../whitebox/loop_testing/type_function.py | 6 +- .../mutation_testing_results.txt | Bin .../mutation_testing/test_src_evaluator.py | 0 .../arithmetic_operations.py | 56 ---- .../whitebox/statement_testing/break_loop.py | 39 --- .../statement_testing/logical_error.py | 45 --- .../statement_testing/nest_math_operations.py | 4 - .../symbolic_testing/type_function.py | 10 + .../statement_testing/bmi_calculator.py | 2 +- .../statement_testing/test_bmi_calculator.py | 3 +- 52 files changed, 837 insertions(+), 773 deletions(-) delete mode 100644 249039503/test/blackbox/category_partitioning/arithmetic_oper_test.tsl rename 249039503/test/blackbox/category_partitioning/{arithmetic_oper_test => arithmetic_operations_test} (73%) create mode 100644 249039503/test/blackbox/category_partitioning/arithmetic_operations_test.tsl create mode 100644 249039503/test/blackbox/category_partitioning/break_loop_test.tsl rename 249039503/test/blackbox/category_partitioning/{comment_write_test => comment_writing_test} (100%) rename 249039503/test/blackbox/category_partitioning/{comment_write_test.tsl => comment_writing_test.tsl} (59%) create mode 100644 249039503/test/blackbox/category_partitioning/exit_statement_test.tsl rename 249039503/test/blackbox/category_partitioning/{integer_read_and_store_test => integer_reading_and_storing_test} (100%) create mode 100644 249039503/test/blackbox/category_partitioning/integer_reading_and_storing_test.tsl create mode 100644 249039503/test/blackbox/category_partitioning/logical_error_test.tsl rename 249039503/test/blackbox/category_partitioning/{math_operation_test => math_operations_test} (100%) create mode 100644 249039503/test/blackbox/category_partitioning/math_operations_test.tsl rename 249039503/test/blackbox/category_partitioning/{nest_math_oper_test => nest_math_operations_test} (100%) create mode 100644 249039503/test/blackbox/category_partitioning/nest_math_operations_test.tsl create mode 100644 249039503/test/whitebox/concolic_testing/type_function.py rename 249039503/test/{blackbox => whitebox}/mutation_testing/mutation_testing_results.txt (100%) rename 249039503/test/{blackbox => whitebox}/mutation_testing/test_src_evaluator.py (100%) delete mode 100644 249039503/test/whitebox/statement_testing/arithmetic_operations.py delete mode 100644 249039503/test/whitebox/statement_testing/break_loop.py delete mode 100644 249039503/test/whitebox/statement_testing/logical_error.py create mode 100644 249039503/test/whitebox/symbolic_testing/type_function.py diff --git a/.gitignore b/.gitignore index 60bf908cba077ee8d1fbb18af6cf3b0c9839ef15..86b747be75f3b2b6b5d9580fb5f7d27f5692d163 100644 GIT binary patch delta 167 zcmW-XF$%&!5CAvr!q#e~U?(K$ZPM5)q!c;gWlauZF5F!rSNR3=4PWI`T&;!~=AC?! z*Rmi~YKXehEi081?y@1Ct-cUmN7L0(YU6|8(K2`be{j>JroUN2nvaV$VK#9;iQ#s0 xin^`bU7D%6lAY$~YEPI4_Tjf=hfjSxJLmUusR8^}Vr0OHiCuEa$60b2Pgr2qf` diff --git a/249039503/test/blackbox/category_partitioning/arithmetic_oper_test.tsl b/249039503/test/blackbox/category_partitioning/arithmetic_oper_test.tsl deleted file mode 100644 index f5283f7e..00000000 --- a/249039503/test/blackbox/category_partitioning/arithmetic_oper_test.tsl +++ /dev/null @@ -1,260 +0,0 @@ - -Test Case 1 - SPECIAL_CASES : DIVIDE_BY_ZERO - - -Test Case 2 (Key = 1.1.1.1.1.) - OPERATOR : PLUS - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 3 (Key = 1.1.1.2.1.) - OPERATOR : PLUS - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 4 (Key = 1.1.2.1.1.) - OPERATOR : PLUS - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 5 (Key = 1.1.2.2.1.) - OPERATOR : PLUS - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 6 (Key = 1.2.1.1.1.) - OPERATOR : PLUS - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 7 (Key = 1.2.1.2.1.) - OPERATOR : PLUS - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 8 (Key = 1.2.2.1.1.) - OPERATOR : PLUS - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 9 (Key = 1.2.2.2.1.) - OPERATOR : PLUS - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 10 (Key = 2.1.1.1.1.) - OPERATOR : MINUS - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 11 (Key = 2.1.1.2.1.) - OPERATOR : MINUS - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 12 (Key = 2.1.2.1.1.) - OPERATOR : MINUS - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 13 (Key = 2.1.2.2.1.) - OPERATOR : MINUS - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 14 (Key = 2.2.1.1.1.) - OPERATOR : MINUS - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 15 (Key = 2.2.1.2.1.) - OPERATOR : MINUS - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 16 (Key = 2.2.2.1.1.) - OPERATOR : MINUS - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 17 (Key = 2.2.2.2.1.) - OPERATOR : MINUS - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 18 (Key = 3.1.1.1.1.) - OPERATOR : MULTIPLY - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 19 (Key = 3.1.1.2.1.) - OPERATOR : MULTIPLY - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 20 (Key = 3.1.2.1.1.) - OPERATOR : MULTIPLY - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 21 (Key = 3.1.2.2.1.) - OPERATOR : MULTIPLY - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 22 (Key = 3.2.1.1.1.) - OPERATOR : MULTIPLY - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 23 (Key = 3.2.1.2.1.) - OPERATOR : MULTIPLY - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 24 (Key = 3.2.2.1.1.) - OPERATOR : MULTIPLY - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 25 (Key = 3.2.2.2.1.) - OPERATOR : MULTIPLY - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 26 (Key = 4.1.1.1.1.) - OPERATOR : DIVIDE - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 27 (Key = 4.1.1.2.1.) - OPERATOR : DIVIDE - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 28 (Key = 4.1.2.1.1.) - OPERATOR : DIVIDE - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 29 (Key = 4.1.2.2.1.) - OPERATOR : DIVIDE - OPERAND_TYPE_LEFT : INT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 30 (Key = 4.2.1.1.1.) - OPERATOR : DIVIDE - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 31 (Key = 4.2.1.2.1.) - OPERATOR : DIVIDE - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : INT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - - -Test Case 32 (Key = 4.2.2.1.1.) - OPERATOR : DIVIDE - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : POSITIVE - SPECIAL_CASES : NORMAL - - -Test Case 33 (Key = 4.2.2.2.1.) - OPERATOR : DIVIDE - OPERAND_TYPE_LEFT : FLOAT - OPERAND_TYPE_RIGHT : FLOAT - OPERAND_SIGN : NEGATIVE - SPECIAL_CASES : NORMAL - diff --git a/249039503/test/blackbox/category_partitioning/arithmetic_operations.py b/249039503/test/blackbox/category_partitioning/arithmetic_operations.py index 12cbd081..562caae3 100644 --- a/249039503/test/blackbox/category_partitioning/arithmetic_operations.py +++ b/249039503/test/blackbox/category_partitioning/arithmetic_operations.py @@ -19,66 +19,59 @@ def _eval(self, expr: str): return result # Tests for + - def test1(self): - self.assertEqual(self._eval("1+2"), 3) + def test_for_plus_1(self): + self.assertEqual(self._eval("999+2"), 1001) - def test2(self): - self.assertEqual(self._eval("-7+3"), -4) + def test_for_plus_2(self): + self.assertEqual(self._eval("-300+3"), -297) - def test3(self): - self.assertEqual(self._eval("5+0"), 5) + def test_for_plus_3(self): + self.assertEqual(self._eval("554+0"), 554) - def test4(self): + def test_for_plus_4(self): self.assertAlmostEqual(self._eval("5.2*3.0"), 15.6, places=6) # Test for - - def test5(self): - self.assertEqual(self._eval("10-5"), 5) + def test_for_minus_5(self): + self.assertEqual(self._eval("225-5"), 220) - def test6(self): - self.assertEqual(self._eval("2-5"), -3) + def test_for_minus_6(self): + self.assertEqual(self._eval("2-500"), -498) - def test7(self): - self.assertEqual(self._eval("9-0"), 9) + def test_for_minus_7(self): + self.assertEqual(self._eval("9123-0"), 9123) - def test8(self): + def test_for_minus_8(self): self.assertAlmostEqual(self._eval("9.0/2.0"), 4.5, places=6) # Test for * - def test9(self): - self.assertEqual(self._eval("9*9"), 81) + def test_for_multiplication_9(self): + self.assertEqual(self._eval("90*90"), 8100) - def test10(self): - self.assertEqual(self._eval("-9*1"), -9) + def test_for_multiplcitaion_10(self): + self.assertEqual(self._eval("-901*1"), -901) - def test11(self): - self.assertEqual(self._eval("9*0"), 0) + def test_for_multiplcitaion_11(self): + self.assertEqual(self._eval("9123*0"), 0) - def test12(self): + def test_for_multiplication_12(self): self.assertAlmostEqual(self._eval("2.0*3.5"), 7.0, places=6) # Test for / - def test13(self): - self.assertEqual(self._eval("9/3"), 3) + def test_for_division_13(self): + self.assertEqual(self._eval("999/3"), 333) - def test14(self): - self.assertEqual(self._eval("-9/3"), -3) + def test_for_division_14(self): + self.assertEqual(self._eval("-903/3"), -301) - def test15(self): + def test_for_division_15(self): self.assertAlmostEqual(self._eval("10.0/4.0"), 2.5, places=6) - def test16(self): + def test_for_division_16(self): with self.assertRaises(RuntimeEvaluationError) as context: self._eval("6/0") self.assertIn("Division by zero", str(context.exception)) - # Combined different situations - def test17(self): - self.assertEqual(self._eval("3+4-2"), 5) - - def test18(self): - self.assertAlmostEqual(self._eval(" 5.0 * 2.0/1.0"), 10.0, places=6) - if __name__ == "__main__": unittest.main() diff --git a/249039503/test/blackbox/category_partitioning/arithmetic_oper_test b/249039503/test/blackbox/category_partitioning/arithmetic_operations_test similarity index 73% rename from 249039503/test/blackbox/category_partitioning/arithmetic_oper_test rename to 249039503/test/blackbox/category_partitioning/arithmetic_operations_test index 482facb4..b06f1208 100644 --- a/249039503/test/blackbox/category_partitioning/arithmetic_oper_test +++ b/249039503/test/blackbox/category_partitioning/arithmetic_operations_test @@ -10,9 +10,6 @@ OPERANDS: INCLUDES_NEGATIVE_OPERANDS INCLUDES_ZERO_OPERANDS DIVISION_BY_ZERO.[error] - WHITESPACE_PRESENT EXPRESSION_STRUCTURE: SINGLE_OPERATIONS.[single] - MULTIPLE_OPERATIONS (same precedence) - MULTIPLE_OPERATIONS (mixed precedence) diff --git a/249039503/test/blackbox/category_partitioning/arithmetic_operations_test.tsl b/249039503/test/blackbox/category_partitioning/arithmetic_operations_test.tsl new file mode 100644 index 00000000..0325507e --- /dev/null +++ b/249039503/test/blackbox/category_partitioning/arithmetic_operations_test.tsl @@ -0,0 +1,124 @@ + +Test Case 1 + SPECIAL_CASES : DIVIDE_BY_ZERO + + +Test Case 2 (Key = 1.1.1.1.1.) + OPERATOR : PLUS + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : NORMAL + + +Test Case 3 (Key = 1.1.1.2.1.) + OPERATOR : PLUS + OPERAND_TYPE_LEFT : INT(NEGATIVE) + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : NEGATIVE + SPECIAL_CASES : NORMAL + + +Test Case 4 (Key = 1.1.2.1.1.) + OPERATOR : PLUS + OPERAND_TYPE_LEFT : FLOAT + OPERAND_TYPE_RIGHT : FLOAT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : NORMAL + + +Test Case 5 (Key = 1.1.2.2.1.) + OPERATOR : MINUS + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : NORMAL + + +Test Case 6 (Key = 1.2.1.1.1.) + OPERATOR : MINUS + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : NORMAL + + +Test Case 7 (Key = 1.2.1.2.1.) + OPERATOR : MINUS + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : NORMAL + + +Test Case 8 (Key = 1.2.2.1.1.) + OPERATOR : MINUS + OPERAND_TYPE_LEFT : FLOAT + OPERAND_TYPE_RIGHT : FLOAT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : NORMAL + + +Test Case 9 (Key = 1.2.2.2.1.) + OPERATOR : MULTIPLICATION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : NEGATIVE + SPECIAL_CASES : NORMAL + + +Test Case 10 (Key = 2.1.1.1.1.) + OPERATOR : MULTIPLICATION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : NEGATIVE + SPECIAL_CASES : NORMAL + + +Test Case 11 (Key = 2.1.1.2.1.) + OPERATOR : MULTIPLICATION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : NEGATIVE + SPECIAL_CASES : NORMAL + + +Test Case 12 (Key = 2.1.2.1.1.) + OPERATOR : MULTIPLICATION + OPERAND_TYPE_LEFT : FLOAT + OPERAND_TYPE_RIGHT : FLOAT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : NORMAL + + +Test Case 13 (Key = 2.1.2.2.1.) + OPERATOR : DIVISION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : NORMAL + + +Test Case 14 (Key = 2.2.1.1.1.) + OPERATOR : DIVISION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : NEGATIVE + SPECIAL_CASES : NORMAL + + +Test Case 15 (Key = 2.2.1.2.1.) + OPERATOR : DIVISION + OPERAND_TYPE_LEFT : FLOAT + OPERAND_TYPE_RIGHT : FLOAT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : NORMAL + + +Test Case 16 (Key = 2.2.2.1.1.) + OPERATOR : DIVISION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + OPERAND_SIGN : POSITIVE + SPECIAL_CASES : ERROR(EXCEPTION) + diff --git a/249039503/test/blackbox/category_partitioning/break_loop.py b/249039503/test/blackbox/category_partitioning/break_loop.py index ed37fea5..b2a55eee 100644 --- a/249039503/test/blackbox/category_partitioning/break_loop.py +++ b/249039503/test/blackbox/category_partitioning/break_loop.py @@ -12,7 +12,7 @@ def evaluate_expr(program: str): class BreakStatementCategoryPartitioningTests(unittest.TestCase): - def test_break_never_triggers(self): + def test_break_1(self): program = """ let i = 0; @@ -24,7 +24,7 @@ def test_break_never_triggers(self): """ self.assertEqual(evaluate_expr(program), 5) - def test_break_first_iteration(self): + def test_break_first_iteration_2(self): program = """ let i = 0; @@ -36,7 +36,7 @@ def test_break_first_iteration(self): """ self.assertEqual(evaluate_expr(program), 0) - def test_break_middle_iteration(self): + def test_break_middle_iteration_3(self): program = """ let i = 0; @@ -50,7 +50,7 @@ def test_break_middle_iteration(self): """ self.assertEqual(evaluate_expr(program), 3) - def test_break_last_useful_iteration(self): + def test_break_last_iteration_4(self): program = """ let i = 0; @@ -64,7 +64,7 @@ def test_break_last_useful_iteration(self): """ self.assertEqual(evaluate_expr(program), 4) - def test_break_only_exits_inner_loop(self): + def test_break_inner_loop_5(self): program = """ let i = 0; @@ -81,12 +81,12 @@ def test_break_only_exits_inner_loop(self): """ self.assertEqual(evaluate_expr(program), 3) - def test_break_outside_loop_raises(self): + def test_break_outside_loop_6(self): program = "break;" with self.assertRaises(Exception): evaluate_expr(program) - def test_assignment_works(self): + def test_assignment_works_7(self): program = """ let x = 1; x = x + 1; diff --git a/249039503/test/blackbox/category_partitioning/break_loop_test b/249039503/test/blackbox/category_partitioning/break_loop_test index af8493fc..bffdd79e 100644 --- a/249039503/test/blackbox/category_partitioning/break_loop_test +++ b/249039503/test/blackbox/category_partitioning/break_loop_test @@ -5,7 +5,7 @@ CATEGORY LOOP_NESTING: CATEGORY BREAK_POSITION: FIRST_ITERATION.[single] MIDDLE_ITERATION.[single] - LAST_USEFUL_ITERATION.[single] + LAST_ITERATION.[single] NEVER_EXECUTED CATEGORY BREAK_LOCATION: @@ -14,4 +14,3 @@ CATEGORY BREAK_LOCATION: CATEGORY VALIDITY: BREAK_INSIDE_LOOP.[single] - BREAK_OUTSIDE_LOOP.[error] diff --git a/249039503/test/blackbox/category_partitioning/break_loop_test.tsl b/249039503/test/blackbox/category_partitioning/break_loop_test.tsl new file mode 100644 index 00000000..63192f31 --- /dev/null +++ b/249039503/test/blackbox/category_partitioning/break_loop_test.tsl @@ -0,0 +1,51 @@ +Test Case 1 (Key = 1.1.1.1.) + FEATURE : BREAK + BREAK_POSITION : NONE + LOOP_NESTING : SINGLE + LOOP_UPDATES_OUTER : YES + SPECIAL_CASES : NORMAL + + +Test Case 2 (Key = 1.1.1.2.) + FEATURE : BREAK + BREAK_POSITION : FIRST_ITERATION + LOOP_NESTING : SINGLE + LOOP_UPDATES_OUTER : NO + SPECIAL_CASES : NORMAL + + +Test Case 3 (Key = 1.1.2.1.) + FEATURE : BREAK + BREAK_POSITION : MIDDLE_ITERATION (trigger at i == 3) + LOOP_NESTING : SINGLE + LOOP_UPDATES_OUTER : YES (increment happens before check in loop flow) + SPECIAL_CASES : NORMAL + + +Test Case 4 (Key = 1.1.2.2.) + FEATURE : BREAK + BREAK_POSITION : LAST_ITERATION (trigger at i == 4) + LOOP_NESTING : SINGLE + LOOP_UPDATES_OUTER : YES + SPECIAL_CASES : NORMAL + + +Test Case 5 (Key = 1.2.1.1.) + FEATURE : BREAK + BREAK_POSITION : INNER_LOOP_ONLY (trigger at j == 2) + LOOP_NESTING : NESTED + BREAK_SCOPE : INNER + SPECIAL_CASES : NORMAL + + +Test Case 6 (Key = 2.1.1.1.) + FEATURE : BREAK + CONTEXT : OUTSIDE_LOOP + SPECIAL_CASES : INVALID_BREAK_CONTEXT + + +Test Case 7 (Key = 3.1.1.1.) + FEATURE : ASSIGNMENT + ASSIGN_TARGET : EXISTING_VARIABLE + ASSIGN_EXPRESSION : RANDOMLY CHOSEN + SPECIAL_CASES : NORMAL diff --git a/249039503/test/blackbox/category_partitioning/comment_write_test b/249039503/test/blackbox/category_partitioning/comment_writing_test similarity index 100% rename from 249039503/test/blackbox/category_partitioning/comment_write_test rename to 249039503/test/blackbox/category_partitioning/comment_writing_test diff --git a/249039503/test/blackbox/category_partitioning/comment_write_test.tsl b/249039503/test/blackbox/category_partitioning/comment_writing_test.tsl similarity index 59% rename from 249039503/test/blackbox/category_partitioning/comment_write_test.tsl rename to 249039503/test/blackbox/category_partitioning/comment_writing_test.tsl index 5d44291b..983fd7f5 100644 --- a/249039503/test/blackbox/category_partitioning/comment_write_test.tsl +++ b/249039503/test/blackbox/category_partitioning/comment_writing_test.tsl @@ -2,54 +2,34 @@ Test Case 1 COMMENT_MARKER : HASH - Test Case 2 - COMMENT_MARKER : SLASHSLASH - - -Test Case 3 - TERMINATION : NEWLINE - - -Test Case 4 TERMINATION : EOF - -Test Case 5 - CONTENT : EMPTY - - -Test Case 6 +Test Case 3 CONTENT : NON_EMPTY - -Test Case 7 +Test Case 4 WHITESPACE_BEFORE : NONE - -Test Case 8 - WHITESPACE_BEFORE : SPACES - - -Test Case 9 (Key = 0.1.0.0.0.) +Test Case 5 (Key = 0.1.0.0.0.) COMMENT_MARKER : - POSITION : ONLY_COMMENT_LINE + POSITION : TRAILING_COMMENT TERMINATION : CONTENT : WHITESPACE_BEFORE : -Test Case 10 (Key = 0.2.0.0.0.) +Test Case 6 (Key = 0.2.0.0.0.) COMMENT_MARKER : - POSITION : LEADING_COMMENT_LINES + POSITION : - TERMINATION : CONTENT : WHITESPACE_BEFORE : -Test Case 11 (Key = 0.3.0.0.0.) +Test Case 7 (Key = 0.3.0.0.0.) COMMENT_MARKER : - POSITION : TRAILING_COMMENT + POSITION : SPACES_COMMENT TERMINATION : CONTENT : WHITESPACE_BEFORE : diff --git a/249039503/test/blackbox/category_partitioning/comments_writing.py b/249039503/test/blackbox/category_partitioning/comments_writing.py index 77e83682..24dce791 100644 --- a/249039503/test/blackbox/category_partitioning/comments_writing.py +++ b/249039503/test/blackbox/category_partitioning/comments_writing.py @@ -16,34 +16,20 @@ def _collect_tokens(self, source: str): return tokens - def test1(self): + def test_comment_line_1(self): src = "# just a comment\n" tokens = self._collect_tokens(src) - self.assertEqual(tokens, [], "Comment only line should produce no tokens") + self.assertEqual(tokens, [], "only no tokens") - def test2(self): + def test_comment_EOF_2(self): src = "# just a comment" tokens = self._collect_tokens(src) - self.assertEqual(tokens, [], "Comment only at EOF should produce no tokens") + self.assertEqual(tokens, [], "only at EOF should produce no tokens") - def test3(self): - src = "// just a comment\n" - tokens = self._collect_tokens(src) - - self.assertEqual(tokens, [], "'//' Comment only line should produce no tokens") - - def test4(self): - src = "// just a comment" - tokens = self._collect_tokens(src) - - self.assertEqual( - tokens, [], "'//' Comment only at EOF should produce no tokens" - ) - - def test5(self): - src = "# first comment line\n# second comment line\nlet x = 1;" + def test_only_1st_line_3(self): + src = "# 1st comment line\n# 2nd comment line\nlet x = 1;" tokens = self._collect_tokens(src) expected_tokens = [ @@ -55,7 +41,7 @@ def test5(self): ] self.assertEqual(tokens, expected_tokens) - def test6(self): + def test_trailing_comment_4(self): src = "let x = 1; # trailing comment\n" tokens = self._collect_tokens(src) @@ -68,7 +54,7 @@ def test6(self): ] self.assertEqual(tokens, expected_tokens) - def test7(self): + def test_trailing_comment_5(self): src = "let x = 1; // trailing comment\n" tokens = self._collect_tokens(src) @@ -81,7 +67,7 @@ def test7(self): ] self.assertEqual(tokens, expected_tokens) - def test8(self): + def test_comment_6(self): src = "#\nlet x = 1;" tokens = self._collect_tokens(src) @@ -94,7 +80,7 @@ def test8(self): ] self.assertEqual(tokens, expected_tokens) - def test9(self): + def test_spaced_comment_7(self): src = " # spaced comment\nlet x = 1;" tokens = self._collect_tokens(src) diff --git a/249039503/test/blackbox/category_partitioning/exit_statement.py b/249039503/test/blackbox/category_partitioning/exit_statement.py index b65538ea..10964288 100644 --- a/249039503/test/blackbox/category_partitioning/exit_statement.py +++ b/249039503/test/blackbox/category_partitioning/exit_statement.py @@ -12,23 +12,23 @@ def evaluate_expr(program: str): class ExitStatementCategoryPartitioningTests(unittest.TestCase): - def test_top_level_int_literal_immediate_termination(self): + def test_exit_1(self): program = """ exit(7); 999; """ self.assertEqual(evaluate_expr(program), 7) - def test_inside_if_int_expression_immediate_termination(self): + def test_exit_inside_if_2(self): program = """ if true { - exit(3 + 4); + exit(32 + 24); } 999; """ - self.assertEqual(evaluate_expr(program), 7) + self.assertEqual(evaluate_expr(program), 56) - def test_inside_loop_int_literal_immediate_termination(self): + def test_exit_inside_loop_3(self): program = """ let i = 0; for (let i = 0; i < 10; i = i + 1) { @@ -38,30 +38,30 @@ def test_inside_loop_int_literal_immediate_termination(self): """ self.assertEqual(evaluate_expr(program), 7) - def test_non_int_value_raises_error(self): + def test_another_value_error_4(self): program = """ - exit(1.5); + exit(12.5); """ with self.assertRaises(Exception): evaluate_expr(program) - def test_bool_value_raises_error(self): + def test_bool_value_raises_error_5(self): program = """ exit(true); """ with self.assertRaises(Exception): evaluate_expr(program) - def test_no_argument_raises_error(self): + def test_no_argument_raises_error_6(self): program = """ exit(); """ with self.assertRaises(Exception): evaluate_expr(program) - def test_multiple_arguments_raises_error(self): + def test_multiple_arguments_raises_error_7(self): program = """ - exit(1, 2); + exit(777, 123); """ with self.assertRaises(Exception): evaluate_expr(program) diff --git a/249039503/test/blackbox/category_partitioning/exit_statement_test.tsl b/249039503/test/blackbox/category_partitioning/exit_statement_test.tsl new file mode 100644 index 00000000..0d803a05 --- /dev/null +++ b/249039503/test/blackbox/category_partitioning/exit_statement_test.tsl @@ -0,0 +1,53 @@ +Test Case 1 (Key = 1.1.1.1.) + FEATURE : EXIT + CONTEXT : TOP_LEVEL + ARG_TYPE : INT + ARG_EXPRESSION : LITERAL + SPECIAL_CASES : NORMAL + + +Test Case 2 (Key = 1.1.1.2.) + FEATURE : EXIT + CONTEXT : INSIDE_IF + IF_CONDITION : TRUE + ARG_COUNT : ONE + ARG_TYPE : INT + SPECIAL_CASES : NORMAL + + +Test Case 3 (Key = 1.1.2.1.) + FEATURE : EXIT + CONTEXT : INSIDE_LOOP + ARG_COUNT : ONE + ARG_TYPE : INT + SPECIAL_CASES : NORMAL + + +Test Case 4 (Key = 2.1.1.1.) + FEATURE : EXIT + CONTEXT : TOP_LEVEL + ARG_COUNT : ONE + ARG_TYPE : FLOAT + SPECIAL_CASES : INVALID_EXIT_CODE_TYPE + + +Test Case 5 (Key = 2.1.1.2.) + FEATURE : EXIT + CONTEXT : TOP_LEVEL + ARG_COUNT : ONE + ARG_TYPE : BOOL + SPECIAL_CASES : INVALID_EXIT_CODE_TYPE + + +Test Case 6 (Key = 2.2.1.1.) + FEATURE : EXIT + CONTEXT : TOP_LEVEL + ARG_COUNT : ZERO + SPECIAL_CASES : MISSING_ARGUMENT + + +Test Case 7 (Key = 2.2.1.2.) + FEATURE : EXIT + CONTEXT : TOP_LEVEL + ARG_COUNT : MULTIPLE + SPECIAL_CASES : TOO_MANY_ARGUMENTS diff --git a/249039503/test/blackbox/category_partitioning/integer_reading_and_storing.py b/249039503/test/blackbox/category_partitioning/integer_reading_and_storing.py index 537570cf..be89a8f2 100644 --- a/249039503/test/blackbox/category_partitioning/integer_reading_and_storing.py +++ b/249039503/test/blackbox/category_partitioning/integer_reading_and_storing.py @@ -16,54 +16,54 @@ def _collect_tokens(self, source: str): return tokens - def test_zero_standalone(self): + def test_zero_1(self): src = "0" tokens = self._collect_tokens(src) expected = [(Token.INT, "0")] self.assertEqual(tokens, expected) - def test_positive_single_digit(self): - src = "5" + def test_positive_digit_2(self): + src = "7" tokens = self._collect_tokens(src) - expected = [(Token.INT, "5")] + expected = [(Token.INT, "7")] self.assertEqual(tokens, expected) - def test_positive_multi_digit(self): - src = "123" + def test_positive_multi_digit_3(self): + src = "567" tokens = self._collect_tokens(src) - expected = [(Token.INT, "123")] + expected = [(Token.INT, "567")] self.assertEqual(tokens, expected) - def test_negative_single_digit(self): - src = "-5" + def test_negative_single_digit_4(self): + src = "-3" tokens = self._collect_tokens(src) - expected = [(Token.INT, "-5")] + expected = [(Token.INT, "-3")] self.assertEqual(tokens, expected) - def test_negative_multi_digit(self): - src = "-123" + def test_negative_multi_digit_5(self): + src = "-857" tokens = self._collect_tokens(src) - expected = [(Token.INT, "-123")] + expected = [(Token.INT, "-857")] self.assertEqual(tokens, expected) - def test_leading_zero_integer(self): + def test_leading_zero_integer_6(self): src = "007" tokens = self._collect_tokens(src) expected = [(Token.INT, "007")] self.assertEqual(tokens, expected) - def test_assignment_positive_integer(self): - src = "let x = 42" + def test_assigned_positive_integer_7(self): + src = "let x = 87" tokens = self._collect_tokens(src) expected = [ (Token.LET, "let"), (Token.IDENTIFIER, "x"), (Token.ASSIGN, "="), - (Token.INT, "42"), + (Token.INT, "87"), ] self.assertEqual(tokens, expected) - def test_assignment_negative_integer(self): + def test_assigned_negative_integer_8(self): src = "let x = -42" tokens = self._collect_tokens(src) expected = [ @@ -74,7 +74,7 @@ def test_assignment_negative_integer(self): ] self.assertEqual(tokens, expected) - def test_trailing_dot_raises_error(self): + def test_trailing_dot_error_9(self): src = "1." with self.assertRaises(Exception): self._collect_tokens(src) diff --git a/249039503/test/blackbox/category_partitioning/integer_read_and_store_test b/249039503/test/blackbox/category_partitioning/integer_reading_and_storing_test similarity index 100% rename from 249039503/test/blackbox/category_partitioning/integer_read_and_store_test rename to 249039503/test/blackbox/category_partitioning/integer_reading_and_storing_test diff --git a/249039503/test/blackbox/category_partitioning/integer_reading_and_storing_test.tsl b/249039503/test/blackbox/category_partitioning/integer_reading_and_storing_test.tsl new file mode 100644 index 00000000..f08f3e78 --- /dev/null +++ b/249039503/test/blackbox/category_partitioning/integer_reading_and_storing_test.tsl @@ -0,0 +1,86 @@ +Test Case 1 (Key = 1.1.1.1.) + FEATURE : INTEGER_LITERAL + SIGN : NONE + DIGIT_COUNT : SINGLE + VALUE : ZERO + CONTEXT : STANDALONE + EXPECTED_TOKEN : INT + SPECIAL_CASES : NORMAL + + +Test Case 2 (Key = 1.1.1.2.) + FEATURE : INTEGER_LITERAL + SIGN : POSITIVE + DIGIT_COUNT : SINGLE + VALUE : NON_ZERO + CONTEXT : STANDALONE + EXPECTED_TOKEN : INT + SPECIAL_CASES : NORMAL + + +Test Case 3 (Key = 1.1.2.1.) + FEATURE : INTEGER_LITERAL + SIGN : POSITIVE + DIGIT_COUNT : MULTI + VALUE : NON_ZERO + CONTEXT : STANDALONE + EXPECTED_TOKEN : INT + SPECIAL_CASES : NORMAL + + +Test Case 4 (Key = 1.2.1.1.) + FEATURE : INTEGER_LITERAL + SIGN : NEGATIVE + DIGIT_COUNT : SINGLE + VALUE : NON_ZERO + CONTEXT : STANDALONE + EXPECTED_TOKEN : INT + SPECIAL_CASES : NORMAL + + +Test Case 5 (Key = 1.2.2.1.) + FEATURE : INTEGER_LITERAL + SIGN : NEGATIVE + DIGIT_COUNT : MULTI + VALUE : NON_ZERO + CONTEXT : STANDALONE + EXPECTED_TOKEN : INT + SPECIAL_CASES : NORMAL + + +Test Case 6 (Key = 1.3.1.1.) + FEATURE : INTEGER_LITERAL + SIGN : NONE + LEADING_ZEROS : PRESENT + DIGIT_COUNT : MULTI + CONTEXT : STANDALONE + EXPECTED_TOKEN : INT + SPECIAL_CASES : NORMAL + + +Test Case 7 (Key = 2.1.1.1.) + FEATURE : INTEGER_LITERAL + SIGN : POSITIVE + DIGIT_COUNT : MULTI + CONTEXT : ASSIGNMENT + PRECEDING_TOKENS : LET IDENTIFIER ASSIGN + EXPECTED_TOKENS : LET IDENTIFIER ASSIGN INT + SPECIAL_CASES : NORMAL + + +Test Case 8 (Key = 2.1.2.1.) + FEATURE : INTEGER_LITERAL + SIGN : NEGATIVE + DIGIT_COUNT : MULTI + CONTEXT : ASSIGNMENT + PRECEDING_TOKENS : LET IDENTIFIER ASSIGN + EXPECTED_TOKENS : LET IDENTIFIER ASSIGN INT + SPECIAL_CASES : NORMAL + + +Test Case 9 (Key = 3.1.1.1.) + FEATURE : INTEGER_LITERAL + INVALID_FORMAT : TRAILING_DOT + CONTEXT : STANDALONE + EXPECTED_BEHAVIOUR : LEXICAL_ERROR + SPECIAL_CASES : INVALID_INTEGER_FORMAT diff --git a/249039503/test/blackbox/category_partitioning/logical_error.py b/249039503/test/blackbox/category_partitioning/logical_error.py index 328918b1..5407bdeb 100644 --- a/249039503/test/blackbox/category_partitioning/logical_error.py +++ b/249039503/test/blackbox/category_partitioning/logical_error.py @@ -17,46 +17,46 @@ def evaluate_expr(self, expr: str): result = _eval(e, env) return result - def test1(self): - self.assertEqual(self.evaluate_expr("10/2"), 5) + def test_no_error_1(self): + self.assertEqual(self.evaluate_expr("100/2"), 50) - def test2(self): + def test_division_int_to_float_2(self): self.assertEqual(self.evaluate_expr("10/2.0"), 5.0) - def test3(self): + def test_nested_operation_3(self): self.assertEqual(self.evaluate_expr("10/(2+3)"), 2) - def test4(self): + def test_division_by_zero_4(self): with self.assertRaises(RuntimeEvaluationError) as context: - self.evaluate_expr("6/0") + self.evaluate_expr("62/0") self.assertIn("Division by zero", str(context.exception)) - def test5(self): + def test_nested_division_by_zero_5(self): with self.assertRaises(RuntimeEvaluationError) as context: - self.evaluate_expr("10/(2-2)") + self.evaluate_expr("102/(2-2)") self.assertIn("Division by zero", str(context.exception)) - def test6(self): + def test_division_by_zero_6(self): with self.assertRaises(RuntimeEvaluationError) as context: self.evaluate_expr("10/0") self.assertIn("Division by zero", str(context.exception)) - def test7(self): + def test_undefined_var_7(self): with self.assertRaises(RuntimeEvaluationError) as context: self.evaluate_expr("x + 1") self.assertIn("Undefined variable 'x'", str(context.exception)) - def test8(self): - result = self.evaluate_expr("let x = 1; x + 2;") - self.assertEqual(result, 3) + def test_defined_var_8(self): + result = self.evaluate_expr("let x = 1123; x + 2;") + self.assertEqual(result, 1125) - def test9(self): - result = self.evaluate_expr("const y = 5; y + 1;") - self.assertEqual(result, 6) + def test_const_9(self): + result = self.evaluate_expr("const y = 5345; y + 1;") + self.assertEqual(result, 5346) - def test10(self): + def test_undefined_var_10(self): with self.assertRaises(RuntimeEvaluationError) as context: - self.evaluate_expr("x = 10;") + self.evaluate_expr("x = 1000;") self.assertIn("Undefined variable 'x'", str(context.exception)) def test11(self): diff --git a/249039503/test/blackbox/category_partitioning/logical_error_test.tsl b/249039503/test/blackbox/category_partitioning/logical_error_test.tsl new file mode 100644 index 00000000..25df94cf --- /dev/null +++ b/249039503/test/blackbox/category_partitioning/logical_error_test.tsl @@ -0,0 +1,93 @@ +Test Case 1 (Key = 1.1.1.1.) + FEATURE : DIVISION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + SPECIAL_CASES : NORMAL + + +Test Case 2 (Key = 1.1.1.2.) + FEATURE : DIVISION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : FLOAT + RESULT_TYPE : FLOAT + NESTING : NONE + ENV_STATE : EMPTY + EXPECTED_BEHAVIOUR : NORMAL_EVALUATION + SPECIAL_CASES : NORMAL + + +Test Case 3 (Key = 1.1.2.1.) + FEATURE : DIVISION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : EXPRESSION(INT + INT) + NESTING : PRESENT (PARENTHESES) + ENV_STATE : EMPTY + EXPECTED_BEHAVIOUR : NORMAL_EVALUATION + SPECIAL_CASES : NORMAL + + +Test Case 4 (Key = 2.1.1.1.) + FEATURE : DIVISION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + RIGHT_OPERAND_VALUE : ZERO + SPECIAL_CASES : DIVIDE_BY_ZERO + + +Test Case 5 (Key = 2.1.2.1.) + FEATURE : DIVISION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : EXPRESSION(INT - INT) + RIGHT_OPERAND_VALUE : EVALUATES_TO_ZERO + NESTING : PRESENT (PARENTHESES) + ENV_STATE : EMPTY + EXPECTED_BEHAVIOUR : RUNTIME_ERROR + SPECIAL_CASES : DIVIDE_BY_ZERO (NESTED) + + +Test Case 6 (Key = 2.1.1.2.) + FEATURE : DIVISION + OPERAND_TYPE_LEFT : INT + OPERAND_TYPE_RIGHT : INT + RIGHT_OPERAND_VALUE : ZERO + SPECIAL_CASES : DIVIDE_BY_ZERO + + +Test Case 7 (Key = 3.1.1.1.) + FEATURE : IDENTIFIER_USAGE + IDENTIFIER_STATE : UNDEFINED + OPERATOR : PLUS + EXPRESSION_FORM : x + INT + SPECIAL_CASES : UNDEFINED_VARIABLE (READ) + + +Test Case 8 (Key = 3.2.1.1.) + FEATURE : LET_DECLARATION + IDENTIFIER_STATE : DEFINED + DECLARATION_KIND : LET + FOLLOWUP_OPERATION : PLUS + SPECIAL_CASES : NORMAL + + +Test Case 9 (Key = 3.2.2.1.) + FEATURE : CONST_DECLARATION + IDENTIFIER_STATE : DEFINED + DECLARATION_KIND : CONST + FOLLOWUP_OPERATION : PLUS + SPECIAL_CASES : NORMAL + + +Test Case 10 (Key = 3.1.2.1.) + FEATURE : ASSIGNMENT + IDENTIFIER_STATE : UNDEFINED + EXPRESSION_FORM : x = INT + EXPECTED_BEHAVIOUR : RUNTIME_ERROR + SPECIAL_CASES : UNDEFINED_VARIABLE (ASSIGN) + + +Test Case 11 (Key = 3.3.1.1.) + FEATURE : ASSIGNMENT + IDENTIFIER_STATE : DEFINED + DECLARATION_KIND : LET + ASSIGNMENT_COUNT : ONE + SPECIAL_CASES : NORMAL diff --git a/249039503/test/blackbox/category_partitioning/math_operations.py b/249039503/test/blackbox/category_partitioning/math_operations.py index c2738720..f7b4a790 100644 --- a/249039503/test/blackbox/category_partitioning/math_operations.py +++ b/249039503/test/blackbox/category_partitioning/math_operations.py @@ -17,50 +17,47 @@ def _eval(self, expr: str): result = _eval(e, env) return result - def test1(self): - self.assertEqual(self._eval("1 + 2 + 3"), 6) + def test_simple_expression_with_plus_1(self): + self.assertEqual(self._eval("100 + 2 + 3"), 105) - def test2(self): - self.assertEqual(self._eval("1 * 2 + 3"), 5) + def test_simple_expression_combined_2(self): + self.assertEqual(self._eval("1 * 25 + 3"), 28) - def test3(self): - self.assertEqual(self._eval("1 * 2 * 3 + 4"), 10) + def test_simple_expression_combined_3(self): + self.assertEqual(self._eval("10 * 12 * 3 + 4"), 364) - def test4(self): - self.assertEqual(self._eval("-1 + 2 + 3 - 4 - 5"), -5) + def test_combined_alt_digit_4(self): + self.assertEqual(self._eval("-10 + 2 + 3 - 4 - 5"), -14) - def test5(self): - self.assertEqual(self._eval("1 + 2 - 3 + 4"), 4) + def test_combined_minus_plus_5(self): + self.assertEqual(self._eval("12 + 23 - 43 + 44"), 36) - def test6(self): - self.assertEqual(self._eval("8 / 2 * 4 + 2"), 18) + def test_combined_division_multiplication_plus6(self): + self.assertEqual(self._eval("88 / 2 * 4 + 212"), 388) - def test7(self): + def test_combined_7(self): self.assertEqual(self._eval("1 + 2 * 3 - 2 + 4 / 2"), 7) - def test8(self): - self.assertEqual(self._eval("1 + 2 * 3"), 7) + def test_simple_plus_8(self): + self.assertEqual(self._eval("111 + 222 * 223"), 49617) - def test9(self): + def test_multiplication_by_zero_9(self): self.assertEqual(self._eval("0 * 1 + 2 * 0"), 0) - def test10(self): - self.assertEqual(self._eval("-1 + 2 * 3"), 5) + def test_minus_signed_digit_10(self): + self.assertEqual(self._eval("-11 + 20 * 3"), 49) - def test11(self): + def test_several_minus_digits_11(self): self.assertEqual(self._eval("(-1) + 2 * (-3)"), -7) - def test12(self): - self.assertEqual(self._eval("1 + 2 * 3 + 4"), 11) - - def test13(self): - self.assertEqual(self._eval("(1 + 2) * 3 + 4"), 13) + def test_nested_operation_12(self): + self.assertEqual(self._eval("(10 + 2) * 30 + 4"), 364) def test_sqrt(self): - self.assertEqual(self._eval("sqrt(9);"), 3.0) + self.assertEqual(self._eval("sqrt(900);"), 30.0) def test_pow(self): - self.assertEqual(self._eval("pow(2,3);"), 8.0) + self.assertEqual(self._eval("pow(20,3);"), 800.0) def test_ceil(self): self.assertEqual(self._eval("ceil(2.3);"), 3) diff --git a/249039503/test/blackbox/category_partitioning/math_operation_test b/249039503/test/blackbox/category_partitioning/math_operations_test similarity index 100% rename from 249039503/test/blackbox/category_partitioning/math_operation_test rename to 249039503/test/blackbox/category_partitioning/math_operations_test diff --git a/249039503/test/blackbox/category_partitioning/math_operations_test.tsl b/249039503/test/blackbox/category_partitioning/math_operations_test.tsl new file mode 100644 index 00000000..709d8a7c --- /dev/null +++ b/249039503/test/blackbox/category_partitioning/math_operations_test.tsl @@ -0,0 +1,143 @@ +Test Case 1 (Key = 1.1.1.1.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : PLUS (CHAIN) + PRECEDENCE_FOCUS : LEFT_TO_RIGHT (SAME_PRECEDENCE) + OPERAND_TYPES : INT, INT, INT + SPECIAL_CASES : NORMAL + + +Test Case 2 (Key = 1.1.2.1.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : MULTIPLY THEN PLUS + PRECEDENCE_FOCUS : MULTIPLY_OVER_PLUS + OPERAND_TYPES : INT, INT, INT + SPECIAL_CASES : NORMAL + + +Test Case 3 (Key = 1.1.2.2.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : MULTIPLY (CHAIN) THEN PLUS + PRECEDENCE_FOCUS : MULTIPLY_CHAIN_ASSOCIATIVITY + OPERAND_TYPES : INT, INT, INT, INT + SPECIAL_CASES : NORMAL + + +Test Case 4 (Key = 1.2.1.1.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : PLUS/MINUS (CHAIN) + PRECEDENCE_FOCUS : LEFT_TO_RIGHT (SAME_PRECEDENCE) + OPERAND_TYPES : INT, INT, INT, INT, INT + SPECIAL_CASES : NORMAL + + +Test Case 5 (Key = 1.2.1.2.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : PLUS/MINUS (CHAIN) + PRECEDENCE_FOCUS : LEFT_TO_RIGHT (SAME_PRECEDENCE) + OPERAND_TYPES : INT, INT, INT, INT + SPECIAL_CASES : NORMAL + + +Test Case 6 (Key = 1.2.2.1.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : DIVIDE THEN MULTIPLY THEN PLUS + PRECEDENCE_FOCUS : DIVIDE_MULTIPLY_LEFT_TO_RIGHT + OPERAND_TYPES : INT, INT, INT, INT + SPECIAL_CASES : NORMAL + + +Test Case 7 (Key = 1.2.2.2.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : PLUS, MULTIPLY, MINUS, PLUS, DIVIDE + PRECEDENCE_FOCUS : MIXED_PRECEDENCE + OPERAND_TYPES : INT + SPECIAL_CASES : NORMAL + + +Test Case 8 (Key = 1.3.1.1.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : PLUS THEN MULTIPLY + PRECEDENCE_FOCUS : MULTIPLY_OVER_PLUS + OPERAND_TYPES : INT, INT, INT + SPECIAL_CASES : NORMAL + + +Test Case 9 (Key = 1.3.1.2.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : MULTIPLY_WITH_ZERO AND PLUS + PRECEDENCE_FOCUS : MULTIPLY_OVER_PLUS + SPECIAL_CASES : MULTIPLY_BY_ZERO + + +Test Case 10 (Key = 1.3.2.1.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : PLUS THEN MULTIPLY + PRECEDENCE_FOCUS : UNARY_MINUS_BINDING + OPERAND_TYPES : INT, INT, INT + SPECIAL_CASES : UNARY_MINUS + + +Test Case 11 (Key = 1.3.2.2.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : PLUS THEN MULTIPLY + PRECEDENCE_FOCUS : PARENTHESES_AND_UNARY_MINUS + OPERAND_TYPES : INT + SPECIAL_CASES : NEGATIVE_OPERANDS_WITH_PARENS + + +Test Case 12 (Key = 1.4.1.1.) + FEATURE : ARITHMETIC_EXPRESSION + OPERATORS : PLUS_IN_PARENS THEN MULTIPLY THEN PLUS + PRECEDENCE_FOCUS : PARENTHESES_OVERRIDE_PRECEDENCE + SPECIAL_CASES : NESTED_EXPRESSION + + +Test Case 13 (Key = 2.1.1.1.) + FEATURE : STDLIB_FUNCTION + FUNCTION_NAME : sqrt + ARG_COUNT : ONE + ARG_TYPES : INT + ARG_VALUE_CLASS : PERFECT_SQUARE (9) + EXPECTED_RETURN_TYPE : FLOAT + SPECIAL_CASES : NORMAL + + +Test Case 14 (Key = 2.1.1.2.) + FEATURE : STDLIB_FUNCTION + FUNCTION_NAME : pow + ARG_COUNT : TWO + ARG_TYPES : INT, INT + EXPECTED_RETURN_TYPE : FLOAT + SPECIAL_CASES : NORMAL + + +Test Case 15 (Key = 2.1.2.1.) + FEATURE : STDLIB_FUNCTION + FUNCTION_NAME : ceil + ARG_COUNT : ONE + EXPECTED_RETURN_TYPE : INT + SPECIAL_CASES : NORMAL + + +Test Case 16 (Key = 2.1.2.2.) + FEATURE : STDLIB_FUNCTION + FUNCTION_NAME : floor + ARG_COUNT : ONE + ARG_TYPES : FLOAT + SPECIAL_CASES : NORMAL + + +Test Case 17 (Key = 2.2.1.1.) + FEATURE : STDLIB_FUNCTION + FUNCTION_NAME : abs + ARG_COUNT : ONE + ARG_TYPES : INT + SPECIAL_CASES : NORMAL + + +Test Case 18 (Key = 2.2.1.2.) + FEATURE : STDLIB_FUNCTION + FUNCTION_NAME : abs + ARG_COUNT : ONE + ARG_TYPES : INT + SPECIAL_CASES : NORMAL diff --git a/249039503/test/blackbox/category_partitioning/nest_math_oper_test b/249039503/test/blackbox/category_partitioning/nest_math_operations_test similarity index 100% rename from 249039503/test/blackbox/category_partitioning/nest_math_oper_test rename to 249039503/test/blackbox/category_partitioning/nest_math_operations_test diff --git a/249039503/test/blackbox/category_partitioning/nest_math_operations_test.tsl b/249039503/test/blackbox/category_partitioning/nest_math_operations_test.tsl new file mode 100644 index 00000000..e69de29b diff --git a/249039503/test/whitebox/branch_testing/arithmetic_operations.py b/249039503/test/whitebox/branch_testing/arithmetic_operations.py index 4b0f0040..6da5a731 100644 --- a/249039503/test/whitebox/branch_testing/arithmetic_operations.py +++ b/249039503/test/whitebox/branch_testing/arithmetic_operations.py @@ -12,56 +12,43 @@ def run(code: str): class ArithmeticOperationsBranchTest(unittest.TestCase): # PLUS - def test_plus_int_int(self): + def test_plus_int_int_1(self): self.assertEqual(run("1 + 2;"), 3) - def test_plus_float_float(self): + def test_plus_float_float_2(self): self.assertAlmostEqual(run("1.5 + 2.25;"), 3.75) - def test_plus_int_float(self): + def test_plus_int_float_3(self): self.assertAlmostEqual(run("1 + 2.5;"), 3.5) - def test_plus_float_int(self): + def test_plus_float_int_4(self): self.assertAlmostEqual(run("2.5 + 1;"), 3.5) # MINUS - def test_minus_int_int(self): + def test_minus_int_int_5(self): self.assertEqual(run("5 - 2;"), 3) - def test_minus_unary(self): + def test_minus_unary_6(self): self.assertEqual(run("-5;"), -5) # MULTIPLY - def test_multiply_int_int(self): + def test_multiply_int_int_7(self): self.assertEqual(run("3 * 4;"), 12) - def test_multiply_float_int(self): + def test_multiply_float_int_8(self): self.assertAlmostEqual(run("2.5 * 4;"), 10.0) # DIVIDE - def test_divide_int_int_exact(self): + def test_divide_int_int_exact_9(self): self.assertEqual(run("10 / 2;"), 5) - def test_divide_float(self): + def test_divide_float_10(self): self.assertAlmostEqual(run("7.5 / 2.5;"), 3.0) - def test_divide_by_zero_raises(self): + def test_divide_by_zero_raises_11(self): with self.assertRaises(Exception): run("10 / 0;") - def test_divide_by_zero_float_raises(self): + def test_divide_by_zero_float_raises_12(self): with self.assertRaises(Exception): run("10.0 / 0.0;") - - # PARSER BRANCHES - def test_precedence_mul_before_add(self): - self.assertEqual(run("1 + 2 * 3;"), 7) - - def test_parentheses_override_precedence(self): - self.assertEqual(run("(1 + 2) * 3;"), 9) - - def test_left_associative_subtraction(self): - self.assertEqual(run("10 - 3 - 2;"), 5) - - def test_left_associative_division(self): - self.assertEqual(run("20 / 2 / 2;"), 5) diff --git a/249039503/test/whitebox/branch_testing/break_loop.py b/249039503/test/whitebox/branch_testing/break_loop.py index 9a40ec21..7de1df4a 100644 --- a/249039503/test/whitebox/branch_testing/break_loop.py +++ b/249039503/test/whitebox/branch_testing/break_loop.py @@ -11,7 +11,7 @@ def run(code: str): class BreakLoopBranchTest(unittest.TestCase): - def test_break_exits_loop_immediately(self): + def test_break_exits_loop_immediately_1(self): code = """ for (let i = 0; i < 10; i = i + 1) { break; @@ -21,7 +21,7 @@ def test_break_exits_loop_immediately(self): """ self.assertEqual(run(code), 0) - def test_break_after_some_iterations(self): + def test_break_after_some_iterations_2(self): code = """ let out = 0; for (let i = 0; i < 10; i = i + 1) { @@ -32,7 +32,7 @@ def test_break_after_some_iterations(self): """ self.assertEqual(run(code), 3) - def test_zero_iterations_condition_false_initially(self): + def test_zero_iterations_condition_false_3(self): code = """ let out = 123; for (let i = 0; i < 0; i = i + 1) { @@ -42,7 +42,7 @@ def test_zero_iterations_condition_false_initially(self): """ self.assertEqual(run(code), 123) - def test_break_in_nested_loop_breaks_inner_only(self): + def test_break_in_nested_loop_breaks_4(self): code = """ let outer = 0; for (let o = 0; o < 2; o = o + 1) { @@ -55,6 +55,6 @@ def test_break_in_nested_loop_breaks_inner_only(self): """ self.assertEqual(run(code), 2) - def test_break_outside_loop_raises(self): + def test_break_outside_loop_5(self): with self.assertRaises(Exception): run("break;") diff --git a/249039503/test/whitebox/branch_testing/comments_writing.py b/249039503/test/whitebox/branch_testing/comments_writing.py index 32c82512..8d66f052 100644 --- a/249039503/test/whitebox/branch_testing/comments_writing.py +++ b/249039503/test/whitebox/branch_testing/comments_writing.py @@ -11,25 +11,25 @@ def run(code: str): class CommentsWritingBranchTest(unittest.TestCase): - def test_line_comment_ignored(self): + def test_line_comment_1(self): code = """ // full line comment 1 + 2; """ self.assertEqual(run(code), 3) - def test_line_comment_after_expression(self): + def test_line_comment_after_expression_2(self): code = "1 + 2; // trailing comment" self.assertEqual(run(code), 3) - def test_line_comment_after_statement_followed_by_new_statement(self): + def test_line_comment_after_statement_followed_by_new_statement_3(self): code = """ 1 + 2; // comment 3; """ self.assertEqual(run(code), 3) - def test_comments_between_statements(self): + def test_comments_between_statements_4(self): code = """ let x = 1; // mid @@ -39,7 +39,7 @@ def test_comments_between_statements(self): """ self.assertEqual(run(code), 3) - def test_comment_markers_inside_string_not_comment(self): + def test_comment_markers_inside_string_not_comment_5(self): code = r""" let s = "not a // comment"; 1 + 2; diff --git a/249039503/test/whitebox/branch_testing/exit_statement.py b/249039503/test/whitebox/branch_testing/exit_statement.py index 759513cb..9ffcfbc7 100644 --- a/249039503/test/whitebox/branch_testing/exit_statement.py +++ b/249039503/test/whitebox/branch_testing/exit_statement.py @@ -11,16 +11,16 @@ def run(code: str): class ExitStatementBranchTest(unittest.TestCase): - def test_exit_with_code_int_returns_code(self): + def test_exit_with_int_1(self): self.assertEqual(run("exit(7);"), 7) - def test_exit_zero_returns_zero(self): + def test_exit_zero_returns_zero_2(self): self.assertEqual(run("exit(0);"), 0) - def test_exit_negative_returns_negative(self): + def test_exit_negative_3(self): self.assertEqual(run("exit(-1);"), -1) - def test_exit_inside_if_returns_code(self): + def test_exit_inside_if_returns_code_3(self): code = """ if (1 < 2) { exit(3); @@ -28,7 +28,7 @@ def test_exit_inside_if_returns_code(self): """ self.assertEqual(run(code), 3) - def test_exit_inside_loop_returns_code(self): + def test_exit_inside_loop_4(self): code = """ for (let i = 0; i < 3; i = i + 1) { exit(5); @@ -36,10 +36,10 @@ def test_exit_inside_loop_returns_code(self): """ self.assertEqual(run(code), 5) - def test_exit_missing_argument_raises(self): + def test_exit_no_argument_5(self): with self.assertRaises(Exception): run("exit();") - def test_exit_non_int_argument_raises(self): + def test_exit_non_int_arg_6(self): with self.assertRaises(Exception): run('exit("1");') diff --git a/249039503/test/whitebox/branch_testing/integer_reading_and_storing.py b/249039503/test/whitebox/branch_testing/integer_reading_and_storing.py index 443d05bd..7a34956b 100644 --- a/249039503/test/whitebox/branch_testing/integer_reading_and_storing.py +++ b/249039503/test/whitebox/branch_testing/integer_reading_and_storing.py @@ -11,14 +11,14 @@ def run(code: str): class IntegerReadingAndStoringBranchTest(unittest.TestCase): - def test_let_store_and_read(self): + def test_let_store_1(self): code = """ let x = 10; x; """ self.assertEqual(run(code), 10) - def test_reassign_overwrites_value(self): + def test_overwrites_value_2(self): code = """ let x = 10; x = 20; @@ -26,7 +26,7 @@ def test_reassign_overwrites_value(self): """ self.assertEqual(run(code), 20) - def test_read_used_in_expression(self): + def test_in_expression_3(self): code = """ let x = 10; let y = 5; @@ -34,7 +34,7 @@ def test_read_used_in_expression(self): """ self.assertEqual(run(code), 15) - def test_reassign_used_in_expression(self): + def test_reassign_used_in_expression_4(self): code = """ let x = 1; x = x + 2; @@ -42,17 +42,17 @@ def test_reassign_used_in_expression(self): """ self.assertEqual(run(code), 3) - def test_read_undefined_variable_raises(self): + def test_read_undefined_variable_raises_5(self): with self.assertRaises(Exception) as ctx: run("x;") self.assertIn("Undefined", str(ctx.exception)) - def test_assign_undefined_variable_raises(self): + def test_assign_undefined_variable_raises_6(self): with self.assertRaises(Exception) as ctx: run("x = 1;") self.assertIn("Undefined", str(ctx.exception)) - def test_shadowing_in_block_if_supported(self): + def test_shadowing_in_block_if_supported_7(self): code = """ let x = 10; if (1 < 2) { diff --git a/249039503/test/whitebox/branch_testing/logical_error.py b/249039503/test/whitebox/branch_testing/logical_error.py index 79535b19..b8b0044f 100644 --- a/249039503/test/whitebox/branch_testing/logical_error.py +++ b/249039503/test/whitebox/branch_testing/logical_error.py @@ -11,40 +11,38 @@ def run(code: str): class LogicalErrorBranchTest(unittest.TestCase): - # --- arithmetic correctness branches --- - def test_division_basic(self): + # arithmetic correctness branches + def test_division_basic_1(self): self.assertEqual(run("10 / 2;"), 5) - def test_division_left_associative(self): - # (20/2)/2 = 5 (not 20/(2/2)=20) + def test_division_left_associative_2(self): self.assertEqual(run("20 / 2 / 2;"), 5) - def test_precedence_mul_before_add(self): + def test_precedence_mul_before_add_3(self): self.assertEqual(run("1 + 2 * 3;"), 7) - def test_parentheses_override_precedence(self): + def test_parentheses_override_precedence_4(self): self.assertEqual(run("(1 + 2) * 3;"), 9) - def test_nested_parentheses(self): + def test_nested_parentheses_4(self): self.assertEqual(run("((1 + 2) * (3 + 4));"), 21) - # --- runtime error branches --- - def test_division_by_zero_raises(self): + # runtime error branches + def test_division_by_zero_raises_5(self): with self.assertRaises(Exception): run("10 / 0;") - def test_undefined_variable_raises(self): + def test_undefined_variable_raises_6(self): with self.assertRaises(Exception) as ctx: run("x;") - # accept both message variants msg = str(ctx.exception) self.assertTrue(("Undefined variable" in msg) or ("Undefined" in msg)) - # --- parser/syntax error branches --- - def test_missing_closing_parenthesis_raises(self): + # parser/syntax error branches + def test_missing_closing_parenthesis_raises_7(self): with self.assertRaises(Exception): run("1 + (2 * (3 + 4);") - def test_operator_missing_rhs_raises(self): + def test_operator_missing_rhs_raises_8(self): with self.assertRaises(Exception): run("1 + ;") diff --git a/249039503/test/whitebox/branch_testing/nest_math_operations.py b/249039503/test/whitebox/branch_testing/nest_math_operations.py index 4cf756a4..b568cb24 100644 --- a/249039503/test/whitebox/branch_testing/nest_math_operations.py +++ b/249039503/test/whitebox/branch_testing/nest_math_operations.py @@ -11,37 +11,31 @@ def run(code: str): class NestMathOperationsBranchTest(unittest.TestCase): - def test_simple_nested_add_mul(self): - # 1 + (2 * 3) = 7 + def test_simple_nested_add_mul_1(self): self.assertEqual(run("1 + (2 * 3);"), 7) - def test_deeply_nested_parentheses(self): - # (((1 + 2) * 3) - 4) = 5 + def test_deeply_nested_parentheses_2(self): self.assertEqual(run("(((1 + 2) * 3) - 4);"), 5) - def test_nested_mixed_precedence(self): - # (1 + 2) * (3 + 4) = 21 + def test_nested_mixed_precedence_3(self): self.assertEqual(run("(1 + 2) * (3 + 4);"), 21) - def test_nested_unary_inside(self): + def test_nested_unary_inside_4(self): self.assertEqual(run("-(2 * (3 + 1));"), 8) - def test_unary_and_binary_chain(self): - # -1 - (2 * -3) = -1 - (-6) = 5 + def test_unary_and_binary_chain_5(self): self.assertEqual(run("-1 - (2 * -3);"), 5) - def test_nested_division_associativity(self): - # (20 / (2 * 2)) = 5 + def test_nested_division_associativity_6(self): self.assertEqual(run("20 / (2 * 2);"), 5) - def test_left_associative_without_parentheses(self): - # ((10 - 3) - 2) = 5 + def test_left_associative_without_parentheses_7(self): self.assertEqual(run("10 - 3 - 2;"), 5) - def test_missing_closing_parenthesis_raises(self): + def test_missing_closing_parenthesis_raises_8(self): with self.assertRaises(Exception): run("1 + (2 * (3 + 4);") - def test_operator_after_open_paren_raises(self): + def test_operator_after_open_paren_raises_9(self): with self.assertRaises(Exception): run("(+ 2);") diff --git a/249039503/test/whitebox/branch_testing/type_functions.py b/249039503/test/whitebox/branch_testing/type_functions.py index a6a76d5e..db6705b0 100644 --- a/249039503/test/whitebox/branch_testing/type_functions.py +++ b/249039503/test/whitebox/branch_testing/type_functions.py @@ -19,37 +19,37 @@ def assert_type_str(testcase: unittest.TestCase, value, expected_keywords): class TypeFunctionBranchTest(unittest.TestCase): - def test_type_int_literal(self): + def test_type_int_literal_1(self): v = run("type(1);") assert_type_str(self, v, ("int", "integer", "number")) - def test_type_float_literal(self): + def test_type_float_literal_2(self): v = run("type(1.5);") assert_type_str(self, v, ("float", "double", "number")) - def test_type_bool_literal(self): + def test_type_bool_literal_3(self): v = run("type(true);") assert_type_str(self, v, ("bool", "boolean")) - def test_type_string_literal(self): + def test_type_string_literal_4(self): v = run('type("x");') assert_type_str(self, v, ("string", "str")) - def test_type_char_literal_if_supported(self): + def test_type_char_literal_if_supported_5(self): try: v = run("type('a');") assert_type_str(self, v, ("char", "character", "string")) except Exception: pass - def test_type_identifier(self): + def test_type_identifier_6(self): v = run("let x = 10; type(x);") assert_type_str(self, v, ("int", "integer", "number")) - def test_type_wrong_arity_zero_args_raises(self): + def test_type_wrong_arity_zero_args_raises_7(self): with self.assertRaises(Exception): run("type();") - def test_type_wrong_arity_two_args_raises(self): + def test_type_wrong_arity_two_args_raises_8(self): with self.assertRaises(Exception): run("type(1, 2);") diff --git a/249039503/test/whitebox/concolic_testing/type_function.py b/249039503/test/whitebox/concolic_testing/type_function.py new file mode 100644 index 00000000..1311593b --- /dev/null +++ b/249039503/test/whitebox/concolic_testing/type_function.py @@ -0,0 +1,56 @@ +import unittest +from src.lexer import Lexer +from src.parser import Parser +from src.evaluator import evaluate + +# Here I did concolic testing for type() function. Combine some statements to showing how program works. +# For input comes f.e. type(10) which do path (Lexer -> Parser -> Evaluator) +# In every Run we use concrete argument and save it. +# In this function we can see this path: +# Checking amount of arguments +# If argument is identifier, program checks is it created in environment +# identifier defined +# identifier undefined +# Identifying type of var. + + +def eval_program(program: str): + parser = Parser(Lexer(program)) + stmts = parser.run() + return evaluate(stmts) + + +class ConcolicTypeFunctionTests(unittest.TestCase): + def test_T0_seed_int(self): + self.assertEqual(eval_program("type(10);"), "integer") + + def test_T1_negate_arity_zero_args(self): + with self.assertRaises(Exception): + eval_program("type();") + + def test_T2_negate_arity_many_args(self): + with self.assertRaises(Exception): + eval_program("type(1, 2);") + + def test_T3_negate_value_type_float(self): + self.assertEqual(eval_program("type(3.14);"), "float") + + def test_T4_negate_value_type_bool(self): + self.assertEqual(eval_program("type(true);"), "boolean") + + def test_T5_negate_value_type_string(self): + self.assertEqual(eval_program('type("hello");'), "string") + + def test_T6_negate_identifier_defined(self): + with self.assertRaises(Exception): + eval_program("type(x);") + + def test_T7_identifier_defined_via_let(self): + self.assertEqual(eval_program("let x = 10; type(x);"), "integer") + + def test_T8_function_identifier(self): + self.assertEqual(eval_program("fn f(){ return 1; }; type(f);"), "function") + + +if __name__ == "__main__": + unittest.main() diff --git a/249039503/test/whitebox/condition_testing/arithmetic_operations.py b/249039503/test/whitebox/condition_testing/arithmetic_operations.py index 022e130c..621dc2eb 100644 --- a/249039503/test/whitebox/condition_testing/arithmetic_operations.py +++ b/249039503/test/whitebox/condition_testing/arithmetic_operations.py @@ -24,11 +24,6 @@ def test_division_right_zero_int_raises(self): run("10/0;") self.assertIn("Division by zero", str(ctx.exception)) - def test_division_right_zero_float_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - run("10.0/0.0;") - self.assertIn("Division by zero", str(ctx.exception)) - def test_division_right_nonzero_float(self): self.assertEqual(run("7.5/2.5;"), 3.0) @@ -42,7 +37,6 @@ def test_multiply_int_int(self): self.assertEqual(run("3*4;"), 12) def test_plus_int_float(self): - # Python semantics: int + float -> float self.assertEqual(run("1+2.5;"), 3.5) def test_multiply_float_int(self): diff --git a/249039503/test/whitebox/condition_testing/integer_reading_and_storing.py b/249039503/test/whitebox/condition_testing/integer_reading_and_storing.py index 1e4c65bb..9a272dc9 100644 --- a/249039503/test/whitebox/condition_testing/integer_reading_and_storing.py +++ b/249039503/test/whitebox/condition_testing/integer_reading_and_storing.py @@ -11,58 +11,20 @@ def evaluate_expr(program: str): class TestIntegerReadAndStoreCondition(unittest.TestCase): - def test_isInt_numeric_string_true(self): + def test_isInt_numeric_string_true_1(self): self.assertEqual(evaluate_expr('isInt("123");'), True) - def test_isInt_non_numeric_string_false(self): + def test_isInt_non_numeric_string_false_2(self): self.assertEqual(evaluate_expr('isInt("12a");'), False) - def test_isInt_empty_string_false(self): - self.assertEqual(evaluate_expr('isInt("");'), False) - - def test_isInt_wrong_arity_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr('isInt("1", "2");') - self.assertIn("is_int expects 1 argument", str(ctx.exception)) - - def test_isInt_non_string_raises(self): - with self.assertRaises(Exception): - evaluate_expr("isInt(123);") - - def test_toInt_from_numeric_string_success(self): - self.assertEqual(evaluate_expr('toInt("42");'), 42) - - def test_toInt_from_int_success(self): - self.assertEqual(evaluate_expr("toInt(7);"), 7) - - def test_toInt_from_float_truncates_like_python(self): + def test_toInt_from_float_truncates_like_python_3(self): self.assertEqual(evaluate_expr("toInt(3.9);"), 3) - def test_toInt_from_non_numeric_string_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr('toInt("4a");') - self.assertIn("Cannot convert value to int", str(ctx.exception)) - - def test_toInt_wrong_arity_raises(self): + def test_toInt_wrong_arity_raises_4(self): with self.assertRaises(RuntimeEvaluationError) as ctx: evaluate_expr("toInt();") self.assertIn("to_int expects 1 argument", str(ctx.exception)) - def test_store_converted_int_in_variable(self): - program = """ - let x = toInt("10"); - x; - """ - self.assertEqual(evaluate_expr(program), 10) - - def test_update_variable_with_int_value(self): - program = """ - let x = toInt("10"); - x = x + 5; - x; - """ - self.assertEqual(evaluate_expr(program), 15) - if __name__ == "__main__": unittest.main() diff --git a/249039503/test/whitebox/condition_testing/logical_error.py b/249039503/test/whitebox/condition_testing/logical_error.py index 73258272..7a0a7012 100644 --- a/249039503/test/whitebox/condition_testing/logical_error.py +++ b/249039503/test/whitebox/condition_testing/logical_error.py @@ -16,20 +16,6 @@ def test_undefined_variable_read_raises(self): evaluate_expr("x;") self.assertIn("Undefined variable 'x'", str(ctx.exception)) - def test_undefined_variable_assignment_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr("x = 1;") - self.assertIn("Undefined variable 'x'", str(ctx.exception)) - - def test_redeclare_constant_in_same_scope_raises(self): - program = """ - const x = 1; - const x = 2; - """ - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr(program) - self.assertIn("Cannot redeclare constant 'x'", str(ctx.exception)) - def test_assign_to_constant_raises(self): program = """ const x = 1; @@ -39,14 +25,6 @@ def test_assign_to_constant_raises(self): evaluate_expr(program) self.assertIn("Cannot assign to constant 'x'", str(ctx.exception)) - def test_assignment_lhs_not_identifier_raises(self): - program = "(1 + 2) = 3;" - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr(program) - self.assertIn( - "Left-hand side of assignment must be a variable", str(ctx.exception) - ) - def test_break_outside_loop_raises(self): with self.assertRaises(RuntimeEvaluationError) as ctx: evaluate_expr("break;") @@ -57,14 +35,6 @@ def test_continue_outside_loop_raises(self): evaluate_expr("continue;") self.assertIn("continue used outside loop", str(ctx.exception)) - def test_let_variable_ok_then_assign_ok(self): - program = """ - let x = 1; - x = 2; - x; - """ - self.assertEqual(evaluate_expr(program), 2) - def test_shadowing_constant_in_inner_scope_is_allowed(self): program = """ let x = 1; diff --git a/249039503/test/whitebox/loop_testing/arithmetic_operations.py b/249039503/test/whitebox/loop_testing/arithmetic_operations.py index 5db2e9b0..f14a506f 100644 --- a/249039503/test/whitebox/loop_testing/arithmetic_operations.py +++ b/249039503/test/whitebox/loop_testing/arithmetic_operations.py @@ -11,20 +11,19 @@ def evaluate_expr(program: str): class TestArithmeticOperationsLoopTesting(unittest.TestCase): - # Case 1: Zero arithmetic operations + # Zero arithmetic operations def test_zero_operations_single_literal(self): self.assertEqual(evaluate_expr("5;"), 5) - # Case 2: One arithmetic operation + # One arithmetic operation def test_one_operation(self): self.assertEqual(evaluate_expr("5 + 2;"), 7) - # Case 3: Multiple arithmetic operations + # Multiple arithmetic operations def test_multiple_operations_chain(self): - # 3 operators: +, *, - self.assertEqual(evaluate_expr("1 + 2 * 3 - 4;"), 3) - # Another many case + # many case def test_multiple_operations_nested(self): self.assertEqual(evaluate_expr("(1 + 2) * (3 + 4);"), 21) diff --git a/249039503/test/whitebox/loop_testing/break_loop.py b/249039503/test/whitebox/loop_testing/break_loop.py index 77c48eb5..b8aec69b 100644 --- a/249039503/test/whitebox/loop_testing/break_loop.py +++ b/249039503/test/whitebox/loop_testing/break_loop.py @@ -11,7 +11,7 @@ def evaluate_expr(program: str): class TestBreakLoopTesting(unittest.TestCase): - # Case 1: Zero iterations + # Zero iterations def test_break_zero_iterations(self): program = """ for(let i = 0; i < 0; i = i + 1) { @@ -21,7 +21,7 @@ def test_break_zero_iterations(self): """ self.assertEqual(evaluate_expr(program), 0) - # Case 2: One iteration + # 1 iteration def test_break_one_iteration(self): program = """ for(let i = 0; i < 5; i = i + 1) { @@ -31,7 +31,7 @@ def test_break_one_iteration(self): """ self.assertEqual(evaluate_expr(program), 0) - # Case 3: Multiple iterations + # Multiple iterations def test_break_multiple_iterations(self): program = """ for(let i = 0; i < 10; i = i + 1) { diff --git a/249039503/test/whitebox/loop_testing/exit_statement.py b/249039503/test/whitebox/loop_testing/exit_statement.py index dcfd1292..a5749f2b 100644 --- a/249039503/test/whitebox/loop_testing/exit_statement.py +++ b/249039503/test/whitebox/loop_testing/exit_statement.py @@ -11,11 +11,11 @@ def evaluate_expr(program: str): class TestExitStatementLoopTesting(unittest.TestCase): - # Case 1: Zero statements before exit + # Zero statements before exit def test_exit_zero_statements(self): self.assertEqual(evaluate_expr("exit(1);"), 1) - # Case 2: One statement before exit + # 1 statement before exit def test_exit_one_statement(self): program = """ let x = 10; @@ -23,7 +23,7 @@ def test_exit_one_statement(self): """ self.assertEqual(evaluate_expr(program), 2) - # Case 3: Multiple statements before exit + # Multiple statements before exit def test_exit_multiple_statements(self): program = """ let x = 1; diff --git a/249039503/test/whitebox/loop_testing/integer_reading_and_storing.py b/249039503/test/whitebox/loop_testing/integer_reading_and_storing.py index d539a669..8286d8ad 100644 --- a/249039503/test/whitebox/loop_testing/integer_reading_and_storing.py +++ b/249039503/test/whitebox/loop_testing/integer_reading_and_storing.py @@ -11,7 +11,7 @@ def evaluate_expr(program: str): class TestIntegerReadingAndStoringLoopTesting(unittest.TestCase): - # Case 1: Zero conversions/stores + # Zero conversions/stores def test_zero_conversions_store_direct_int(self): program = """ let x = 5; @@ -19,7 +19,7 @@ def test_zero_conversions_store_direct_int(self): """ self.assertEqual(evaluate_expr(program), 5) - # Case 2: One conversion/store + # One conversion/store def test_one_conversion_and_store(self): program = """ let x = toInt("10"); @@ -27,7 +27,7 @@ def test_one_conversion_and_store(self): """ self.assertEqual(evaluate_expr(program), 10) - # Case 3: Multiple conversions/stores + # Multiple conversions/stores def test_multiple_conversions_and_stores(self): program = """ let a = toInt("1"); diff --git a/249039503/test/whitebox/loop_testing/logical_error.py b/249039503/test/whitebox/loop_testing/logical_error.py index aef09360..e1b22533 100644 --- a/249039503/test/whitebox/loop_testing/logical_error.py +++ b/249039503/test/whitebox/loop_testing/logical_error.py @@ -11,7 +11,7 @@ def evaluate_expr(program: str): class TestLogicalErrorLoopTesting(unittest.TestCase): - # Case 1: Zero logical errors + # Zero logical errors def test_zero_errors(self): program = """ let x = 1; @@ -20,27 +20,24 @@ def test_zero_errors(self): """ self.assertEqual(evaluate_expr(program), 2) - # Case 2: One logical error + # One logical error def test_one_error_undefined_variable(self): program = "x;" with self.assertRaises(RuntimeEvaluationError) as ctx: evaluate_expr(program) self.assertIn("Undefined variable 'x'", str(ctx.exception)) - # Case 3: Multiple logical errors + # Multiple logical errors def test_multiple_errors_across_programs(self): - # Error 1: undefined variable read with self.assertRaises(RuntimeEvaluationError): evaluate_expr("y;") - # Error 2: assign to const with self.assertRaises(RuntimeEvaluationError): evaluate_expr(""" const a = 1; a = 2; """) - # Error 3: break outside loop with self.assertRaises(RuntimeEvaluationError): evaluate_expr("break;") diff --git a/249039503/test/whitebox/loop_testing/math_operations.py b/249039503/test/whitebox/loop_testing/math_operations.py index 1c82c515..000fe686 100644 --- a/249039503/test/whitebox/loop_testing/math_operations.py +++ b/249039503/test/whitebox/loop_testing/math_operations.py @@ -11,17 +11,17 @@ def evaluate_expr(program: str): class TestMathOperationsLoopTesting(unittest.TestCase): - # Case 1: Zero math operations + # Zero math operations def test_zero_math_operations(self): program = "1 + 2;" self.assertEqual(evaluate_expr(program), 3) - # Case 2: One math operation + # One math operation def test_one_math_operation(self): program = "sqrt(9);" self.assertEqual(evaluate_expr(program), 3.0) - # Case 3: Multiple math operations + # Multiple math operations def test_multiple_math_operations(self): program = """ let a = sqrt(9); diff --git a/249039503/test/whitebox/loop_testing/nest_math_operations.py b/249039503/test/whitebox/loop_testing/nest_math_operations.py index 2ea65b55..9ba6d104 100644 --- a/249039503/test/whitebox/loop_testing/nest_math_operations.py +++ b/249039503/test/whitebox/loop_testing/nest_math_operations.py @@ -11,21 +11,19 @@ def evaluate_expr(program: str): class TestNestMathOperationsLoopTesting(unittest.TestCase): - # Case 1: Zero nesting + # Zero nesting def test_zero_nesting(self): program = "1 + 2 * 3;" - # precedence: 1 + (2*3) = 7 self.assertEqual(evaluate_expr(program), 7) - # Case 2: One level of nesting + # One nesting def test_one_level_nesting(self): program = "(1 + 2) * 3;" self.assertEqual(evaluate_expr(program), 9) - # Case 3: Multiple levels of nesting + # Multiple levels of nesting def test_multiple_levels_nesting(self): program = "((1 + 2) * (3 + 4)) - (5 - (1 + 1));" - # ((3) * (7)) - (5 - 2) = 21 - 3 = 18 self.assertEqual(evaluate_expr(program), 18) diff --git a/249039503/test/whitebox/loop_testing/type_function.py b/249039503/test/whitebox/loop_testing/type_function.py index 7f607572..79b360f2 100644 --- a/249039503/test/whitebox/loop_testing/type_function.py +++ b/249039503/test/whitebox/loop_testing/type_function.py @@ -11,7 +11,7 @@ def evaluate_expr(program: str): class TestTypeFunctionLoopTesting(unittest.TestCase): - # Case 1: Zero type() calls + # Zero type() calls def test_zero_type_calls(self): program = """ let x = 5; @@ -19,12 +19,12 @@ def test_zero_type_calls(self): """ self.assertEqual(evaluate_expr(program), 5) - # Case 2: One type() call + # One type() call def test_one_type_call(self): program = "type(10);" self.assertEqual(evaluate_expr(program), "integer") - # Case 3: Multiple type() calls + # Multiple type() calls def test_multiple_type_calls(self): program = """ let a = type(1); diff --git a/249039503/test/blackbox/mutation_testing/mutation_testing_results.txt b/249039503/test/whitebox/mutation_testing/mutation_testing_results.txt similarity index 100% rename from 249039503/test/blackbox/mutation_testing/mutation_testing_results.txt rename to 249039503/test/whitebox/mutation_testing/mutation_testing_results.txt diff --git a/249039503/test/blackbox/mutation_testing/test_src_evaluator.py b/249039503/test/whitebox/mutation_testing/test_src_evaluator.py similarity index 100% rename from 249039503/test/blackbox/mutation_testing/test_src_evaluator.py rename to 249039503/test/whitebox/mutation_testing/test_src_evaluator.py diff --git a/249039503/test/whitebox/statement_testing/arithmetic_operations.py b/249039503/test/whitebox/statement_testing/arithmetic_operations.py deleted file mode 100644 index 75614b0f..00000000 --- a/249039503/test/whitebox/statement_testing/arithmetic_operations.py +++ /dev/null @@ -1,56 +0,0 @@ -import unittest - -from src.lexer import Lexer -from src.parser import Parser -from src.evaluator import evaluate, RuntimeEvaluationError - - -def evaluate_expr(program: str): - expressions = Parser(Lexer(program)).run() - return evaluate(expressions) - - -class TestArithmeticOperationsStatement(unittest.TestCase): - def test_int_literal(self): - self.assertEqual(evaluate_expr("5;"), 5) - - def test_float_literal(self): - self.assertEqual(evaluate_expr("1.5;"), 1.5) - - def test_prefix_minus(self): - self.assertEqual(evaluate_expr("-5;"), -5) - - def test_prefix_plus(self): - self.assertEqual(evaluate_expr("+5;"), 5) - - def test_prefix_not(self): - self.assertEqual(evaluate_expr("!null;"), True) - - def test_infix_plus(self): - self.assertEqual(evaluate_expr("1 + 2;"), 3) - - def test_infix_minus(self): - self.assertEqual(evaluate_expr("5 - 8;"), -3) - - def test_infix_multiply(self): - self.assertEqual(evaluate_expr("3 * 4;"), 12) - - def test_infix_divide_nonzero(self): - self.assertEqual(evaluate_expr("10 / 2;"), 5) - - def test_division_by_zero_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr("10 / 0;") - self.assertIn("Division by zero", str(ctx.exception)) - - def test_bitwise_and_ints(self): - self.assertEqual(evaluate_expr("5 & 3;"), 1) - - def test_bitwise_requires_integers_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr("1.5 & 1;") - self.assertIn("Bitwise operations require integers", str(ctx.exception)) - - -if __name__ == "__main__": - unittest.main() diff --git a/249039503/test/whitebox/statement_testing/break_loop.py b/249039503/test/whitebox/statement_testing/break_loop.py deleted file mode 100644 index 2253a05a..00000000 --- a/249039503/test/whitebox/statement_testing/break_loop.py +++ /dev/null @@ -1,39 +0,0 @@ -import unittest - -from src.lexer import Lexer -from src.parser import Parser -from src.evaluator import evaluate, RuntimeEvaluationError - - -def evaluate_expr(program: str): - expressions = Parser(Lexer(program)).run() - return evaluate(expressions) - - -class TestBreakLoopStatement(unittest.TestCase): - def test_for_zero_iterations(self): - program = """ - for(let i = 0; i < 0; i = i + 1) { - break; - } - i; - """ - self.assertEqual(evaluate_expr(program), 0) - - def test_break_exits_loop(self): - program = """ - for(let i = 0; i < 5; i = i + 1) { - break; - } - i; - """ - self.assertEqual(evaluate_expr(program), 0) - - def test_break_outside_loop_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr("break;") - self.assertIn("break used outside loop", str(ctx.exception)) - - -if __name__ == "__main__": - unittest.main() diff --git a/249039503/test/whitebox/statement_testing/logical_error.py b/249039503/test/whitebox/statement_testing/logical_error.py deleted file mode 100644 index 1f5a10d0..00000000 --- a/249039503/test/whitebox/statement_testing/logical_error.py +++ /dev/null @@ -1,45 +0,0 @@ -import unittest - -from src.lexer import Lexer -from src.parser import Parser -from src.evaluator import evaluate, RuntimeEvaluationError - - -def evaluate_expr(program: str): - expressions = Parser(Lexer(program)).run() - return evaluate(expressions) - - -class TestLogicalErrorStatement(unittest.TestCase): - def test_undefined_variable_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr("x;") - self.assertIn("Undefined variable", str(ctx.exception)) - - def test_assignment_lhs_not_identifier_raises(self): - program = "(1 + 2) = 3;" - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr(program) - self.assertIn( - "Left-hand side of assignment must be a variable", - str(ctx.exception), - ) - - def test_division_by_zero_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr("10 / 0;") - self.assertIn("Division by zero", str(ctx.exception)) - - def test_break_outside_loop_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr("break;") - self.assertIn("break used outside loop", str(ctx.exception)) - - def test_continue_outside_loop_raises(self): - with self.assertRaises(RuntimeEvaluationError) as ctx: - evaluate_expr("continue;") - self.assertIn("continue used outside loop", str(ctx.exception)) - - -if __name__ == "__main__": - unittest.main() diff --git a/249039503/test/whitebox/statement_testing/nest_math_operations.py b/249039503/test/whitebox/statement_testing/nest_math_operations.py index 745fa316..24a88f70 100644 --- a/249039503/test/whitebox/statement_testing/nest_math_operations.py +++ b/249039503/test/whitebox/statement_testing/nest_math_operations.py @@ -12,19 +12,15 @@ def evaluate_expr(program: str): class TestNestMathOperationsStatement(unittest.TestCase): def test_nested_parentheses(self): - # 1 + (2 * (3 + 4)) = 1 + (2 * 7) = 15 self.assertEqual(evaluate_expr("1 + (2 * (3 + 4));"), 15) def test_operator_precedence(self): - # 1 + 2 * 3 = 7 self.assertEqual(evaluate_expr("1 + 2 * 3;"), 7) def test_deep_nesting(self): - # ((1+2)+(3+4))*(2+3) = (3+7)*5 = 50 self.assertEqual(evaluate_expr("((1 + 2) + (3 + 4)) * (2 + 3);"), 50) def test_mixed_ops_nested(self): - # (20 / (2 * 2)) - (3 + 1) = (20/4) - 4 = 1 self.assertEqual(evaluate_expr("(20 / (2 * 2)) - (3 + 1);"), 1) def test_missing_closing_paren_raises(self): diff --git a/249039503/test/whitebox/symbolic_testing/type_function.py b/249039503/test/whitebox/symbolic_testing/type_function.py new file mode 100644 index 00000000..34821eff --- /dev/null +++ b/249039503/test/whitebox/symbolic_testing/type_function.py @@ -0,0 +1,10 @@ +import unittest + + +class MyTestCase(unittest.TestCase): + def test_something(self): + self.assertEqual(True, False) # add assertion here + + +if __name__ == "__main__": + unittest.main() diff --git a/249053812/test/whitebox/statement_testing/bmi_calculator.py b/249053812/test/whitebox/statement_testing/bmi_calculator.py index f22b83e1..143e9112 100644 --- a/249053812/test/whitebox/statement_testing/bmi_calculator.py +++ b/249053812/test/whitebox/statement_testing/bmi_calculator.py @@ -10,4 +10,4 @@ def bmi_calculator(weight, height): return "healthy" elif 0 <= bmi < 18.5: return "underweight" - return "error" \ No newline at end of file + return "error" diff --git a/249053812/test/whitebox/statement_testing/test_bmi_calculator.py b/249053812/test/whitebox/statement_testing/test_bmi_calculator.py index 38a3fc63..f31f5786 100644 --- a/249053812/test/whitebox/statement_testing/test_bmi_calculator.py +++ b/249053812/test/whitebox/statement_testing/test_bmi_calculator.py @@ -1,6 +1,7 @@ import unittest from bmi_calculator import BMICalculator + class TestBMICalculator(unittest.TestCase): def testObesity(self): self.assertIn("obesity", BMICalculator().bmi_calculator(85.3, 1.56)) @@ -15,4 +16,4 @@ def testUnderweight(self): self.assertIn("underweight", BMICalculator().bmi_calculator(45.5, 1.6)) def testError(self): - self.assertIn("error", BMICalculator().bmi_calculator(-2, 1.56)) \ No newline at end of file + self.assertIn("error", BMICalculator().bmi_calculator(-2, 1.56))