Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

tests/arrays: Assert that result does not equal original. #56

Closed
wants to merge 1 commit into from

3 participants

@Krinkle

Without this assertion, the simple implementation (where there is no copy being made) will pass for both remove and removeWithoutCopy.

@rmurphey rmurphey commented on the diff
tests/app/arrays.js
@@ -27,6 +27,9 @@ define([
expect(result).to.have.length(3);
expect(result.join(' ')).to.eql('1 3 4');
+
+ // make sure that you didn't change the original array instance
+ expect(result).not.to.equal(a);
@rmurphey Owner
rmurphey added a note

A better test would be to ensure that the original array is unmodified, because that's what we really care about. Can you just do this in #58 and we can close this issue?

@Krinkle
Krinkle added a note

It is rather unlikely that an implementation will both make a copy and then modify both and return the copy. But ensuring the original is unmodified makes sense.

@Krinkle
Krinkle added a note

#58 and #59 are different pulls that include this due to merge conflicts, unrelated otherwise. Or do you want me to squash them into one pull request? (people usually prefer to keep them atomic and easy to review)

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

See #59.

@Krinkle Krinkle closed this
@beeeswax

I was just about to submit a pull request for this same change! :smile:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  tests/app/arrays.js
View
3  tests/app/arrays.js
@@ -27,6 +27,9 @@ define([
expect(result).to.have.length(3);
expect(result.join(' ')).to.eql('1 3 4');
+
+ // make sure that you didn't change the original array instance
+ expect(result).not.to.equal(a);
@rmurphey Owner
rmurphey added a note

A better test would be to ensure that the original array is unmodified, because that's what we really care about. Can you just do this in #58 and we can close this issue?

@Krinkle
Krinkle added a note

It is rather unlikely that an implementation will both make a copy and then modify both and return the copy. But ensuring the original is unmodified makes sense.

@Krinkle
Krinkle added a note

#58 and #59 are different pulls that include this due to merge conflicts, unrelated otherwise. Or do you want me to squash them into one pull request? (people usually prefer to keep them atomic and easy to review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
});
it('you should be able to remove a value from an array, returning the original array', function() {
Something went wrong with that request. Please try again.