Esempio n. 1
0
 def testRequireWalkerErrorBadOptionValue(self):
     ast = lua.Lua.from_lines([b'require("foo", {use_game_loop=123})'], 8)
     try:
         unused_result = list(build.RequireWalker(ast.tokens, ast.root).walk())
         self.fail()
     except build.LuaBuildError:
         pass
Esempio n. 2
0
 def testRequireWalkerErrorSecondNonTable(self):
     ast = lua.Lua.from_lines([b'require("foo", 123)'], 8)
     try:
         unused_result = list(build.RequireWalker(ast.tokens, ast.root).walk())
         self.fail()
     except build.LuaBuildError:
         pass
Esempio n. 3
0
 def testRequireWalkerErrorBadOptionName(self):
     ast = lua.Lua.from_lines([b'require("foo", {invalid_name=true})'], 8)
     try:
         unused_result = list(build.RequireWalker(ast.tokens, ast.root).walk())
         self.fail()
     except build.LuaBuildError:
         pass
Esempio n. 4
0
 def testRequireWalkerErrorFirstNonString(self):
     ast = lua.Lua.from_lines([b'require(123)'], 8)
     try:
         unused_result = list(build.RequireWalker(ast.tokens, ast.root).walk())
         self.fail()
     except build.LuaBuildError:
         pass
Esempio n. 5
0
 def testRequireWalkerComplexRequires(self):
     ast = lua.Lua.from_lines([
         b'foomod = require("foo")'
         b'function bar()',
         b'  require("foo", {use_game_loop=true})',
         b'end\n'], 8)
     result = list(build.RequireWalker(ast.tokens, ast.root).walk())
     self.assertEquals(2, len(result))
Esempio n. 6
0
 def testRequireWalkerOptionsTable(self):
     ast = lua.Lua.from_lines([
         b'print("hi")',
         b'require("foo", {use_game_loop=true})',
         b'x = 7\n'], 8)
     result = list(build.RequireWalker(ast.tokens, ast.root).walk())
     self.assertEquals(1, len(result))
     self.assertEquals((b'foo', True, lexer.TokSymbol(b'(')), result[0])
Esempio n. 7
0
 def testRequireWalkerExpression(self):
     ast = lua.Lua.from_lines([
         b'print("hi")',
         b'foomod = require("foo")',
         b'x = 7\n'], 8)
     result = list(build.RequireWalker(ast.tokens, ast.root).walk())
     self.assertEquals(1, len(result))
     self.assertEquals((b'foo', False, lexer.TokSymbol(b'(')), result[0])
Esempio n. 8
0
 def testRequireWalkerNoRequires(self):
     ast = lua.Lua.from_lines([
         b'print("hi")',
         b'x = 7\n'], 8)
     result = list(build.RequireWalker(ast.tokens, ast.root).walk())
     self.assertEquals(0, len(result))