def test_preprocessor_expression(): """ Test inner macro expantion """ obj = process(tokenize('(test (test "one" "two"))')[0]) assert type(obj) == HyList assert type(obj[0]) == HyList assert obj[0] == HyList([HyString("one"), HyString("two")]) obj = HyList([HyString("one"), HyString("two")]) obj = tokenize('(shill ["one" "two"])')[0][1] assert obj == process(obj)
def test_preprocessor_expression(): """ Test that macro expansion doesn't recurse""" obj = process(tokenize('(test (test "one" "two"))')[0], __name__) assert type(obj) == HyList assert type(obj[0]) == HyExpression assert obj[0] == HyExpression( [HySymbol("test"), HyString("one"), HyString("two")]) obj = HyList([HyString("one"), HyString("two")]) obj = tokenize('(shill ["one" "two"])')[0][1] assert obj == process(obj, '')
def test_preprocessor_expression(): """ Test that macro expansion doesn't recurse""" obj = process(tokenize('(test (test "one" "two"))')[0], __name__) assert type(obj) == HyList assert type(obj[0]) == HyExpression assert obj[0] == HyExpression([HySymbol("test"), HyString("one"), HyString("two")]) obj = HyList([HyString("one"), HyString("two")]) obj = tokenize('(shill ["one" "two"])')[0][1] assert obj == process(obj, '')
def runsource(self, source, filename="<input>", symbol="single"): global _machine try: _machine.process(source + "\n") except LexException: _machine = Machine(Idle, 1, 0) self.showsyntaxerror(filename) return False if type(_machine.state) != Idle: _machine = Machine(Idle, 1, 0) return True try: tokens = process(_machine.nodes, "__console__") except Exception: _machine = Machine(Idle, 1, 0) self.showtraceback() return False _machine = Machine(Idle, 1, 0) try: _ast = hy_compile(tokens, "__console__", root=ast.Interactive) code = ast_compile(_ast, filename, symbol) except Exception: self.showtraceback() return False self.runcode(code) return False
def runsource(self, source, filename='<input>', symbol='single'): global _hymachine try: _hymachine.process(source + "\n") except LexException: _hymachine = Machine(Idle, 1, 0) self.showsyntaxerror(filename) return False if type(_hymachine.state) != Idle: _hymachine = Machine(Idle, 1, 0) return True try: tokens = process(_hymachine.nodes, "__console__") except Exception: _hymachine = Machine(Idle, 1, 0) self.showtraceback() return False _hymachine = Machine(Idle, 1, 0) try: _ast = hy_compile(tokens, "__console__", root=ast.Interactive) code = ast_compile(_ast, filename, symbol) except Exception: self.showtraceback() return False self.runcode(code) return False
def test_preprocessor_simple(): """ Test basic macro expantion """ obj = process(tokenize('(test "one" "two")')[0]) assert obj == HyList(["one", "two"]) assert type(obj) == HyList