Skip to content

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

@younata

Description

@younata

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions