Ejemplo n.º 1
0
 def test_init(self):
     ast = AST()
     data = list(reversed([(0, 0), (1, 2), (2, 4), (3, 6), (4, 8),
                           (5, 10)]))
     for k, v in data:
         ast[k] = v
     self.assertEquals(data, list(ast.items()))
Ejemplo n.º 2
0
 def test_iter(self):
     ast = AST()
     ast['name'] = 'hello'
     ast['name'] = 'world'
     ast['value'] = 1
     self.assertEqual(['name', 'value'], list(ast))
     self.assertEqual([['hello', 'world'], 1], list(ast.values()))
Ejemplo n.º 3
0
 def test_iter(self):
     ast = AST()
     ast['name'] = 'hello'
     ast['name'] = 'world'
     ast['value'] = 1
     self.assertEqual(['name', 'value'], list(ast))
     self.assertEqual([['hello', 'world'], 1], list(ast.values()))
Ejemplo n.º 4
0
 def test_init(self):
     ast = AST()
     data = list(reversed(
         [(0, 0), (1, 2), (2, 4), (3, 6), (4, 8), (5, 10)]
     ))
     for k, v in data:
         ast[k] = v
     self.assertEquals(data, list(ast.items()))
Ejemplo n.º 5
0
 def __init__(self, ast, name, exp, base, params, kwparams, decorators=None):
     super(BasedRule, self).__init__(
         ast,
         name,
         exp,
         params or base.params,
         kwparams or base.kwparams,
         decorators=decorators
     )
     self.base = base
     ast = AST(sequence=[self.base.exp, self.exp])
     ast._parseinfo = self.base.parseinfo
     self.rhs = Sequence(ast)
Ejemplo n.º 6
0
    def test_add(self):
        ast = AST()
        ast['name'] = 'hello'
        self.assertIsNotNone(ast.name)
        self.assertEqual('hello', ast.name)

        ast['name'] = 'world'
        self.assertEqual(['hello', 'world'], ast.name)

        ast['value'] = 1
        self.assertEqual(1, ast.value)
Ejemplo n.º 7
0
 def test_empty(self):
     ast = AST()
     self.assertIsNone(ast.name)
Ejemplo n.º 8
0
 def test_ast(self):
     ast = AST()
     self.assertEquals([], list(ast.items()))
     self.assertTrue(hasattr(ast, '__json__'))
Ejemplo n.º 9
0
 def test_ast(self):
     ast = AST()
     self.assertEquals([], list(ast.items()))
     self.assertTrue(hasattr(ast, '__json__'))