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()))
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()))
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()))
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)
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)
def test_empty(self): ast = AST() self.assertIsNone(ast.name)
def test_ast(self): ast = AST() self.assertEquals([], list(ast.items())) self.assertTrue(hasattr(ast, '__json__'))