From b68f999b1fb19703e4f154763f8bdbb8116cf6b8 Mon Sep 17 00:00:00 2001 From: faze-geek Date: Tue, 14 Feb 2023 10:58:18 +0530 Subject: [PATCH 1/2] Add tests --- integration_tests/logical_binop1.py | 96 ++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/integration_tests/logical_binop1.py b/integration_tests/logical_binop1.py index e6b052f8f9..57861d0156 100644 --- a/integration_tests/logical_binop1.py +++ b/integration_tests/logical_binop1.py @@ -1,6 +1,6 @@ from ltypes import i32 -def test_issue_1487_1(): +def test_issue_1487_1(): # OR operator: a or b a : i32 b : i32 x : i32 @@ -20,7 +20,7 @@ def test_issue_1487_1(): assert or_op2 == 0 -def test_issue_1487_2(): +def test_issue_1487_2(): # AND operator: a and b a : i32 b : i32 x : i32 @@ -42,9 +42,99 @@ def test_issue_1487_2(): assert and_op1 == 100 +def test_XOR(): # XOR (exclusive OR) operator: a ^ b + a : i32 + b : i32 + x : i32 + y : i32 + xor_op1 : i32 + xor_op2 : i32 + a = 8 + b = 4 + x = 100 + y = 0 + xor_op1 = b ^ a + xor_op2 = y ^ x + assert xor_op1 == 12 + assert xor_op2 == 100 + + +def test_NOR(): # NOR operator: not(a or b) + a : i32 + b : i32 + x : i32 + y : i32 + nor_op1 : bool + nor_op2 : bool + a = 0 + b = 0 + x = 1 + y = 0 + nor_op1 = not(b or a) + nor_op2 = not(y or x) + assert nor_op1 == True + assert nor_op2 == False + + +def test_NAND(): # NAND operator: not(a and b) + a : i32 + b : i32 + x : i32 + y : i32 + nand_op1 : bool + nand_op2 : bool + a = 0 + b = 0 + x = 1 + y = 1 + nand_op1 = not(b and a) + nand_op2 = not(y and x) + assert nand_op1 == True + assert nand_op2 == False + + +def test_XNOR(): # XNOR operator: == + a : i32 + b : i32 + x : i32 + y : i32 + xnor_op1 : bool + xnor_op2 : bool + a = 0 + b = 0 + x = 1 + y = 0 + xnor_op1 = b == a + xnor_op2 = y == x + assert xnor_op1 == True + assert xnor_op2 == False + + +def test_implies(): # implies operator: <= + a : bool + b : bool + x : bool + y : bool + imp_op1 : bool + imp_op2 : bool + a = True + b = True + x = False + y = True + imp_op1 = b <= a + imp_op2 = y <= x + assert imp_op1 == True + assert imp_op2 == False + + def check(): test_issue_1487_1() test_issue_1487_2() + test_XOR() + test_NOR() + test_NAND() + test_XNOR() + test_implies() -check() +check() \ No newline at end of file From 59697cf6b1182049c242bafda6be4e62499ace4f Mon Sep 17 00:00:00 2001 From: faze-geek Date: Tue, 14 Feb 2023 11:03:37 +0530 Subject: [PATCH 2/2] New_Line --- integration_tests/logical_binop1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/logical_binop1.py b/integration_tests/logical_binop1.py index 57861d0156..e7fe3a43e5 100644 --- a/integration_tests/logical_binop1.py +++ b/integration_tests/logical_binop1.py @@ -137,4 +137,4 @@ def check(): test_implies() -check() \ No newline at end of file +check()