Skip to content

Commit

Permalink
Fix test warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
notomo committed Sep 9, 2024
1 parent 75b7866 commit dbd4301
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
7 changes: 7 additions & 0 deletions lua/piemenu/test/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ vim.opt.packpath:prepend(vim.fs.joinpath(helper.root, "spec/.shared/packages"))
require("assertlib").register(require("vusted.assert").register)

function helper.before_each()
---@diagnostic disable-next-line: duplicate-set-field
require("piemenu.view.background")._click = function() end
end

Expand Down Expand Up @@ -43,4 +44,10 @@ asserts.create("exists_highlighted_window"):register(function(self)
end
end)

function helper.typed_assert(assert)
local x = require("assertlib").typed(assert)
---@cast x +{exists_highlighted_window:fun(want)}
return x
end

return helper
9 changes: 5 additions & 4 deletions spec/lua/piemenu/core/angle_range_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local helper = require("piemenu.test.helper")
local assert = helper.typed_assert(assert)

describe("piemenu.core.angle_range", function()
before_each(helper.before_each)
Expand Down Expand Up @@ -42,7 +43,7 @@ describe("piemenu.core.angle_range", function()
:exclude(c.exclude_s, c.exclude_e)
local actual = angle_ranges:raw()

assert.is_same(c.expected, actual)
assert.same(c.expected, actual)
end
)
end
Expand All @@ -57,7 +58,7 @@ describe("piemenu.core.angle_range", function()
}) do
it(("AngleRange.new(%s, %s):contain() == %s"):format(c.start_angle, c.end_angle, c.angle), function()
local actual = require("piemenu.core.angle_range").AngleRange.new(c.start_angle, c.end_angle):contain(c.angle)
assert.is_same(c.expected, actual)
assert.same(c.expected, actual)
end)
end

Expand All @@ -72,7 +73,7 @@ describe("piemenu.core.angle_range", function()
local angle_ranges = require("piemenu.core.angle_range").AngleRanges.from_raw(c.angle_ranges):join()
local actual = angle_ranges:raw()

assert.is_same(c.expected, actual)
assert.same(c.expected, actual)
end)
end

Expand All @@ -94,7 +95,7 @@ describe("piemenu.core.angle_range", function()
local angle_ranges = require("piemenu.core.angle_range").AngleRanges.from_raw(c.angle_ranges):exclude(exclude)
local actual = angle_ranges:raw()

assert.is_same(c.expected, actual)
assert.same(c.expected, actual)
end
)
end
Expand Down
5 changes: 3 additions & 2 deletions spec/lua/piemenu/core/angle_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local helper = require("piemenu.test.helper")
local assert = helper.typed_assert(assert)

describe("piemenu.core.angle", function()
before_each(helper.before_each)
Expand All @@ -14,7 +15,7 @@ describe("piemenu.core.angle", function()
}) do
it(("Angle.new_with_offset(%s, %s) == %s"):format(c.base_angle, c.angle, c.expected), function()
local actual = require("piemenu.core.angle").new_with_offset(c.base_angle, c.angle)
assert.equals(c.expected, actual)
assert.equal(c.expected, actual)
end)
end

Expand All @@ -26,7 +27,7 @@ describe("piemenu.core.angle", function()
}) do
it(("Angle.distance(%s, %s) == %s"):format(c.angle, c.next_angle, c.expected), function()
local actual = require("piemenu.core.angle").distance(c.angle, c.next_angle)
assert.equals(c.expected, actual)
assert.equal(c.expected, actual)
end)
end
end)
3 changes: 2 additions & 1 deletion spec/lua/piemenu/core/angle_splitter_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local helper = require("piemenu.test.helper")
local assert = helper.typed_assert(assert)

describe("piemenu.core.angle_splitter", function()
before_each(helper.before_each)
Expand Down Expand Up @@ -57,7 +58,7 @@ describe("piemenu.core.angle_splitter", function()
local actual =
require("piemenu.core.angle_splitter").new(c.start_angle, c.end_angle, angle_ranges, c.all_count):split()

assert.is_same(c.expected, actual)
assert.same(c.expected, actual)
end
)
end
Expand Down
3 changes: 2 additions & 1 deletion spec/lua/piemenu/core/circle_range_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local helper = require("piemenu.test.helper")
local assert = helper.typed_assert(assert)

describe("piemenu.core.circle_range", function()
before_each(helper.before_each)
Expand Down Expand Up @@ -27,7 +28,7 @@ describe("piemenu.core.circle_range", function()
),
function()
local actual = require("piemenu.core.circle_range").new(c.s, c.e):include(c.origin, c.position)
assert.equals(c.expected, actual)
assert.equal(c.expected, actual)
end
)
end
Expand Down
1 change: 1 addition & 0 deletions spec/lua/piemenu/init_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("piemenu.test.helper")
local piemenu = helper.require("piemenu")
local assert = helper.typed_assert(assert)

describe("piemenu.start()", function()
before_each(helper.before_each)
Expand Down
5 changes: 3 additions & 2 deletions spec/lua/piemenu/lib/list_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local helper = require("piemenu.test.helper")
local assert = helper.typed_assert(assert)

describe("piemenu.lib.list", function()
before_each(helper.before_each)
Expand All @@ -12,7 +13,7 @@ describe("piemenu.lib.list", function()
}) do
it(("tri_circular(%s) == %s"):format(vim.inspect(c.items), vim.inspect(c.expected)), function()
local actual = require("piemenu.lib.list").tri_circular(c.items)
assert.is_same(c.expected, actual)
assert.same(c.expected, actual)
end)
end

Expand All @@ -26,7 +27,7 @@ describe("piemenu.lib.list", function()
local actual = require("piemenu.lib.list").circular_shift(c.items, function(item)
return item > 3
end)
assert.is_same(c.expected, actual)
assert.same(c.expected, actual)
end)
end
end)

0 comments on commit dbd4301

Please sign in to comment.