Skip to content

Commit f9322ae

Browse files
authored
Completed test suite for logical binary operators (#1517)
* Add tests * New_Line
1 parent fe33004 commit f9322ae

File tree

1 file changed

+92
-2
lines changed

1 file changed

+92
-2
lines changed

integration_tests/logical_binop1.py

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from ltypes import i32
22

3-
def test_issue_1487_1():
3+
def test_issue_1487_1(): # OR operator: a or b
44
a : i32
55
b : i32
66
x : i32
@@ -20,7 +20,7 @@ def test_issue_1487_1():
2020
assert or_op2 == 0
2121

2222

23-
def test_issue_1487_2():
23+
def test_issue_1487_2(): # AND operator: a and b
2424
a : i32
2525
b : i32
2626
x : i32
@@ -42,9 +42,99 @@ def test_issue_1487_2():
4242
assert and_op1 == 100
4343

4444

45+
def test_XOR(): # XOR (exclusive OR) operator: a ^ b
46+
a : i32
47+
b : i32
48+
x : i32
49+
y : i32
50+
xor_op1 : i32
51+
xor_op2 : i32
52+
a = 8
53+
b = 4
54+
x = 100
55+
y = 0
56+
xor_op1 = b ^ a
57+
xor_op2 = y ^ x
58+
assert xor_op1 == 12
59+
assert xor_op2 == 100
60+
61+
62+
def test_NOR(): # NOR operator: not(a or b)
63+
a : i32
64+
b : i32
65+
x : i32
66+
y : i32
67+
nor_op1 : bool
68+
nor_op2 : bool
69+
a = 0
70+
b = 0
71+
x = 1
72+
y = 0
73+
nor_op1 = not(b or a)
74+
nor_op2 = not(y or x)
75+
assert nor_op1 == True
76+
assert nor_op2 == False
77+
78+
79+
def test_NAND(): # NAND operator: not(a and b)
80+
a : i32
81+
b : i32
82+
x : i32
83+
y : i32
84+
nand_op1 : bool
85+
nand_op2 : bool
86+
a = 0
87+
b = 0
88+
x = 1
89+
y = 1
90+
nand_op1 = not(b and a)
91+
nand_op2 = not(y and x)
92+
assert nand_op1 == True
93+
assert nand_op2 == False
94+
95+
96+
def test_XNOR(): # XNOR operator: ==
97+
a : i32
98+
b : i32
99+
x : i32
100+
y : i32
101+
xnor_op1 : bool
102+
xnor_op2 : bool
103+
a = 0
104+
b = 0
105+
x = 1
106+
y = 0
107+
xnor_op1 = b == a
108+
xnor_op2 = y == x
109+
assert xnor_op1 == True
110+
assert xnor_op2 == False
111+
112+
113+
def test_implies(): # implies operator: <=
114+
a : bool
115+
b : bool
116+
x : bool
117+
y : bool
118+
imp_op1 : bool
119+
imp_op2 : bool
120+
a = True
121+
b = True
122+
x = False
123+
y = True
124+
imp_op1 = b <= a
125+
imp_op2 = y <= x
126+
assert imp_op1 == True
127+
assert imp_op2 == False
128+
129+
45130
def check():
46131
test_issue_1487_1()
47132
test_issue_1487_2()
133+
test_XOR()
134+
test_NOR()
135+
test_NAND()
136+
test_XNOR()
137+
test_implies()
48138

49139

50140
check()

0 commit comments

Comments
 (0)