Skip to content

Bundled luassert definitions reject valid calls: message argument, spy.calls, equals/errors aliases #3505

Open

Description

@lex57ukr

How are you using the lua-language-server?

Command Line (--check), and VS Code

Which OS are you using?

Linux (Debian, in a container) and macOS

What is the issue affecting?

Libraries

Expected Behaviour

The bundled meta/3rd/luassert definitions accept what luassert 1.9 accepts, so --check over a busted suite reports nothing for valid calls.

Actual Behaviour

lua-language-server 3.19.2, with workspace.library set to ${3rd}/busted/library and ${3rd}/luassert/library:

  1. No failure message on single-value assertions. internal.True, False, Nil, truthy, falsy, the type predicates and every alias bound to them (is_nil, is_not_nil, is_true, is_truthy, …) take one parameter, so assert.is_nil(x, "why") reports redundant-parameter. luassert takes a message after the value.
  2. No calls on a spy. luassert.spy declares no calls, so for _, call in ipairs(s.calls) do ... call.vals[1] ... end reports undefined-field.
  3. Missing aliases. assert.equals(a, b) and assert.has_no.errors(fn) report undefined-field; luassert registers both.
  4. stub declared twice. stub.lua declares local stub = {} as luassert.stub, then function stub(object, key, ...), so require("luassert.stub").new(...) reports undefined-field for new.

Reproduction steps

describe("luassert", function()
  it("checks", function()
    assert.is_nil(nil, "a message")      -- redundant-parameter
    assert.equals(1, 1)                  -- undefined-field
    assert.has_no.errors(function() end) -- undefined-field
    local s = spy.new(function() end)
    s(1)
    local _ = s.calls[1].vals[1]         -- undefined-field
  end)
end)

Run lua-language-server --check=. with:

{ "workspace.library": ["${3rd}/busted/library", "${3rd}/luassert/library"] }

Additional Notes

Related to #3176: in this setup assert does type as luassert, but only while runtime.path keeps its default ?.lua and ?/init.lua; replacing them leaves the busted library's require("luassert") unresolved and assert falls back to the builtin function.

Log File

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions