assert calls order for Symbol.match on matchAll usage (#1795)

Fix #1794
This commit is contained in:
Leo Balter 2018-09-26 11:37:19 -04:00 committed by GitHub
parent 37190a1deb
commit d544eacedf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 5 deletions

View File

@ -25,16 +25,32 @@ Object.defineProperty(RegExp.prototype, Symbol.match, {
}
});
var count = 0;
var calls = [];
var o = {
get [Symbol.match]() {
++count;
calls.push('get @@match');
return false;
},
flags: "",
get flags() {
calls.push('get flags');
return {
toString() {
calls.push('flags toString');
}
};
},
};
RegExp.prototype[Symbol.matchAll].call(o, '1');
RegExp.prototype[Symbol.matchAll].call(o, {
toString() {
calls.push('arg toString')
}
});
assert.sameValue(0, internalCount);
assert.sameValue(1, count);
assert.sameValue(calls.length, 4);
assert.sameValue(calls[0], 'get @@match');
assert.sameValue(calls[1], 'arg toString');
assert.sameValue(calls[2], 'get flags');
assert.sameValue(calls[3], 'flags toString');