Damien George 3c445f6636 py/emitnative: Implement viper unary ops positive, negative and invert.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-19 10:31:36 +11:00

32 lines
335 B
Python

# test unary operators
@micropython.viper
def pos(x: int) -> int:
return +x
print(pos(0))
print(pos(1))
print(pos(-2))
@micropython.viper
def neg(x: int) -> int:
return -x
print(neg(0))
print(neg(1))
print(neg(-2))
@micropython.viper
def inv(x: int) -> int:
return ~x
print(inv(0))
print(inv(1))
print(inv(-2))