Esempio n. 1
0
 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)))
Esempio n. 2
0
 def test_function_call(self):
     code = "sum(a)"
     interp = self.compile(code)
     assert interp.code.statements[0] == Execute(
         FunctionCall("sum", [Variable("a")]))
Esempio n. 3
0
 def test_array_access(self):
     code = "a -> 3"
     interp = self.compile(code)
     assert interp.code.statements[0] == Execute(
         Operator(Variable("a"), "->", FloatConstant(3)))
Esempio n. 4
0
 def test_expr_only(self):
     code = "3 + a"
     interp = self.compile(code)
     assert interp.code.statements[0] == Execute(
         Operator(FloatConstant(3), "+", Variable("a")))
Esempio n. 5
0
 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)))
Esempio n. 6
0
 def test_expr_1(self):
     code = "b = a + 1"
     interp = self.compile(code)
     assert (interp.code.statements[0].expr ==
             Operator(Variable("a"), "+", FloatConstant(1)))