Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stevedonovan/Penlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2021-01-07 12:16:26 +0300
committerGitHub <noreply@github.com>2021-01-07 12:16:26 +0300
commit328d39e8ba255939dbad08b1f6230a9b997ec1ce (patch)
tree9a411b104ce314715a0a51787434fe83ea247f53 /spec
parent94693b1e2d12793ce55cd7c938e8d3e1ddc908a3 (diff)
feat(compat) add a 5.4 compatible "warn" function (#366)
also updates the derpecation warnings to use the warn function
Diffstat (limited to 'spec')
-rw-r--r--spec/utils-deprecate_spec.lua40
1 files changed, 33 insertions, 7 deletions
diff --git a/spec/utils-deprecate_spec.lua b/spec/utils-deprecate_spec.lua
index b236cb0..1a6e352 100644
--- a/spec/utils-deprecate_spec.lua
+++ b/spec/utils-deprecate_spec.lua
@@ -5,13 +5,13 @@ describe("pl.utils", function ()
local old_fn, last_msg, last_trace
before_each(function()
- old_fn = utils.deprecation_warning
+ old_fn = function() end
last_msg = nil
last_trace = nil
- utils.deprecation_warning = function(msg, trace)
+ utils.set_deprecation_func(function(msg, trace)
last_msg = msg
last_trace = trace
- end
+ end)
end)
@@ -21,6 +21,32 @@ describe("pl.utils", function ()
+ describe("set_deprecation_func", function ()
+
+ it("accepts nil as callback", function()
+ assert.has.no.error(function()
+ utils.set_deprecation_func()
+ end)
+ end)
+
+
+ it("accepts function as callback", function()
+ assert.has.no.error(function()
+ utils.set_deprecation_func(function() end)
+ end)
+ end)
+
+
+ it("fails on non-functions", function()
+ assert.has.error(function()
+ utils.set_deprecation_func("not a function")
+ end, "argument 1 expected a 'function', got a 'string'")
+ end)
+
+ end)
+
+
+
describe("raise_deprecation", function ()
it("requires the opts table", function()
@@ -46,7 +72,7 @@ describe("pl.utils", function ()
it("should output the deprecated version", function ()
utils.raise_deprecation {
message = "hello world",
- version_deprecated = "2.0.0",
+ deprecated_after = "2.0.0",
}
assert.equal("hello world (deprecated after 2.0.0)", last_msg)
end)
@@ -64,7 +90,7 @@ describe("pl.utils", function ()
it("should output the deprecated and removal versions", function ()
utils.raise_deprecation {
message = "hello world",
- version_deprecated = "2.0.0",
+ deprecated_after = "2.0.0",
version_removed = "3.0.0",
}
assert.equal("hello world (deprecated after 2.0.0, scheduled for removal in 3.0.0)", last_msg)
@@ -75,7 +101,7 @@ describe("pl.utils", function ()
utils.raise_deprecation {
source = "MyApp 1.2.3",
message = "hello world",
- version_deprecated = "2.0.0",
+ deprecated_after = "2.0.0",
version_removed = "3.0.0",
}
assert.equal("[MyApp 1.2.3] hello world (deprecated after 2.0.0, scheduled for removal in 3.0.0)", last_msg)
@@ -87,7 +113,7 @@ describe("pl.utils", function ()
utils.raise_deprecation {
source = "MyApp 1.2.3",
message = "hello world",
- version_deprecated = "2.0.0",
+ deprecated_after = "2.0.0",
version_removed = "3.0.0",
}
end