luacats / luassert Goto Github PK
View Code? Open in Web Editor NEWDefinitions for the luassert assertion library
Definitions for the luassert assertion library
This is an example taken directly from busted documentation:
local t = {
greet = function(msg) print(msg) end
}
stub(t, "greet")
t.greet("Hey!") -- DOES NOT print 'Hey!'
assert.stub(t.greet).was.called_with("Hey!")
Lua LS gives the following error on the assertion line:
Diagnostics:
Cannot assign `function` to parameter `luassert.spy`.
- `function` cannot match `luassert.spy`
- Type `function` cannot match `luassert.spy` [param-type-mismatch]
I'm not sure how to fix this. Changing the param in the meta file to luassert.spy|function
may be a workaround but would not be accurate. The problem is that t.greet
is already a luassert.spy
object but the language server incorrectly assumes that it is a function
. The object is modified in-place and after the call:
local s = stub(t, "greet")
t.greet
is no longer a function but a callable table. Both s
and t.greet
point to the same object (of type luassert.spy
). It would be best if the language server could figure this out.
luassert assertions support a trailing message parameter, but the annotations don't allow for that. For example, this code works (producing the custom error on failure) but the string is highlighted with the LLS warning "This function expects a maximum of 1 argument(s) but instead it is receiving 2. Lua Diagnostics.(redundant-parameter)"
local crumb = self.engine:poll()
assert.is_nil(crumb, 'Expected nil end of event queue')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.