Skip to content

Commit 21594fa

Browse files
committed
future: add meta 3rd: busted
1 parent 456e4e9 commit 21594fa

File tree

8 files changed

+396
-0
lines changed

8 files changed

+396
-0
lines changed

Diff for: meta/3rd/busted/config.lua

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
configs = {}

Diff for: meta/3rd/busted/library/busted.lua

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---@diagnostic disable: lowercase-global
2+
---@meta
3+
4+
---comment this api is hided
5+
---@param filename string
6+
function file(filename)
7+
end
8+
9+
---comment
10+
---@param name string
11+
---@param block? fun()
12+
function pending(name, block)
13+
end
14+
15+
---comment
16+
---@async
17+
function async()
18+
end
19+
20+
---comment
21+
---@param name string
22+
---@param block fun()
23+
function describe(name, block)
24+
end
25+
26+
context = describe
27+
28+
expose = describe
29+
30+
31+
function randomize()
32+
end
33+
34+
---comment
35+
---@param name string
36+
---@param block fun()
37+
function it(name, block)
38+
end
39+
40+
spec = it
41+
42+
test = it
43+
44+
---comment
45+
---@param block fun()
46+
function before_each(block)
47+
end
48+
49+
---comment
50+
---@param block fun()
51+
function after_each(block)
52+
end
53+
54+
---comment
55+
---@param block fun()
56+
function setup(block)
57+
end
58+
59+
strict_setup = setup
60+
61+
62+
---comment
63+
---@param block fun()
64+
function teardown(block)
65+
end
66+
67+
strict_teardown = teardown
68+
69+
---comment
70+
---@param block fun()
71+
function lazy_setup(block)
72+
end
73+
74+
---comment
75+
---@param block fun()
76+
function lazy_teardown(block)
77+
end
78+
79+
---comment
80+
---@param block fun()
81+
function finally(block)
82+
end
83+
84+
---@type luassert
85+
assert = {}
86+
---@param key 'assertion' | 'matcher'
87+
function assert:register(key, ...)
88+
89+
end
90+
91+
---@type luassert_spy
92+
spy = {}
93+
---@type luassert_mock
94+
mock = {}
95+
---@type luassert_stub
96+
stub = {}
97+
---@type luassert_match
98+
match = {}

Diff for: meta/3rd/luassert/config.lua

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
words = { "assert.%w+" }

