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

expect(nil).toAlways(equal(0)) incorrectly succeeds #1120

Closed
1 task done
defagos opened this issue Feb 23, 2024 · 5 comments · Fixed by #1121
Closed
1 task done

expect(nil).toAlways(equal(0)) incorrectly succeeds #1120

defagos opened this issue Feb 23, 2024 · 5 comments · Fixed by #1121

Comments

@defagos
Copy link

defagos commented Feb 23, 2024

  • I have read CONTRIBUTING and have done my best to follow them.

What did you do?

Consider the following expectation:

func testExpectNilToAlwaysEqualZero() {
    expect(nil).toAlways(equal(0))
}

You would expect a test failure but the test actually succeeds.

The issue is likely associated with polling since the following expectation fails as expected:

func testExpectNilToEqualZero() {
    expect(nil).to(equal(0))
}

What did you expect to happen?

The expectation in testExpectNilToAlwaysEqualZero() above must fail.

What actually happened instead?

The expectation in testExpectNilToAlwaysEqualZero() above incorrectly succeeds.

Environment

  • Nimble: 13.2.0
  • Xcode Version: 15.2.0
  • Swift Version: 5.9.2
  • Swift Package Manager 5.9.0
@younata
Copy link
Member

younata commented Feb 23, 2024

Thanks for identifying this!

@younata
Copy link
Member

younata commented Feb 24, 2024

After looking into this more, this type of issue also applies to toNever. Lovely.

@defagos
Copy link
Author

defagos commented Feb 24, 2024

Thanks for your answer.

As a temporary workaround it is possible to force-unwrap potentially nullable values in related expectations so that mismatches at least do not get unnoticed:

expect(somePotentiallyNilValue!).toAlways(equal(1234))

@younata
Copy link
Member

younata commented Feb 25, 2024

This is now fixed in Nimble 13.2.1.

@defagos
Copy link
Author

defagos commented Feb 25, 2024

Thank you very much for the quick fix, really appreciated!

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

Successfully merging a pull request may close this issue.

2 participants