示例#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
示例#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
示例#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
示例#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
示例#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))
示例#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])
示例#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])
示例#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))