Giter VIP home page Giter VIP logo

luassert's People

Contributors

carsakiller avatar fesily avatar sumneko avatar

Stargazers

 avatar

Forkers

josef-friedrich

luassert's Issues

assert.stub/spy do not accept a function argument

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 annotations are missing optional assertion message as a parameter

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')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.