convert to lua 5.3

This commit is contained in:
Enno Rehling 2020-04-19 21:35:48 +02:00 committed by Enno Rehling
parent 97cb46933e
commit 17e5d6ab78
47 changed files with 295 additions and 127 deletions

View File

@ -52,6 +52,8 @@ if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.3")
find_package (Lua 5.3 REQUIRED) find_package (Lua 5.3 REQUIRED)
elseif (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2") elseif (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2")
find_package (Lua 5.2 REQUIRED) find_package (Lua 5.2 REQUIRED)
elseif (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.3")
find_package ( Lua 5.3 REQUIRED)
else () else ()
find_package (Lua51 REQUIRED) find_package (Lua51 REQUIRED)
endif() endif()

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -e
eval $(luarocks path) eval $(luarocks path)
ROOT=$(git rev-parse --show-toplevel) ROOT=$(git rev-parse --show-toplevel)
[ -z $BUILD ] && BUILD=Debug ; export BUILD [ -z $BUILD ] && BUILD=Debug ; export BUILD

View File

@ -1,6 +1,8 @@
-- Tests that work in all games. With game config of E2. -- Tests that work in all games. With game config of E2.
-- Tests are under scripts/test/e2 and all files must be in scripts/test/e2/init.lua -- Tests are under scripts/test/e2 and all files must be in scripts/test/e2/init.lua
lunit = require('lunit')
module = lunit.module
path = 'scripts' path = 'scripts'
if config.install then if config.install then
path = config.install .. '/' .. path path = config.install .. '/' .. path

View File

@ -1,6 +1,9 @@
-- Tests that work in E3. With game config of E3. -- Tests that work in E3. With game config of E3.
-- Tests are under scripts/test/e3 and all files must be in scripts/test/e3/init.lua -- Tests are under scripts/test/e3 and all files must be in scripts/test/e3/init.lua
lunit = require('lunit')
module = lunit.module
path = 'scripts' path = 'scripts'
if config.install then if config.install then
path = config.install .. '/' .. path path = config.install .. '/' .. path

View File

@ -10,6 +10,9 @@ package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
lunit = require 'lunit' lunit = require 'lunit'
require 'eressea' require 'eressea'
require 'eressea.path' require 'eressea.path'
lunit = require('lunit')
module = lunit.module
require 'tests' require 'tests'
result = lunit.main() result = lunit.main()
return result.errors + result.failed return result.errors + result.failed

View File

@ -1,10 +1,13 @@
require "lunit" local tcname = 'tests.bindings'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local eressea = eressea
local _G = _G local _G = _G
module("tests.bindings", lunit.testcase)
function test_eressea() function test_eressea()
assert_equal("function", _G.type(eressea.free_game)) assert_equal("function", _G.type(eressea.free_game))
assert_equal("function", _G.type(eressea.read_game)) assert_equal("function", _G.type(eressea.read_game))

View File

@ -1,4 +1,10 @@
require "lunit" local tcname = 'tests.shared.common'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local function _test_create_ship(r) local function _test_create_ship(r)
local s = ship.create(r, config.ships[1]) local s = ship.create(r, config.ships[1])
@ -26,8 +32,6 @@ local function two_factions()
return f1, f2 return f1, f2
end end
module("tests.common", package.seeall, lunit.testcase)
function setup() function setup()
eressea.free_game() eressea.free_game()
eressea.settings.set("nmr.timeout", "0") eressea.settings.set("nmr.timeout", "0")

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.config'
local lunit = require("lunit")
module("tests.eressea.config", package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.adamantium'
local lunit = require("lunit")
module("tests.e2.adamantium", package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.allies'
local lunit = require("lunit")
module("tests.e2.allies", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.astral'
local lunit = require("lunit")
module("tests.e2.astral", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()
@ -17,7 +21,7 @@ function test_fetch_astral()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local ra = r:get_astral('fog') local ra = r:get_astral('fog')
local rb = region.create(ra.x + 1, ra.y, 'fog') local rb = region.create(ra.x + 1, ra.y, 'fog')
local f = faction.create("human") local f = faction.create("human");
local u1 = unit.create(f, r, 1) local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1)
local u3 = unit.create(f, rb, 1) local u3 = unit.create(f, rb, 1)

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.buildings'
local lunit = require("lunit")
module("tests.e2.buildings", package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.game.reset() eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.carts'
local lunit = require("lunit")
module("tests.e2.carts", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.destroy'
local lunit = require("lunit")
module("tests.e2.destroy", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.features'
local lunit = require("lunit")
module("tests.e2.e2features", package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.guard'
local lunit = require("lunit")
module("tests.e2.guard", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -3,7 +3,6 @@ require 'tests.e2.trees'
require 'tests.e2.buildings' require 'tests.e2.buildings'
require 'tests.e2.movement' require 'tests.e2.movement'
require 'tests.e2.carts' require 'tests.e2.carts'
require 'tests.e2.quit'
require 'tests.e2.astral' require 'tests.e2.astral'
require 'tests.e2.spells' require 'tests.e2.spells'
require 'tests.e2.e2features' require 'tests.e2.e2features'

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.insects'
local lunit = require("lunit")
module("tests.e2.insects", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.items'
local lunit = require("lunit")
module("tests.e2.items", package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.movement'
local lunit = require("lunit")
module("tests.e2.movement", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.production'
local lunit = require("lunit")
module("tests.e2.production", package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.game.reset() eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.quit'
local lunit = require("lunit")
module("tests.e2.quit", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function test_quit_faction() function test_quit_faction()
local r = region.create(47, 0, "plain") local r = region.create(47, 0, "plain")

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.shiplanding'
local lunit = require("lunit")
module("tests.e2.shiplanding", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.ships'
local lunit = require("lunit")
module("tests.e2.ships", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.game.reset() eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.spells'
local lunit = require("lunit")
module("tests.e2.spells", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.game.reset() eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.stealth'
local lunit = require("lunit")
module('tests.e2.stealth', package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local f local f
local u local u

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.e2.undead'
local lunit = require("lunit")
module("tests.e2.undead", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.economy'
local lunit = require("lunit")
module("tests.economy", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,9 @@
require "lunit" local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
module ('tests.eressea.faction', package.seeall, lunit.testcase) _ENV = module("tests.faction", 'seeall')
else
module("tests.faction", 'seeall')
end
local f local f

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.hunger'
local lunit = require("lunit")
module("tests.hunger", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.items'
local lunit = require("lunit")
module("tests.items", package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,9 @@
require "lunit" local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
module("tests.laws", package.seeall, lunit.testcase) _ENV = module("tests.laws", 'seeall')
else
module("tests.laws", 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()
@ -115,3 +118,4 @@ function test_force_leave_postcombat()
assert_equal(nil, u3.building) assert_equal(nil, u3.building)
assert_equal(1, u3.number) assert_equal(1, u3.number)
end end

View File

@ -1,6 +1,9 @@
require "lunit" local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
module("tests.eressea.locale", package.seeall, lunit.testcase ) _ENV = module("tests.locale", 'seeall')
else
module("tests.locale", 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.magicbag'
local lunit = require("lunit")
module("tests.magicbag", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local u local u

View File

@ -1,6 +1,9 @@
require "lunit" local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
module("tests.movement", package.seeall, lunit.testcase) _ENV = module("tests.movement", 'seeall')
else
module("tests.movement", 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,12 +1,14 @@
require "lunit" local tcname = 'tests.shared.orders'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local _G = _G local _G = _G
local eressea = eressea
local default_ship = config.ships[1] local default_ship = config.ships[1]
local default_building = config.buildings[1] local default_building = config.buildings[1]
module('tests.eressea.orders', package.seeall, lunit.testcase)
local r, f, u local r, f, u
function setup() function setup()

View File

@ -1,6 +1,9 @@
require "lunit" local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
module("tests.eressea.pool", package.seeall, lunit.testcase ) _ENV = module("tests.pool", 'seeall')
else
module("tests.pool", 'seeall')
end
function setup() function setup()
eressea.game.reset() eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.process'
local lunit = require("lunit")
module("tests.process", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local u, r, f local u, r, f

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.production'
local lunit = require("lunit")
module("tests.production", package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.game.reset() eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.regions'
local lunit = require("lunit")
module("tests.regions", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.game.reset() eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.report'
local lunit = require("lunit")
module("tests.report", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require 'lunit' local tcname = 'tests.settings'
local lunit = require("lunit")
module('tests.eressea.settings', package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,5 +1,10 @@
require 'lunit' local tcname = 'tests.shared.spells'
module("tests.spells", package.seeall, lunit.testcase) local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.storage'
local lunit = require("lunit")
module("tests.storage", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.study'
local lunit = require("lunit")
module("tests.eressea.study", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
conf = [[{ conf = [[{

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.undead'
local lunit = require("lunit")
module("tests.undead", package.seeall, lunit.testcase) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit" local tcname = 'tests.shared.xmas'
local lunit = require("lunit")
module("tests.xmas", package.seeall, lunit.testcase ) if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup() function setup()
eressea.free_game() eressea.free_game()