Fix type check on rednet.lookup

Fixes #224
This commit is contained in:
SquidDev 2019-06-01 09:23:18 +01:00
parent ce1f14a010
commit 17645a79f0
5 changed files with 22 additions and 11 deletions

View File

@ -336,7 +336,7 @@ task checkRelease(dependsOn: extractAnnotationsJar) {
token project.hasProperty('githubApiKey') ? project.githubApiKey : ''
owner 'SquidDev-CC'
repo 'CC-Tweaked'
targetCommitish { Grgit.open(dir: '.').branch.current().fullName }
targetCommitish { Grgit.open(dir: '.').branch.current().name }
tagName "v${mc_version}-${mod_version}"
releaseName "[${mc_version}] ${mod_version}"
@ -349,10 +349,12 @@ task checkRelease(dependsOn: extractAnnotationsJar) {
prerelease false
}
task uploadAll(dependsOn: [uploadArchives, "curseforge", "githubRelease"]) {
def uploadTasks = ["uploadArchives", "curseforge", "githubRelease"]
uploadTasks.forEach { tasks.getByName(it).dependsOn checkRelease }
task uploadAll(dependsOn: uploadTasks) {
group "upload"
description "Uploads to all repositories (Maven, Curse, GitHub release)"
dependsOn checkRelease
}
test {

View File

@ -153,7 +153,7 @@ end
function lookup( sProtocol, sHostname )
expect(1, sProtocol, "string")
expect(2, sHostname, "string")
expect(2, sHostname, "string", "nil")
-- Build list of host IDs
local tResults = nil

View File

@ -33,11 +33,8 @@ local active_stubs = {}
--
-- @tparam string var The variable to stub
-- @param value The value to stub it with
local function stub(var, value)
if not active_stubs[var] then
active_stubs[var] = { value = _G[var] }
end
local function stub(tbl, var, value)
table.insert(active_stubs, { tbl = tbl, var = var, value = tbl[var] })
_G[var] = value
end
@ -56,7 +53,11 @@ end
--- Restore the global state of the computer to a previous version
local function pop_state(state)
for k, v in pairs(active_stubs) do _G[k] = v.value end
for i = #active_stubs, 1, -1 do
local stub = active_stubs[i]
stub.tbl[stub.var] = stub.value
end
active_stubs = state.stubs
term.redirect(state.term)

View File

@ -1,7 +1,7 @@
describe("The gps library", function()
describe("gps.locate", function()
it("validates arguments", function()
stub("commands", { getBlockPosition = function()
stub(_G, "commands", { getBlockPosition = function()
end })
gps.locate()

View File

@ -74,5 +74,13 @@ describe("The rednet library", function()
expect.error(rednet.lookup, nil):eq("bad argument #1 (expected string, got nil)")
expect.error(rednet.lookup, "", false):eq("bad argument #2 (expected string, got boolean)")
end)
it("gets a locally hosted protocol", function()
rednet.host("a_protocol", "a_hostname")
expect(rednet.lookup("a_protocol")):eq(os.getComputerID())
expect(rednet.lookup("a_protocol", "localhost")):eq(os.getComputerID())
expect(rednet.lookup("a_protocol", "a_hostname")):eq(os.getComputerID())
end)
end)
end)