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

pkg/matcher: isEmpty etc should not do any type checks #21792

Closed
DartBot opened this Issue Dec 4, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@DartBot
Copy link

DartBot commented Dec 4, 2014

This issue was originally filed by bl...@google.com


There are custom collections (like ListMultimap in quiver or RigidMap) that implement interfaces which are unknown to matcher. The matchers would be more useful and more easily understandable by removing all type checks from them:

class _Empty extends Matcher {
  const _Empty();
  bool matches(item, Map matchState) {
    return item.isEmpty;
  }
  Description describe(Description description) => description.add('empty');
}

This would be also match initial expectations. Obviously, there is a change in semantics (if the object has no isEmpty property, an exception will be thrown), but this is useful:
This also fixes the other bug (https://code.google.com/p/dart/issues/detail?id=21562) because isNot(isEmpty) on a null object would also throw an exception and fail the expect call instead of passing.

I'm happy to provide a patch for isEmpty (and isNotEmpty as soon as it is submitted).

Thanks,
 Andreas

@kevmoo

This comment has been minimized.

Copy link
Member

kevmoo commented Dec 5, 2014

This sounds reasonable to me: this Matcher would map to the .isEmpty property – no more or less.


Added Pkg-matcher, Area-Pkg, PatchesWelcome labels.

@kevmoo

This comment has been minimized.

Copy link
Member

kevmoo commented Jan 17, 2015

@DartBot

This comment has been minimized.

Copy link

DartBot commented Jun 5, 2015

This issue has been moved to dart-lang/matcher#24.

This issue was closed.

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