Skip to content

Commit

Permalink
Merge pull request #1587 from peterwmwong/update-matchall
Browse files Browse the repository at this point in the history
Update tests for String.prototype.matchAll
  • Loading branch information
rwaldron authored Jun 8, 2018
2 parents bb24a39 + bbad948 commit f90a52b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 72 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: pending
description: Throws TypeError when internally created RegExp's @@match is false
description: IsRegExp should only be called once
info: |
RegExp.prototype [ @@matchAll ] ( string )
[...]
Expand All @@ -13,17 +13,28 @@ info: |
2. If ? IsRegExp(R) is true, then
[...]
3. Else,
a. Let matcher be RegExpCreate(R, "g").
b. If ? IsRegExp(matcher) is not true, throw a TypeError exception.
a. Let flags be "g".
b. Let matcher be ? RegExpCreate(R, flags).
features: [Symbol.match, Symbol.matchAll]
---*/

var internalCount = 0;
Object.defineProperty(RegExp.prototype, Symbol.match, {
get() {
return false;
get: function() {
++internalCount;
return true;
}
});

assert.throws(TypeError, function() {
RegExp.prototype[Symbol.matchAll].call({}, '');
});
var count = 0;
var o = {
get [Symbol.match]() {
++count;
return false;
}
};

RegExp.prototype[Symbol.matchAll].call(o, '1');

assert.sameValue(0, internalCount);
assert.sameValue(1, count);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ info: |
2. If ? IsRegExp(R) is true, then
[...]
3. Else,
a. Let R be RegExpCreate(R, "g").
a. Let flags be "g".
b. Let matcher be ? RegExpCreate(R, flags).
features: [Symbol.matchAll]
---*/

Expand Down
2 changes: 1 addition & 1 deletion test/built-ins/Symbol/matchAll/prop-desc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info: |
This property has the attributes { [[Writable]]: false, [[Enumerable]]:
false, [[Configurable]]: false }.
includes: [propertyHelper.js]
features: [Symbol.match]
features: [Symbol.matchAll]
---*/

assert.sameValue(typeof Symbol.matchAll, 'symbol');
Expand Down

0 comments on commit f90a52b

Please sign in to comment.