def assertCompile(self, source, testValue ): parser = Parser() ast = parser.parse(parser.lex( source ), "") gen = Generator().compile(ast) result = gen.execute() print gen.module self.assertEquals(result.as_real(Type.double()), testValue);
def assertCompile(self, source, testValue): parser = Parser() ast = parser.parse(parser.lex(source), "") gen = Generator().compile(ast) result = gen.execute() print gen.module self.assertEquals(result.as_real(Type.double()), testValue)
def test_parser(self): parser = Parser() state = parser.lex( "add(1,2)" ) ast = parser.parse(state, "") assert(FunctionCall == ast[0].__class__) self.assertEquals("add", ast[0].name) self.assertEquals(2, len(ast[0].args)) assert(Number == ast[0].args[0].__class__) assert(Number == ast[0].args[1].__class__)
def test_parser(self): parser = Parser() state = parser.lex("add(1,2)") ast = parser.parse(state, "") assert (FunctionCall == ast[0].__class__) self.assertEquals("add", ast[0].name) self.assertEquals(2, len(ast[0].args)) assert (Number == ast[0].args[0].__class__) assert (Number == ast[0].args[1].__class__)