Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect expect error "not" messages #6

Open
luttje opened this issue Apr 27, 2023 · 0 comments
Open

Incorrect expect error "not" messages #6

luttje opened this issue Apr 27, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@luttje
Copy link
Owner

luttje commented Apr 27, 2023

Most expects do not check for self.inverse to see if the error should say it did 'not' match expected value. This causes confusing errors when using the ["not"] modifier.

Atm each matcher needs to manually check and format the error with something like .. (expect.inverse and " not" or "") ..

It would be nicer if (like expect:checkEquals) there is a expect:throwUnexpected. Or that the checkEquals would work more like a guardEquals like this:

local function toBe(expect, expected)
  local actual = expect.actual

  -- Old:
  -- if not expect:checkEquals(actual, expected) then
  --   error("Expected " .. tostring(actual) .. (expect.inverse and " not " or "") .. " to be " .. tostring(expected))
  -- end

  -- New concept:
  expect:guardEquality(actual, expected, "to be")

  return true
end
@luttje luttje added the bug Something isn't working label Apr 27, 2023
@luttje luttje self-assigned this Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant