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

require(nil).to(beNil()) will incorrectly fail & throw an error. #1125

Open
younata opened this issue Mar 1, 2024 · 0 comments
Open

require(nil).to(beNil()) will incorrectly fail & throw an error. #1125

younata opened this issue Mar 1, 2024 · 0 comments

Comments

@younata
Copy link
Member

younata commented Mar 1, 2024

This test fails, with the contradictory error "expected to be nil, got <nil>":

func testRequireNil() throws {
    expect {
        try require(nil as Int?).to(beNil())
    }.toNot(throwError())
}

Which ultimately comes down to us being unable to unwrap nil (because... it's nil!) in (Sync|Async)Requirement.verify (highlighted is the sync variant, but the Async one has the same logic and therefore, same issue): https://github.com/Quick/Nimble/blob/v13.2.1/Sources/Nimble/Requirement.swift#L88-L95

So... that's fun and unexpected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant