def testFunction(self): module = self.compiler.compile(self.paths, 'emptyfunction') self.assertEqual(len(module.variables), 0) self.assertEqual(len(module.functions), 1) self.assertEqual(len(module.enums), 0) self.assertEqual(len(module.structs), 0) self.assertEqual(len(module.classes), 0) func = module.functions['foo'] self.assertEqual(func.nodetype, 'function') self.assertEqual(matches.tokensToString(func.decltype), 'void') self.assertEqual(func.name, 'foo') self.assertEqual(len(func.params), 0)
def testVariable(self): module = self.compiler.compile(self.paths, 'variableint') self.assertEqual(len(module.variables), 1) self.assertEqual(len(module.functions), 0) self.assertEqual(len(module.enums), 0) self.assertEqual(len(module.structs), 0) self.assertEqual(len(module.classes), 0) var = module.variables['num'] self.assertEqual(var.nodetype, 'variable') self.assertEqual(matches.tokensToString(var.decltype), 'int') self.assertEqual(var.name, 'num') self.assertIsNotNone(var.body) self.assertEqual(var.body.nodetype, 'value') self.assertEqual(var.body.value, '4')