Diff for: meta/3rd/luassert/library/luassert.lua

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---@meta
2+
3+
---@class luassert
4+
---@field unique fun(v1,deep?:boolean,failure_message?:string)
5+
---@field is_unique fun(v1,deep?:boolean,failure_message?:string)
6+
---@field not_unique fun(v1,deep?:boolean,failure_message?:string)
7+
---@field near fun(expected:number|string,actual:number|string,tolerance:number|string,failure_message?:string)
8+
---@field is_near fun(expected:number|string,actual:number|string,tolerance:number|string,failure_message?:string)
9+
---@field not_near fun(expected:number|string,actual:number|string,tolerance:number|string,failure_message?:string)
10+
---@field matches fun(pattern:string,actual:string|number,init?:number,plain?:boolean,failure_message?:string)
11+
---@field is_matches fun(pattern:string,actual:string|number,init?:number,plain?:boolean,failure_message?:string)
12+
---@field not_matches fun(pattern:string,actual:string|number,init?:number,plain?:boolean,failure_message?:string)
13+
---@field equal fun(v1,v2,failure_message?:string)
14+
---@field equals fun(v1:table,v2:table,failure_message?:string)
15+
---@field is_equal fun(v1,v2,failure_message?:string)
16+
---@field is_equals fun(v1:table,v2:table,failure_message?:string)
17+
---@field not_equal fun(v1,v2,failure_message?:string)
18+
---@field not_equals fun(v1:table,v2:table,failure_message?:string)
19+
---@field same fun(v1,v2,failure_message?:string)
20+
---@field is_same fun(v1,v2,failure_message?:string)
21+
---@field not_same fun(v1,v2,failure_message?:string)
22+
---@field truthy fun(v1,v2,failure_message?:string)
23+
---@field falsy fun(v1,v2,failure_message?:string)
24+
---@field error fun(func:fun(),err_expected?:string,failure_message?:string)
25+
---@field errors fun(func:fun(),err_expected?:string,failure_message?:string)
26+
---@field has_error fun(func:fun(),err_expected?:string,failure_message?:string)
27+
---@field has_errors fun(func:fun(),err_expected?:string,failure_message?:string)
28+
---@field no_error fun(func:fun(),err_expected?:string,failure_message?:string)
29+
---@field no_errors fun(func:fun(),err_expected?:string,failure_message?:string)
30+
---@field error_matches fun(func:fun(),pattern:string,init?:number,plain?:boolean,failure_message?:string)
31+
---@field is_error_matches fun(func:fun(),pattern:string,init?:number,plain?:boolean,failure_message?:string)
32+
---@field not_error_matches fun(func:fun(),pattern:string,init?:number,plain?:boolean,failure_message?:string)
33+
---@field number fun(v)
34+
---@field string fun(v)
35+
---@field table fun(v)
36+
---@field userdata fun(v)
37+
---@field function fun(v)
38+
---@field thread fun(v)
39+
---@field boolean fun(v)
40+
---@field returned_arguments fun(...,fn:function)
41+
---@field property fun(name:string,obj)
42+
---@field is_number fun(v)
43+
---@field is_string fun(v)
44+
---@field is_table fun(v)
45+
---@field is_nil fun(v)
46+
---@field is_userdata fun(v)
47+
---@field is_function fun(v)
48+
---@field is_thread fun(v)
49+
---@field is_boolean fun(v)
50+
---@field is_true fun(b)
51+
---@field is_returned_arguments fun(...,fn:function)
52+
---@field is_false fun(b)
53+
---@field has_property fun(name:string,obj)
54+
---@field not_number fun(v)
55+
---@field not_string fun(v)
56+
---@field not_table fun(v)
57+
---@field not_nil fun(v)
58+
---@field not_userdata fun(v)
59+
---@field not_function fun(v)
60+
---@field not_thread fun(v)
61+
---@field not_boolean fun(v)
62+
---@field not_true fun(b)
63+
---@field not_false fun(b)
64+
---@field not_returned_arguments fun(...,fn:function)
65+
---@field no_property fun(name:string,obj)
66+
---@field message fun(failure_message:string)
67+
---@module 'luassert'
68+
local luassert = {}
69+
70+
---comment
71+
---@param fn function
72+
---@param failure_message? string
73+
---@return luassert_spy
74+
function luassert.spy(fn,failure_message)
75+
end
76+
77+
---comment
78+
---@param fn function
79+
---@param failure_message? string
80+
---@return luassert_stub
81+
function luassert.stub(fn,failure_message)
82+
end
83+
84+
85+
return luassert

