Example #1
0
  def testRunSelfReferencingVariable(self):
    root = Node("=")
    root.left = Node("y")
    root.right = Node("+")
    root.right.left = Node("y")
    root.right.right = Node("3")

    program = Program(root)
    result = program.run({"y": 2})

    self.assertEqual(result["y"], 5)
Example #2
0
  def testRun(self):
    root = Node("=")
    root.left = Node("y")
    root.right = Node("+")
    root.right.left = Node("x")
    root.right.right = Node("4")

    program = Program(root)
    result = program.run({"x": 3})

    self.assertEqual(result["x"], 3)
    self.assertEqual(result["y"], 7)