From 1ef2348df0c15f9924d3b5be798fd20805ccd5aa Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 12 Oct 2014 14:21:06 +0100 Subject: py: Implement and,or,xor native ops for viper. --- tests/micropython/viper_binop_arith.py | 22 ++++++++++++++++++++++ tests/micropython/viper_binop_arith.py.exp | 10 ++++++++++ 2 files changed, 32 insertions(+) (limited to 'tests/micropython') diff --git a/tests/micropython/viper_binop_arith.py b/tests/micropython/viper_binop_arith.py index 137b8c104..d37450315 100644 --- a/tests/micropython/viper_binop_arith.py +++ b/tests/micropython/viper_binop_arith.py @@ -34,3 +34,25 @@ shr(1, 0) shr(1, 3) shr(42, 2) shr(-42, 2) + +@micropython.viper +def and_(x:int, y:int): + print(x & y, y & x) +and_(1, 0) +and_(1, 3) +and_(0xf0, 0x3f) +and_(-42, 6) + +@micropython.viper +def or_(x:int, y:int): + print(x | y, y | x) +or_(1, 0) +or_(1, 2) +or_(-42, 5) + +@micropython.viper +def xor(x:int, y:int): + print(x ^ y, y ^ x) +xor(1, 0) +xor(1, 2) +xor(-42, 5) diff --git a/tests/micropython/viper_binop_arith.py.exp b/tests/micropython/viper_binop_arith.py.exp index f10e998cd..15abcc245 100644 --- a/tests/micropython/viper_binop_arith.py.exp +++ b/tests/micropython/viper_binop_arith.py.exp @@ -23,3 +23,13 @@ 0 10 -11 +0 0 +1 1 +48 48 +6 6 +1 1 +3 3 +-41 -41 +1 1 +3 3 +-45 -45 -- cgit v1.2.3