aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/spec/basic_signalling_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_interlocking/spec/basic_signalling_spec.lua')
-rw-r--r--advtrains_interlocking/spec/basic_signalling_spec.lua26
1 files changed, 15 insertions, 11 deletions
diff --git a/advtrains_interlocking/spec/basic_signalling_spec.lua b/advtrains_interlocking/spec/basic_signalling_spec.lua
index cce0f15..a4e1e3a 100644
--- a/advtrains_interlocking/spec/basic_signalling_spec.lua
+++ b/advtrains_interlocking/spec/basic_signalling_spec.lua
@@ -8,7 +8,7 @@ mineunit("core")
_G.advtrains = {
interlocking = {
- aspects = fixture("../../signal_aspects"),
+ aspect = fixture("../../aspect"),
},
ndb = {
get_node = minetest.get_node,
@@ -31,12 +31,16 @@ minetest.register_node("advtrains_interlocking:signal_sign", {
local D = advtrains.distant
local I = advtrains.interlocking
+local A = I.aspect
local stub_aspect_t1 = {
free = {main = -1},
slow = {main = 6},
danger = {main = 0, shunt = false},
}
+for k, v in pairs(stub_aspect_t1) do
+ stub_aspect_t1[k] = A(v)
+end
local stub_pos_t1 = {}
for i = 1, 4 do
stub_pos_t1[i] = {x = 1, y = 0, z = i}
@@ -55,14 +59,14 @@ describe("API for supposed signal aspects", function()
I.load_supposed_aspects(tbl)
assert.same(tbl, I.save_supposed_aspects())
end)
- it("should set and get type 1 signals properly", function ()
+ it("should set and get signals properly", function ()
local pos = stub_pos_t1[2]
local asp = stub_aspect_t1.slow
- local newasp = { main = math.random(1,5) }
- assert.same(asp, I.signal_get_aspect(pos))
+ local newasp = A{ main = math.random(1,5) }
+ assert.equal(asp, I.signal_get_aspect(pos))
I.signal_set_aspect(pos, newasp)
- assert.same(newasp, I.signal_get_aspect(pos))
- assert.same(asp, I.signal_get_real_aspect(pos))
+ assert.equal(newasp, I.signal_get_aspect(pos))
+ assert.equal(asp, I.signal_get_real_aspect(pos))
I.signal_set_aspect(pos, asp)
end)
end)
@@ -72,9 +76,9 @@ describe("Distant signaling", function()
for i = 1, 2 do
D.assign(stub_pos_t1[i], stub_pos_t1[i+1])
end
- assert.same(stub_aspect_t1.danger, I.signal_get_aspect(stub_pos_t1[1]))
- assert.same({main = 6, dst = 0}, I.signal_get_aspect(stub_pos_t1[2]))
- assert.same({main = -1, dst = 6}, I.signal_get_aspect(stub_pos_t1[3]))
+ assert.equal(stub_aspect_t1.danger, I.signal_get_aspect(stub_pos_t1[1]))
+ assert.equal(A{main = 6, dst = 0}, I.signal_get_aspect(stub_pos_t1[2]))
+ assert.equal(A{main = -1, dst = 6}, I.signal_get_aspect(stub_pos_t1[3]))
end)
it("should report assignments properly", function()
assert.same({stub_pos_t1[1], "manual"}, {D.get_main(stub_pos_t1[2])})
@@ -82,8 +86,8 @@ describe("Distant signaling", function()
end)
it("should update distant aspects automatically", function()
I.signal_set_aspect(stub_pos_t1[2], {main = 2, dst = -1})
- assert.same({main = 2, dst = 0}, I.signal_get_aspect(stub_pos_t1[2]))
- assert.same({main = -1, dst = 2}, I.signal_get_aspect(stub_pos_t1[3]))
+ assert.equal(A{main = 2, dst = 0}, I.signal_get_aspect(stub_pos_t1[2]))
+ assert.equal(A{main = -1, dst = 2}, I.signal_get_aspect(stub_pos_t1[3]))
end)
it("should unassign signals when one is removed", function()
world.set_node(stub_pos_t1[2], "air")