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

Combinatoric matchers produce confusing output in some cases #47

Open
jimporter opened this issue Sep 2, 2020 · 0 comments
Open

Combinatoric matchers produce confusing output in some cases #47

jimporter opened this issue Sep 2, 2020 · 0 comments
Milestone

Comments

@jimporter
Copy link
Owner

If you use a combinatoric matcher (e.g. all) and one of the sub-matchers returns a match_result that causes the matcher to fail, the "actual" value reported is whatever that match_result declared. This is generally wrong, since that value is probably only relevant to one of the sub-matchers, and doesn't show the entire value. For example:

struct thing {
  std::string name;
  std::vector<int> values;
};

expect(thing, all(
  filter([](thing &x) { return x.name; }, equal_to("name")),
  filter([](thing &x) { return x.values}, array(1, 2, 3))
));

This might print:

    expected: all of("name", [1, 2, 3])
    actual:   "bad"

The easy way to fix this would be for combinatoric matchers to return bools all the time, so that the full object is printed. However, there might be a better way that lets us see all the match_results. Maybe we should stop short-circuiting the combinatoric matchers too?

@jimporter jimporter added this to the 0.2 milestone Sep 2, 2020
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