diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/global')
12 files changed, 275 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/15.10.7.2-2.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/15.10.7.2-2.js new file mode 100644 index 0000000000..c615203c44 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/15.10.7.2-2.js @@ -0,0 +1,19 @@ +// 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-2 +description: > + RegExp.prototype.global is an accessor property whose set accessor + function is undefined +---*/ + + var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'global'); + + +assert.sameValue(typeof desc.get, 'function', 'typeof desc.get'); +assert.sameValue(desc.set, undefined, 'desc.set'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/S15.10.7.2_A10.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/S15.10.7.2_A10.js new file mode 100644 index 0000000000..9f1722c642 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/S15.10.7.2_A10.js @@ -0,0 +1,22 @@ +// 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 global property does not have a set accessor +es5id: 15.10.7.2_A10 +description: Checking if varying the global property fails +includes: [propertyHelper.js] +---*/ + +var __re = RegExp.prototype; + +assert.sameValue(__re.hasOwnProperty('global'), true, '__re.hasOwnProperty(\'global\') must return true'); + +var __sample = /^|^/; +var __obj = __sample.global; + +verifyNotWritable(__sample, "global", "global", "shifted"); + +assert.sameValue(__sample.global, __obj, 'The value of __sample.global is expected to equal the value of __obj'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/S15.10.7.2_A8.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/S15.10.7.2_A8.js new file mode 100644 index 0000000000..c2f69b59ae --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/S15.10.7.2_A8.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 global property has the attribute DontEnum +es5id: 15.10.7.2_A8 +description: > + Checking if enumerating the global property of RegExp.prototype + fails +---*/ + +var __re = RegExp.prototype; + +assert.sameValue(__re.hasOwnProperty('global'), true, '__re.hasOwnProperty(\'global\') must return true'); + +assert.sameValue( + __re.propertyIsEnumerable('global'), + false, + '__re.propertyIsEnumerable(\'global\') must return false' +); + +var count = 0 +for (var p in __re){ + if (p==="global") { + 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/global/S15.10.7.2_A9.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/S15.10.7.2_A9.js new file mode 100644 index 0000000000..2a2f0f14c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/S15.10.7.2_A9.js @@ -0,0 +1,20 @@ +// 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 global property does not have the attribute + DontDelete +es5id: 15.10.7.2_A9 +description: Checking if deleting the global property succeeds +---*/ + +var __re = RegExp.prototype; + +assert.sameValue(__re.hasOwnProperty('global'), true, '__re.hasOwnProperty(\'global\') must return true'); +assert.sameValue(delete __re.global, true, 'The value of `delete __re.global` is expected to be true'); +assert.sameValue(__re.hasOwnProperty('global'), false, '__re.hasOwnProperty(\'global\') must return false'); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/browser.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/browser.js diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/cross-realm.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/cross-realm.js new file mode 100644 index 0000000000..b903f21996 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/cross-realm.js @@ -0,0 +1,28 @@ +// 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: A TypeError is thrown when the "this" value is an invalid cross-realm 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. +features: [cross-realm] +---*/ + +var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'global').get; +var other = $262.createRealm().global; +var otherRegExpProto = other.RegExp.prototype; +var otherRegExpGetter = Object.getOwnPropertyDescriptor(otherRegExpProto, 'global').get; + +assert.throws(TypeError, function() { + get.call(otherRegExpProto); +}, 'cross-realm RegExp.prototype'); + +assert.throws(other.TypeError, function() { + otherRegExpGetter.call(RegExp.prototype); +}, 'cross-realm RegExp.prototype getter method against primary realm RegExp.prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js new file mode 100644 index 0000000000..d2802441f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js @@ -0,0 +1,33 @@ +// 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.4 +description: > + get RegExp.prototype.global.length is 0. +info: | + get RegExp.prototype.global + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "global"); + +assert.sameValue(desc.get.length, 0); + +verifyNotEnumerable(desc.get, "length"); +verifyNotWritable(desc.get, "length"); +verifyConfigurable(desc.get, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js new file mode 100644 index 0000000000..ba8ace9def --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.2.5.4 +description: > + RegExp.prototype.global name +info: | + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'global'); + +assert.sameValue( + descriptor.get.name, + 'get global' +); + +verifyNotEnumerable(descriptor.get, 'name'); +verifyNotWritable(descriptor.get, 'name'); +verifyConfigurable(descriptor.get, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/shell.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/shell.js diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/this-val-invalid-obj.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/this-val-invalid-obj.js new file mode 100644 index 0000000000..3e51f470cd --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/this-val-invalid-obj.js @@ -0,0 +1,32 @@ +// 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: 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'); + +assert.throws(TypeError, function() { + get.call(() => {}); +}, 'function object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/this-val-non-obj.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/this-val-non-obj.js new file mode 100644 index 0000000000..daf345583d --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/this-val-non-obj.js @@ -0,0 +1,43 @@ +// 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: 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'); + +assert.throws(TypeError, function() { + get.call(4n); +}, 'bigint'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/this-val-regexp-prototype.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/this-val-regexp-prototype.js new file mode 100644 index 0000000000..9d899b1021 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/this-val-regexp-prototype.js @@ -0,0 +1,19 @@ +// 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); + +reportCompare(0, 0); |