def test_comment(self): code = """ # some comment a = b + 3 # another comment """ interp = self.compile(code) assert interp.code.statements[0] == Assignment( 'a', Operator(Variable('b'), "+", FloatConstant(3)))
def test_function_call(self): code = "sum(a)" interp = self.compile(code) assert interp.code.statements[0] == Execute( FunctionCall("sum", [Variable("a")]))
def test_array_access(self): code = "a -> 3" interp = self.compile(code) assert interp.code.statements[0] == Execute( Operator(Variable("a"), "->", FloatConstant(3)))
def test_expr_only(self): code = "3 + a" interp = self.compile(code) assert interp.code.statements[0] == Execute( Operator(FloatConstant(3), "+", Variable("a")))
def test_expr_2(self): code = "b = a + b - 3" interp = self.compile(code) assert (interp.code.statements[0].expr == Operator(Operator(Variable("a"), "+", Variable("b")), "-", FloatConstant(3)))
def test_expr_1(self): code = "b = a + 1" interp = self.compile(code) assert (interp.code.statements[0].expr == Operator(Variable("a"), "+", FloatConstant(1)))