MVP #1

Merged
jbwdevries merged 73 commits from idea_crc32 into master 2022-08-21 12:59:21 +00:00
2 changed files with 37 additions and 5 deletions
Showing only changes of commit 0c64973b2b - Show all commits

View File

@ -219,13 +219,19 @@ class Visitor:
""" """
Visits a UnaryOp node as (part of) an expression Visits a UnaryOp node as (part of) an expression
""" """
del module if isinstance(node.op, ast.UAdd):
del wlocals return self.visit_expr(module, wlocals, exp_type, node.operand)
if not isinstance(node.operand, ast.Constant): if isinstance(node.op, ast.USub):
raise NotImplementedError if not isinstance(node.operand, ast.Constant):
raise NotImplementedError(node.operand)
return self.visit_Constant(exp_type, node.operand) if not isinstance(node.operand.value, int):
raise NotImplementedError(node.operand.value)
return self.visit_Constant(exp_type, ast.Constant(-node.operand.value))
raise NotImplementedError(node.op)
def visit_BinOp( def visit_BinOp(
self, self,

View File

@ -28,6 +28,32 @@ def testEntry(a: i32) -> i32:
assert 125 == result.returned_value assert 125 == result.returned_value
assert [] == result.log_int32_list assert [] == result.log_int32_list
@pytest.mark.integration_test
def test_uadd():
code_py = """
@exported
def testEntry() -> i32:
return +523
"""
result = Suite(code_py, 'test_addition').run_code()
assert 523 == result.returned_value
assert [] == result.log_int32_list
@pytest.mark.integration_test
def test_usub():
code_py = """
@exported
def testEntry() -> i32:
return -19
"""
result = Suite(code_py, 'test_addition').run_code()
assert -19 == result.returned_value
assert [] == result.log_int32_list
@pytest.mark.integration_test @pytest.mark.integration_test
def test_addition(): def test_addition():
code_py = """ code_py = """