Diff for: meta/3rd/luassert/library/luassert/match.lua

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---@meta
2+
3+
--[[
4+
Matchers are used to provide flexible argument matching for `called_with` and `returned_with` asserts. Just like with asserts, you can chain a modifier value using `is` or `is_not`, followed by the matcher you wish to use. Extending busted with your own matchers is done similar to asserts as well; just build a matcher with a common signature and [register it](#matcher-extend). Furthermore, matchers can be combined using [composite matchers](#matcher-composite).
5+
]]
6+
---@class luassert_match
7+
local match = {}
8+
9+
--- this is a `placeholder`, match any thing
10+
--[[
11+
```lua
12+
it("tests wildcard matcher", function()
13+
local s = spy.new(function() end)
14+
local _ = match._
15+
16+
s("foo")
17+
18+
assert.spy(s).was_called_with(_) -- matches any argument
19+
assert.spy(s).was_not_called_with(_, _) -- does not match two arguments
20+
end)
21+
```]]
22+
match._ = {}
23+
24+
--[[
25+
If you're creating a spy for functions that mutate any properties on an table (for example `self`) and you want to use `was_called_with`, you should use `match.is_ref(obj)`.
26+
```lua
27+
describe("combine matchers", function()
28+
local match = require("luassert.match")
29+
30+
it("tests ref matchers for passed in table", function()
31+
local t = { cnt = 0, }
32+
function t.incrby(t, i) t.cnt = t.cnt + i end
33+
34+
local s = spy.on(t, "incrby")
35+
36+
s(t, 2)
37+
38+
assert.spy(s).was_called_with(match.is_ref(t), 2)
39+
end)
40+
41+
it("tests ref matchers for self", function()
42+
local t = { cnt = 0, }
43+
function t:incrby(i) self.cnt = self.cnt + i end
44+
45+
local s = spy.on(t, "incrby")
46+
47+
t:incrby(2)
48+
49+
assert.spy(s).was_called_with(match.is_ref(t), 2)
50+
end)
51+
end)
52+
```]]
53+
---@param obj any
54+
function match.is_ref(obj)
55+
56+
end
57+
58+
--[[
59+
Combine matchers using composite matchers.
60+
```lua
61+
describe("combine matchers", function()
62+
local match = require("luassert.match")
63+
64+
it("tests composite matchers", function()
65+
local s = spy.new(function() end)
66+
67+
s("foo")
68+
69+
assert.spy(s).was_called_with(match.is_all_of(match.is_not_nil(), match.is_not_number()))
70+
assert.spy(s).was_called_with(match.is_any_of(match.is_number(), match.is_string(), match.is_boolean())))
71+
assert.spy(s).was_called_with(match.is_none_of(match.is_number(), match.is_table(), match.is_boolean())))
72+
end)
73+
end)
74+
```
75+
]]
76+
function match.is_all_of(...)
77+
end
78+
79+
function match.is_any_of(...)
80+
end
81+
82+
function match.is_none_of(...)
83+
end
84+
85+
return match

Diff for: meta/3rd/luassert/library/luassert/mock.lua

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---@meta
2+
3+
---@class luassert_mock
4+
---@generic T
5+
---@param object T
6+
---@param dostub? boolean @will never call original function
7+
---@param func? any
8+
---@param target_objcet? any
9+
---@param key? any
10+
---@return T
11+
local mock = function(object, dostub, func, target_objcet, key)
12+
end
13+
14+
---@generic T
15+
---@param object T
16+
---@param dostub? boolean @will never call original function
17+
---@param func? any
18+
---@param target_objcet? any
19+
---@param key? any
20+
---@return T
21+
function mock.new(object, dostub, func, target_objcet, key)
22+
end
23+
24+
25+
---@param object any
26+
function mock.clear(object)
27+
end
28+
29+
30+
---@param object any
31+
function mock.revert(object)
32+
end
33+
34+
return mock

Diff for: meta/3rd/luassert/library/luassert/spy.lua

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---@meta
2+
3+
---@class luassert_spy
4+
---@return luassert_spy
5+
local spy = function(callback)
6+
end
7+
8+
---@param callback function
9+
---@return function warp_callback
10+
---@nodiscard
11+
function spy.new(callback)
12+
end
13+
14+
15+
---comment spy function on obj[name]
16+
---@param obj any
17+
---@param name string
18+
---@return any
19+
---@nodiscard
20+
function spy.on(obj, name)
21+
end
22+
23+
24+
---comment obj is spy
25+
---@param obj any
26+
---@return boolean
27+
function spy.is_spy(obj)
28+
end
29+
30+
31+
function spy.returned_with(...)
32+
end
33+
34+
35+
function spy.called(...)
36+
end
37+
38+
39+
function spy.called_with(...)
40+
end
41+
42+
43+
---comment
44+
---@param count integer
45+
function spy.called_at_least(count)
46+
end
47+
48+
49+
---comment
50+
---@param count integer
51+
function spy.called_at_most(count)
52+
end
53+
54+
55+
---comment
56+
---@param count integer
57+
function spy.called_more_than(count)
58+
end
59+
60+
61+
---comment
62+
---@param count integer
63+
function spy.called_less_than(count)
64+
end
65+
66+
67+
return spy;

0 commit comments

Comments
 (0)