mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Update and tests for %RegExpPrototype% methods
A recent web-compatability change to ECMA262 modified the semantics of the accessor methods on the %RegExpPrototype% intrinsic--the "get" accessors now include steps dedicated to the case where the "this" value is the %RegExpPrototype% object itself. Remove the tests that have been invalidated by this change, introduce tests asserting the new behavior, and extend coverage for other possible "this" values.
This commit is contained in:
parent
9114f815a0
commit
e1cd1e7f85
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 15.10.7.2-1
|
||||
description: RegExp.prototype.global is a non-generic accessor property
|
||||
---*/
|
||||
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
RegExp.prototype.global;
|
||||
});
|
27
test/built-ins/RegExp/prototype/global/this-val-invalid-obj.js
vendored
Normal file
27
test/built-ins/RegExp/prototype/global/this-val-invalid-obj.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.global
|
||||
es6id: 21.2.5.4
|
||||
description: A TypeError is thrown when the "this" value is an invalid Object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return undefined.
|
||||
b. Otherwise, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'global').get;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call({});
|
||||
}, 'ordinary object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call([]);
|
||||
}, 'array exotic object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(arguments);
|
||||
}, 'arguments object');
|
38
test/built-ins/RegExp/prototype/global/this-val-non-obj.js
vendored
Normal file
38
test/built-ins/RegExp/prototype/global/this-val-non-obj.js
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.global
|
||||
es6id: 21.2.5.4
|
||||
description: A TypeError is thrown when the "this" value is not an Object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'global').get;
|
||||
var symbol = Symbol();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(undefined);
|
||||
}, 'undefined');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(null);
|
||||
}, 'null');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(3);
|
||||
}, 'number');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call('string');
|
||||
}, 'string');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(true);
|
||||
}, 'boolean');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(symbol);
|
||||
}, 'symbol');
|
17
test/built-ins/RegExp/prototype/global/this-val-regexp-prototype.js
vendored
Normal file
17
test/built-ins/RegExp/prototype/global/this-val-regexp-prototype.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.global
|
||||
description: >
|
||||
Return value of `undefined` when the "this" value is the RegExp prototype
|
||||
object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return undefined.
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'global').get;
|
||||
|
||||
assert.sameValue(get.call(RegExp.prototype), undefined);
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 15.10.7.3-1
|
||||
description: RegExp.prototype.ignoreCase is a non-generic accessor property
|
||||
---*/
|
||||
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
RegExp.prototype.ignoreCase;
|
||||
});
|
27
test/built-ins/RegExp/prototype/ignoreCase/this-val-invalid-obj.js
vendored
Normal file
27
test/built-ins/RegExp/prototype/ignoreCase/this-val-invalid-obj.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.ignorecase
|
||||
es6id: 21.2.5.5
|
||||
description: A TypeError is thrown when the "this" value is an invalid Object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return undefined.
|
||||
b. Otherwise, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'ignoreCase').get;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call({});
|
||||
}, 'ordinary object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call([]);
|
||||
}, 'array exotic object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(arguments);
|
||||
}, 'arguments object');
|
38
test/built-ins/RegExp/prototype/ignoreCase/this-val-non-obj.js
vendored
Normal file
38
test/built-ins/RegExp/prototype/ignoreCase/this-val-non-obj.js
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.ignorecase
|
||||
es6id: 21.2.5.5
|
||||
description: A TypeError is thrown when the "this" value is not an Object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'ignoreCase').get;
|
||||
var symbol = Symbol();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(undefined);
|
||||
}, 'undefined');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(null);
|
||||
}, 'null');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(3);
|
||||
}, 'number');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call('string');
|
||||
}, 'string');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(true);
|
||||
}, 'boolean');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(symbol);
|
||||
}, 'symbol');
|
17
test/built-ins/RegExp/prototype/ignoreCase/this-val-regexp-prototype.js
vendored
Normal file
17
test/built-ins/RegExp/prototype/ignoreCase/this-val-regexp-prototype.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.ignorecase
|
||||
description: >
|
||||
Return value of `undefined` when the "this" value is the RegExp prototype
|
||||
object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return undefined.
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'ignoreCase').get;
|
||||
|
||||
assert.sameValue(get.call(RegExp.prototype), undefined);
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 15.10.7.4-1
|
||||
description: RegExp.prototype.multiline is a non-generic accessor property
|
||||
---*/
|
||||
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
RegExp.prototype.multiline;
|
||||
});
|
27
test/built-ins/RegExp/prototype/multiline/this-val-invalid-obj.js
vendored
Normal file
27
test/built-ins/RegExp/prototype/multiline/this-val-invalid-obj.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.multiline
|
||||
es6id: 21.2.5.7
|
||||
description: A TypeError is thrown when the "this" value is an invalid Object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return undefined.
|
||||
b. Otherwise, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'multiline').get;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call({});
|
||||
}, 'ordinary object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call([]);
|
||||
}, 'array exotic object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(arguments);
|
||||
}, 'arguments object');
|
38
test/built-ins/RegExp/prototype/multiline/this-val-non-obj.js
vendored
Normal file
38
test/built-ins/RegExp/prototype/multiline/this-val-non-obj.js
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.multiline
|
||||
es6id: 21.2.5.7
|
||||
description: A TypeError is thrown when the "this" value is not an Object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'multiline').get;
|
||||
var symbol = Symbol();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(undefined);
|
||||
}, 'undefined');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(null);
|
||||
}, 'null');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(3);
|
||||
}, 'number');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call('string');
|
||||
}, 'string');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(true);
|
||||
}, 'boolean');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(symbol);
|
||||
}, 'symbol');
|
17
test/built-ins/RegExp/prototype/multiline/this-val-regexp-prototype.js
vendored
Normal file
17
test/built-ins/RegExp/prototype/multiline/this-val-regexp-prototype.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.multiline
|
||||
description: >
|
||||
Return value of `undefined` when the "this" value is the RegExp prototype
|
||||
object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return undefined.
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'multiline').get;
|
||||
|
||||
assert.sameValue(get.call(RegExp.prototype), undefined);
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 15.10.7.1-1
|
||||
description: RegExp.prototype.source is a non-generic accessor property
|
||||
---*/
|
||||
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
RegExp.prototype.source;
|
||||
});
|
27
test/built-ins/RegExp/prototype/source/this-val-invalid-obj.js
vendored
Normal file
27
test/built-ins/RegExp/prototype/source/this-val-invalid-obj.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.source
|
||||
es6id: 21.2.5.10
|
||||
description: A TypeError is thrown when the "this" value is an invalid Object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return "(?:)".
|
||||
b. Otherwise, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source').get;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call({});
|
||||
}, 'ordinary object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call([]);
|
||||
}, 'array exotic object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(arguments);
|
||||
}, 'arguments object');
|
38
test/built-ins/RegExp/prototype/source/this-val-non-obj.js
vendored
Normal file
38
test/built-ins/RegExp/prototype/source/this-val-non-obj.js
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.source
|
||||
es6id: 21.2.5.10
|
||||
description: A TypeError is thrown when the "this" value is not an Object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source').get;
|
||||
var symbol = Symbol();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(undefined);
|
||||
}, 'undefined');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(null);
|
||||
}, 'null');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(3);
|
||||
}, 'number');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call('string');
|
||||
}, 'string');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(true);
|
||||
}, 'boolean');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
get.call(symbol);
|
||||
}, 'symbol');
|
17
test/built-ins/RegExp/prototype/source/this-val-regexp-prototype.js
vendored
Normal file
17
test/built-ins/RegExp/prototype/source/this-val-regexp-prototype.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.source
|
||||
description: >
|
||||
Return value of `undefined` when the "this" value is the RegExp prototype
|
||||
object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return "(?:)".
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source').get;
|
||||
|
||||
assert.sameValue(get.call(RegExp.prototype), '(?:)');
|
@ -17,4 +17,12 @@ var sticky = Object.getOwnPropertyDescriptor(RegExp.prototype, 'sticky').get;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sticky.call({});
|
||||
});
|
||||
}, 'ordinary object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sticky.call([]);
|
||||
}, 'array exotic object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sticky.call(arguments);
|
||||
}, 'arguments object');
|
17
test/built-ins/RegExp/prototype/sticky/this-val-regexp-prototype.js
vendored
Normal file
17
test/built-ins/RegExp/prototype/sticky/this-val-regexp-prototype.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.sticky
|
||||
description: >
|
||||
Return value of `undefined` when the "this" value is the RegExp prototype
|
||||
object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return undefined.
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'sticky').get;
|
||||
|
||||
assert.sameValue(get.call(RegExp.prototype), undefined);
|
@ -17,4 +17,12 @@ var unicode = Object.getOwnPropertyDescriptor(RegExp.prototype, 'unicode').get;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
unicode.call({});
|
||||
});
|
||||
}, 'ordinary object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
unicode.call([]);
|
||||
}, 'array exotic object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
unicode.call(arguments);
|
||||
}, 'arguments object');
|
17
test/built-ins/RegExp/prototype/unicode/this-val-regexp-prototype.js
vendored
Normal file
17
test/built-ins/RegExp/prototype/unicode/this-val-regexp-prototype.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-regexp.prototype.unicode
|
||||
description: >
|
||||
Return value of `undefined` when the "this" value is the RegExp prototype
|
||||
object
|
||||
info: |
|
||||
1. Let R be the this value.
|
||||
2. If Type(R) is not Object, throw a TypeError exception.
|
||||
3. If R does not have an [[OriginalFlags]] internal slot, then
|
||||
a. If SameValue(R, %RegExpPrototype%) is true, return undefined.
|
||||
---*/
|
||||
|
||||
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'unicode').get;
|
||||
|
||||
assert.sameValue(get.call(RegExp.prototype), undefined);
|
Loading…
x
Reference in New Issue
Block a user