diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/toString')
11 files changed, 272 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A10.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A10.js new file mode 100644 index 0000000000..34498afafc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A10.js @@ -0,0 +1,30 @@ +// 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.toString.length property has the attribute ReadOnly +es5id: 15.10.6.4_A10 +description: > + Checking if varying the RegExp.prototype.toString.length property + fails +includes: [propertyHelper.js] +---*/ +assert.sameValue( + RegExp.prototype.toString.hasOwnProperty('length'), + true, + 'RegExp.prototype.toString.hasOwnProperty(\'length\') must return true' +); + +var __obj = RegExp.prototype.toString.length; + +verifyNotWritable(RegExp.prototype.toString, "length", null, function(){return "shifted";}); + +assert.sameValue( + RegExp.prototype.toString.length, + __obj, + 'The value of RegExp.prototype.toString.length is expected to equal the value of __obj' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A11.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A11.js new file mode 100644 index 0000000000..ba322bd577 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A11.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of the toString method is 1 +es5id: 15.10.6.4_A11 +description: Checking RegExp.prototype.toString.length +---*/ +assert.sameValue( + RegExp.prototype.toString.hasOwnProperty("length"), + true, + 'RegExp.prototype.toString.hasOwnProperty("length") must return true' +); + +assert.sameValue( + RegExp.prototype.toString.length, + 0, + 'The value of RegExp.prototype.toString.length is expected to be 0' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A6.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A6.js new file mode 100644 index 0000000000..42adb4757d --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: RegExp.prototype.toString has not prototype property +es5id: 15.10.6.4_A6 +description: Checking RegExp.prototype.toString.prototype +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ +assert.sameValue( + RegExp.prototype.toString.prototype, + undefined, + 'The value of RegExp.prototype.toString.prototype is expected to equal undefined' +); + +assert.sameValue( + isConstructor(RegExp.prototype.toString), + false, + 'isConstructor(RegExp.prototype.toString) must return false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A7.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A7.js new file mode 100644 index 0000000000..334fcc1f4d --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A7.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: RegExp.prototype.toString can't be used as constructor +es5id: 15.10.6.4_A7 +description: Checking if creating the RegExp.prototype.toString object fails +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +var __FACTORY = RegExp.prototype.toString; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1.1: __FACTORY = RegExp.prototype.toString throw TypeError. Actual: ' + (__instance)); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +assert.sameValue( + isConstructor(RegExp.prototype.toString), + false, + 'isConstructor(RegExp.prototype.toString) must return false' +); + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A8.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A8.js new file mode 100644 index 0000000000..fe8d29d512 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A8.js @@ -0,0 +1,35 @@ +// 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.toString.length property has the attribute DontEnum +es5id: 15.10.6.4_A8 +description: > + Checking if enumerating the RegExp.prototype.toString.length + property fails +---*/ +assert.sameValue( + RegExp.prototype.toString.hasOwnProperty('length'), + true, + 'RegExp.prototype.toString.hasOwnProperty(\'length\') must return true' +); + +assert.sameValue( + RegExp.prototype.toString.propertyIsEnumerable('length'), + false, + 'RegExp.prototype.toString.propertyIsEnumerable(\'length\') must return false' +); + +var count=0; + +for (var p in RegExp.prototype.toString){ + if (p==="length") { + count++; + } +} + +assert.sameValue(count, 0, 'The value of count is expected to be 0'); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A9.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A9.js new file mode 100644 index 0000000000..34f1cdffc9 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/S15.10.6.4_A9.js @@ -0,0 +1,33 @@ +// 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.toString.length property does not have the attribute + DontDelete +es5id: 15.10.6.4_A9 +description: > + Checking if deleting the RegExp.prototype.toString.length property + fails +---*/ +assert.sameValue( + RegExp.prototype.toString.hasOwnProperty('length'), + true, + 'RegExp.prototype.toString.hasOwnProperty(\'length\') must return true' +); + +assert.sameValue( + delete RegExp.prototype.toString.length, + true, + 'The value of `delete RegExp.prototype.toString.length` is expected to be true' +); + +assert.sameValue( + RegExp.prototype.toString.hasOwnProperty('length'), + false, + 'RegExp.prototype.toString.hasOwnProperty(\'length\') must return false' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/browser.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/browser.js diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/called-as-function.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/called-as-function.js new file mode 100644 index 0000000000..0b64826c37 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/called-as-function.js @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-regexp.prototype.tostring +description: > + `this` value is resolved using strict mode semantics, + throwing TypeError if called as top-level function. +info: | + RegExp.prototype.toString ( ) + + 1. Let R be the this value. + 2. If Type(R) is not Object, throw a TypeError exception. + + ToObject ( argument ) + + Argument Type: Undefined + Result: Throw a TypeError exception. +---*/ + +["source", "flags"].forEach(function(key) { + Object.defineProperty(this, key, { + get: function() { + throw new Test262Error(key + " lookup should not be performed"); + }, + }); +}, this); + +var toString = RegExp.prototype.toString; +assert.throws(TypeError, function() { + toString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js new file mode 100644 index 0000000000..91fe5a8809 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 21.2.5.14 +description: > + RegExp.prototype.toString.name is "toString". +info: | + RegExp.prototype.toString ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a 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] +---*/ + +assert.sameValue(RegExp.prototype.toString.name, "toString"); + +verifyNotEnumerable(RegExp.prototype.toString, "name"); +verifyNotWritable(RegExp.prototype.toString, "name"); +verifyConfigurable(RegExp.prototype.toString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js new file mode 100644 index 0000000000..f064aaf64d --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + RegExp.prototype.toString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(RegExp.prototype.toString), + false, + 'isConstructor(RegExp.prototype.toString) must return false' +); + +assert.throws(TypeError, () => { + let re = new RegExp(''); new re.toString(); +}, '`let re = new RegExp(\'\'); new re.toString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/shell.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/shell.js |