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

Check that result contains expected allergens #134

Merged
merged 2 commits into from
May 31, 2016
Merged

Check that result contains expected allergens #134

merged 2 commits into from
May 31, 2016

Conversation

taravancil
Copy link
Contributor

Fixes #130

Testing for all allergies would fail if the allergens weren't in the
same order as the test vector.

This checks that the result contains all the expected allergens rather
than expecting the result and test vector to be equal.

Fixes #130

Testing for all allergies would fail if the allergens weren't in the
same order as the test vector.

This checks that the result contains all the expected allergens rather
than expecting the result and test vector to be equal.
@IanWhitney
Copy link
Contributor

Good change!

I would add one more test: that all and allergies have the same number of elements. If allergies contains Eggs twice, for example, it'd pass that test but still have a failure somewhere in its implementation.

@kytrinyx
Copy link
Member

Are we missing this test in https://github.com/exercism/x-common/blob/master/allergies.json?

@taravancil
Copy link
Contributor Author

Oh wait, do you mean check that all and allergies have the same number of elements in a completely different test? I think that makes more sense.

@IanWhitney
Copy link
Contributor

Same test or different test, I don't think I have a strong opinion. I'm happy to merge this as-is.

@kytrinyx, I think the tests in the json file are fine. This is just a way to make the canonical tests work for Rust, while still handling the weird edge case that could emerge because of our testing approach.

@taravancil
Copy link
Contributor Author

Great! I'll leave it alone then. No need to over-complicate things.

@taravancil taravancil closed this May 30, 2016
@taravancil taravancil reopened this May 30, 2016
@IanWhitney IanWhitney merged commit 7b1d5d7 into exercism:master May 31, 2016
@IanWhitney
Copy link
Contributor

Fireworks. Marching Bands. Etc. Thank you!

IanWhitney pushed a commit to IanWhitney/xrust that referenced this pull request Jun 6, 2016
Fixes exercism#135

- Introducing tests that were missing
- Handling the ordering problem in all tests that check vectors,
  encapsulating the solution introduced in exercism#134
- Updating test names to not start with `test_`
        - Cargo starts each test result line with "test ", followed by
          the test's name.. So these tests looked like "test
          test_allergic_to_peanuts".
- Trying to give the final test a useful name. "ignore non allergen
  score parts" didn't make much sense to me when I worked on this
  exercise. I think the new name better describes what we're trying to
  capture.
IanWhitney pushed a commit to IanWhitney/xrust that referenced this pull request Jun 11, 2016
Fixes exercism#135

- Introducing tests that were missing
- Handling the ordering problem in all tests that check vectors,
  encapsulating the solution introduced in exercism#134
- Updating test names to not start with `test_`
        - Cargo starts each test result line with "test ", followed by
          the test's name.. So these tests looked like "test
          test_allergic_to_peanuts".
- Trying to give the final test a useful name. "ignore non allergen
  score parts" didn't make much sense to me when I worked on this
  exercise. I think the new name better describes what we're trying to
  capture.
IanWhitney added a commit that referenced this pull request Jun 11, 2016
* Update tests to canonical set

Fixes #135

- Introducing tests that were missing
- Handling the ordering problem in all tests that check vectors,
  encapsulating the solution introduced in #134
- Updating test names to not start with `test_`
        - Cargo starts each test result line with "test ", followed by
          the test's name.. So these tests looked like "test
          test_allergic_to_peanuts".
- Trying to give the final test a useful name. "ignore non allergen
  score parts" didn't make much sense to me when I worked on this
  exercise. I think the new name better describes what we're trying to
  capture.

Testing iterator equality seems like a nicer way of comparing these two
vectors. And I'm now returning a useful error message when the vectors
are not equal.

If you do

```rust
assert_eq!(expected.iter().eq(actual.iter()))
```

The error message is just that the two iterators are not equal. The
differing elements are not called out in any way. Not as helpful.
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 this pull request may close these issues.

None yet

3 participants