Ejemplo n.º 1
0
 def test_bind(self):
     """
     Test code generation for variable assignment.
     """
     x = t.Exactly("x")
     b = t.Bind("var", x)
     self.assertEqual(
         writePython(b, ""),
         dd("""
                         _G_exactly_1, lastError = self.exactly('x')
                         self.considerError(lastError, None)
                         _locals['var'] = _G_exactly_1
                         _G_exactly_1
                         """))
 def test_bind_apply(self):
     x = t.Apply("members", "object", [])
     b = t.Bind("m", x)
     self.assertEqual(writeBytecode(b), [t.Call('members'), t.Bind('m')])
 def test_bind(self):
     x = t.Exactly("x")
     b = t.Bind("var", x)
     self.assertEqual(writeBytecode(b), [t.Match('x'), t.Bind('var')])
Ejemplo n.º 4
0
 def generate_Bind(self, out, name, expr, debugname=None):
     self._generateNode(out, expr)
     out.emit(t.Bind(name))