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

[regexp-named-groups] Expand tests for groups property #1376

Merged
merged 1 commit into from
Dec 20, 2017

Conversation

mathiasbynens
Copy link
Member

The groups property must be created unconditionally per tc39/proposal-regexp-named-groups#40.

This patch ports @schuay’s tests from https://chromium.googlesource.com/v8/v8.git/+/d2f95e189c3209408525c88e2893d16c09724159.

cc @littledan

Copy link
Member

@littledan littledan left a comment

Choose a reason for hiding this comment

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

Tests look correct to me, so approved from my perspective.

It'd be nice to check that groups is a data property in the case of RegExps that don't have named capture groups. You can do this using the verifyProperty helper function used further down in the file.

In the review for #998, @leobalter encouraged me to break up the tests into several small files. Seems like you could keep following that here and put what you're adding into a new file, with this file dedicated to testing the new path and maintaining the existing file to test the other path.

@@ -1,4 +1,5 @@
// Copyright 2017 Aleksey Shvayka. All rights reserved.
// Copyright 2017 Mathias Bynens. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

FWIW other contributions from the V8 team came with "the V8 project authors" as the author, like the V8 source code.

@mathiasbynens
Copy link
Member Author

Feedback addressed. Thanks for taking a look, @littledan!

assert.sameValue("b", result.groups.a);
assert.sameValue("b", "ab".replace(re, "$<a>"));
assert.sameValue("c", "ab".replace(re, "$<b>"));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Each of these blocks could be a different file. This is not a blocker, and I will likely do it myself after I land this, but I figure I should give you the opportunity to make the split the way you want to. Let me know what you want to do.

Copy link
Member Author

Choose a reason for hiding this comment

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

@rwaldron I’ll do the split — no worries! Naming things is hard, though… Gotta think of a good file name :)

a. Let _groups_ be ObjectCreate(*null*).
25. Else,
a. Let _groups_ be *undefined*.
26. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
Copy link
Contributor

Choose a reason for hiding this comment

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

<3

@rwaldron
Copy link
Contributor

@mathiasbynens be sure you @ mention me when you reply to my comment—thanks!

@mathiasbynens
Copy link
Member Author

@rwaldron Split it up into separate files. PTAL

@rwaldron rwaldron merged commit 7446e88 into tc39:master Dec 20, 2017
@rwaldron
Copy link
Contributor

@mathiasbynens you're the best, thank you.

@schuay
Copy link
Contributor

schuay commented Dec 21, 2017

@mathiasbynens you're the best, thank you.

+1, thanks! :)

@mathiasbynens
Copy link
Member Author

Thanks to @schuay for writing these tests in the first place, as part of his work on implementing this change in V8! 💯

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.

4 participants