mirror of https://github.com/tc39/test262.git
Improve RegExp.prototype.source coverage (#1145)
This commit is contained in:
parent
4a9c9e9886
commit
4327cdb207
|
@ -1,26 +0,0 @@
|
||||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
info: The RegExp.prototype source property does not have a set accessor
|
|
||||||
es5id: 15.10.7.1_A10
|
|
||||||
description: Checking if varying the source property fails
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var __re = RegExp.prototype;
|
|
||||||
|
|
||||||
//CHECK#1
|
|
||||||
if (__re.hasOwnProperty('source') !== true) {
|
|
||||||
$ERROR('#1: __re = RegExp.prototype; __re.hasOwnProperty(\'source\') === true');
|
|
||||||
}
|
|
||||||
|
|
||||||
var __sample = /./;
|
|
||||||
var __obj = __sample.source;
|
|
||||||
|
|
||||||
verifyNotWritable(__sample, "source", "source", "shifted");
|
|
||||||
|
|
||||||
//CHECK#2
|
|
||||||
if (__sample.source !== __obj) {
|
|
||||||
$ERROR('#2: __sample = /./; __obj = __sample.source; __sample.source = "shifted"; __sample.source === __obj. Actual: ' + (__sample.source));
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
info: The RegExp.prototype source property has the attribute DontEnum
|
|
||||||
es5id: 15.10.7.1_A8
|
|
||||||
description: >
|
|
||||||
Checking if enumerating the source property of RegExp.prototype
|
|
||||||
fails
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var __re = RegExp.prototype;
|
|
||||||
|
|
||||||
//CHECK#0
|
|
||||||
if (__re.hasOwnProperty('source') !== true) {
|
|
||||||
$ERROR('#0: __re = RegExp.prototype; __re.hasOwnProperty(\'source\') === true');
|
|
||||||
}
|
|
||||||
|
|
||||||
//CHECK#1
|
|
||||||
if (__re.propertyIsEnumerable('source') !== false) {
|
|
||||||
$ERROR('#1: __re = RegExp.prototype; __re.propertyIsEnumerable(\'source\') === false');
|
|
||||||
}
|
|
||||||
|
|
||||||
//CHECK#2
|
|
||||||
var count = 0
|
|
||||||
for (var p in __re){
|
|
||||||
if (p==="source") count++
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count !== 0) {
|
|
||||||
$ERROR('#2: count = 0; __re = RegExp.prototype; for (p in __re){ if (p==="source") count++; } count === 0. Actual: ' + (count));
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
info: >
|
|
||||||
The RegExp.prototype source property does not have the attribute
|
|
||||||
DontDelete
|
|
||||||
es5id: 15.10.7.1_A9
|
|
||||||
description: Checking if deleting the source property succeeds
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var __re = RegExp.prototype;
|
|
||||||
|
|
||||||
//CHECK#0
|
|
||||||
if (__re.hasOwnProperty('source') !== true) {
|
|
||||||
$ERROR('#0: __re = RegExp.prototype; __re.hasOwnProperty(\'source\') === true');
|
|
||||||
}
|
|
||||||
|
|
||||||
//CHECK#1
|
|
||||||
if ((delete __re.source) !== true) {
|
|
||||||
$ERROR('#1: __re = RegExp.prototype; (delete __re.source) === true');
|
|
||||||
}
|
|
||||||
|
|
||||||
//CHECK#2
|
|
||||||
if (__re.hasOwnProperty('source') !== false) {
|
|
||||||
$ERROR('#2: __re = RegExp.prototype;delete __re.source === true; __re.hasOwnProperty(\'source\') === false');
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-get-regexp.prototype.source
|
||||||
es6id: 21.2.5.10
|
es6id: 21.2.5.10
|
||||||
description: >
|
description: >
|
||||||
get RegExp.prototype.source.length is 0.
|
get RegExp.prototype.source.length is 0.
|
||||||
|
@ -22,10 +23,11 @@ info: >
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "source");
|
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source').get;
|
||||||
|
|
||||||
assert.sameValue(desc.get.length, 0);
|
verifyProperty(get, 'length', {
|
||||||
|
value: 0,
|
||||||
verifyNotEnumerable(desc.get, "length");
|
writable: false,
|
||||||
verifyNotWritable(desc.get, "length");
|
enumerable: false,
|
||||||
verifyConfigurable(desc.get, "length");
|
configurable: true,
|
||||||
|
});
|
||||||
|
|
|
@ -1,24 +1,30 @@
|
||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-get-regexp.prototype.source
|
||||||
es6id: 21.2.5.10
|
es6id: 21.2.5.10
|
||||||
description: >
|
description: >
|
||||||
RegExp.prototype.source name
|
get RegExp.prototype.source.name is "get source".
|
||||||
info: >
|
info: >
|
||||||
|
get RegExp.prototype.source
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
Functions that are specified as get or set accessor functions of built-in
|
Functions that are specified as get or set accessor functions of built-in
|
||||||
properties have "get " or "set " prepended to the property name string.
|
properties have "get " or "set " prepended to the property name string.
|
||||||
|
|
||||||
|
Unless otherwise specified, the name property of a built-in function object,
|
||||||
|
if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false,
|
||||||
|
[[Configurable]]: true }.
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source');
|
var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source').get;
|
||||||
|
|
||||||
assert.sameValue(
|
verifyProperty(get, 'name', {
|
||||||
descriptor.get.name,
|
value: 'get source',
|
||||||
'get source'
|
writable: false,
|
||||||
);
|
enumerable: false,
|
||||||
|
configurable: true,
|
||||||
verifyNotEnumerable(descriptor.get, 'name');
|
});
|
||||||
verifyNotWritable(descriptor.get, 'name');
|
|
||||||
verifyConfigurable(descriptor.get, 'name');
|
|
||||||
|
|
|
@ -2,16 +2,21 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-get-regexp.prototype.source
|
||||||
es5id: 15.10.7.1-2
|
es5id: 15.10.7.1-2
|
||||||
|
es6id: 21.2.5.10
|
||||||
description: >
|
description: >
|
||||||
RegExp.prototype.source is an accessor property whose set accessor
|
RegExp.prototype.source is an accessor property whose set accessor
|
||||||
function is undefined
|
function is undefined
|
||||||
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var d = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source');
|
var d = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source');
|
||||||
|
|
||||||
|
|
||||||
assert.sameValue(typeof d.get, 'function', 'typeof d.get');
|
assert.sameValue(typeof d.get, 'function', 'typeof d.get');
|
||||||
assert.sameValue(d.set, undefined, 'd.set');
|
assert.sameValue(d.set, undefined, 'd.set');
|
||||||
assert.sameValue(d.enumerable, false, 'd.enumerable');
|
|
||||||
assert.sameValue(d.configurable, true, 'd.configurable');
|
verifyProperty(RegExp.prototype, 'source', {
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true,
|
||||||
|
});
|
|
@ -3,8 +3,7 @@
|
||||||
/*---
|
/*---
|
||||||
esid: sec-get-regexp.prototype.source
|
esid: sec-get-regexp.prototype.source
|
||||||
description: >
|
description: >
|
||||||
Return value of `undefined` when the "this" value is the RegExp prototype
|
Return "(?:)" when the `this` value is the RegExp.prototype object
|
||||||
object
|
|
||||||
info: |
|
info: |
|
||||||
1. Let R be the this value.
|
1. Let R be the this value.
|
||||||
2. If Type(R) is not Object, throw a TypeError exception.
|
2. If Type(R) is not Object, throw a TypeError exception.
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright (C) 2016 Aleksey Shvayka. 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: Return value can be used to create an equivalent RegExp
|
||||||
|
info: |
|
||||||
|
[...]
|
||||||
|
5. Let src be R.[[OriginalSource]].
|
||||||
|
6. Let flags be R.[[OriginalFlags]].
|
||||||
|
7. Return EscapeRegExpPattern(src, flags).
|
||||||
|
|
||||||
|
21.2.3.2.4 Runtime Semantics: EscapeRegExpPattern
|
||||||
|
|
||||||
|
[...] The code points / or any LineTerminator occurring in the pattern
|
||||||
|
shall be escaped in S as necessary to ensure that the String value
|
||||||
|
formed by concatenating the Strings "/", S, "/", and F can be parsed
|
||||||
|
(in an appropriate lexical context) as a RegularExpressionLiteral that
|
||||||
|
behaves identically to the constructed regular expression.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var re = eval('/' + new RegExp('/').source + '/');
|
||||||
|
|
||||||
|
assert(re.test('/'), 'input: "/"');
|
||||||
|
assert(re.test('_/_'), 'input: "_/_"');
|
||||||
|
assert(!re.test('\\'), 'input: "\\"');
|
Loading…
Reference in New Issue