Skip to content

Add tests for Array.prototype.includes#643

Closed
leobalter wants to merge 10 commits into
tc39:masterfrom
bocoup:array-includes
Closed

Add tests for Array.prototype.includes#643
leobalter wants to merge 10 commits into
tc39:masterfrom
bocoup:array-includes

Conversation

@leobalter

Copy link
Copy Markdown
Member

No description provided.

@leobalter

Copy link
Copy Markdown
Member Author

I missed tests for non-number values of length and out of range values as well. I'll add them.

@jugglinmike

Copy link
Copy Markdown
Contributor

Alright; I'll hold off on reviewing until you're ready

@leobalter

Copy link
Copy Markdown
Member Author

It's done. But I've got this change I didn't like to avoid breaking runtimes around 2**53. Without a fromIndex I got issues with V8, SM, es6draft, etc.

8. Return false.
---*/

var sample = new Array(42).map(function() { return 7; });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This complexity doesn't really add much value, and it's a little inconsistent with the way you seed arrays in other tests. Would you be satisfied with something like var sample = [7, 7, 7, 7];?

@jugglinmike

Copy link
Copy Markdown
Contributor

Just a few suggestions for this one Leo. We're almost done with arrays!

@leobalter

Copy link
Copy Markdown
Member Author

One extra test I missed: values are not cached

@leobalter

Copy link
Copy Markdown
Member Author

fixes are up including the missing test

assert.sameValue([].includes.call(obj, "ecma262"), true, "'ecma262' is true");

obj = getCleanObj();
assert.sameValue([].includes.call(obj, "cake"), false, "'cake' is false");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cake is a lie

}
});
obj[1] = "ecma262";
obj[2] = "tc39";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As nice as the simplification is, this change invalidated the test. The final assertion in this file expects obj[2] to have the value "cake", but (after this change) it actually takes the value "tc39".

@jugglinmike

Copy link
Copy Markdown
Contributor

The newest test is now invalid (my in-line comment is above but rendering as collapsed for some reason). If we address that problem, this patch should be ready to land.

@leobalter

Copy link
Copy Markdown
Member Author

oops. It looked as such an easy change I didn't test, I should never guess something is just a piece of cake.

@jugglinmike

Copy link
Copy Markdown
Contributor

I was just checking this patch for coverage parity with gh-95 and found that this version is missing a test for the extension of Array.prototype[@@unscopables]. Could you add a test for that? Can you also check for additional tests that we may have missed in this version?

This makes me wonder (a little late, now that gh-641 has landed) if it would be better to use gh-95 as a "base" and work from there. Probably you considered this prior to starting. Can you say a bit about why you preferred a fresh start?

@leobalter

Copy link
Copy Markdown
Member Author

I was just checking this patch for coverage parity with gh-95 and found that this version is missing a test for the extension of Array.prototype[@@unscopables]

oops, I missed that.

Could you add a test for that? Can you also check for additional tests that we may have missed in this version?

yes, yes

This makes me wonder (a little late, now that gh-641 has landed) if it would be better to use gh-95 as a "base" and work from there. Probably you considered this prior to starting. Can you say a bit about why you preferred a fresh start?

I used it as a quick reference only, but I preferred using the other tests for typedArray methods (mostly indexOf) as the base for the tests on gh-641, and then I reused them for this one. I've done a coverage check in a piece of paper, as I've been doing to check coverage on other tests to find missing parts for the steps of Array#includes and quickly compared with what we have on gh-95, that's where I missed unscopables.

@leobalter

Copy link
Copy Markdown
Member Author

the test for unscopables is up

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.

2 participants