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

allPass and beNil can't work together #388

Closed
1 task done
nandin-borjigin opened this issue Jan 12, 2017 · 5 comments · Fixed by #894
Closed
1 task done

allPass and beNil can't work together #388

nandin-borjigin opened this issue Jan 12, 2017 · 5 comments · Fixed by #894
Assignees

Comments

@nandin-borjigin
Copy link

nandin-borjigin commented Jan 12, 2017

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

What did you do?

let a: Double? = nil
let b: Double? = nil
expect([a, b]).to(allPass(beNil()))

What did you expect to happen?

The expectation should pass

What actually happened instead?

It fails instead

Environment

  • Quick: Irrelevant
  • Nimble: 1.0 Nimble-iOS
  • Xcode Version: Version 8.2.1 (8C1002)
  • Swift Version: Xcode Default
  • Package manager : None, only using git submodule

Project that demonstrates the issue

Three line of code shown above will reproduce the issue

@sigito
Copy link
Contributor

sigito commented Jan 12, 2017

According to AllPassTest WAI

@nandin-borjigin
Copy link
Author

nandin-borjigin commented Jan 12, 2017

Okay, then why? Expecting [nil, nil, nil] to allPass a beNil() matcher is intuitive, isn't it?

@jeffh
Copy link
Member

jeffh commented Jan 18, 2017

This is a bug. It was a limitation of an older implementation of Nimble that I think isn't a problem anymore.

@jeffh jeffh added the bug label Jan 24, 2017
@jeffh
Copy link
Member

jeffh commented Jan 24, 2017

Hm, it's still a problem with the type hierarchy ATM. Perhaps a future release a Nimble will properly handle this situation.

@ikesyo
Copy link
Member

ikesyo commented Jun 28, 2018

This is still happening in 2018. Looks like the problem here is that the type evaluated in beNil() is Double?? and the value is Optional.some(.none) so that value does not satisfy beNil() matcher.

  • beNil<T>() -> Predicate<T> is evaluated as beNil<Double?>() -> Predicate<Double?>
  • So let actualValue = try actualExpression.evaluate() is Double??
  • actualValue == nil will be false because the actualValue is Optional<Double?>.some(.none) which is not nil in that context

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

Successfully merging a pull request may close this issue.

4 participants