Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Completed test suite for logical binary operators #1517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 92 additions & 2 deletions integration_tests/logical_binop1.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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()