diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/annexB/built-ins/String | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/annexB/built-ins/String')
159 files changed, 3469 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/built-ins/String/browser.js b/js/src/tests/test262/annexB/built-ins/String/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/B.2.3.2.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/B.2.3.2.js new file mode 100644 index 0000000000..6b8511876e --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/B.2.3.2.js @@ -0,0 +1,28 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.anchor returns a string of HTML describing a single HTML + anchor element. The element's content is the `this` value of the function + invocation, coerced to a string. If specified, the first argument will be + coerced to a string, escaped, and set as the element's `name` attribute. + es6id: B.2.3.2 +---*/ + +assert.sameValue('_'.anchor('b'), '<a name="b">_</a>'); +assert.sameValue('<'.anchor('<'), '<a name="<"><</a>'); +assert.sameValue('_'.anchor(0x2A), '<a name="42">_</a>'); +assert.sameValue('_'.anchor('\x22'), '<a name=""">_</a>'); +assert.sameValue(String.prototype.anchor.call(0x2A, 0x2A), '<a name="42">42</a>'); +assert.throws(TypeError, function() { + String.prototype.anchor.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.anchor.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/attr-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/attr-tostring-err.js new file mode 100644 index 0000000000..bf6a3eae21 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/attr-tostring-err.js @@ -0,0 +1,25 @@ +// 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-string.prototype.anchor +es6id: B.2.3.2 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + [...] + 4. If attribute is not the empty String, then + a. Let V be ? ToString(value). +---*/ + +var attr = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.anchor(attr); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/length.js new file mode 100644 index 0000000000..9df190d4a3 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.2 +description: > + String.prototype.anchor.length is 1. +info: | + String.prototype.anchor ( name ) + + 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] +---*/ + +verifyProperty(String.prototype.anchor, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/name.js new file mode 100644 index 0000000000..4d961bd1a9 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.2 +description: > + String.prototype.anchor.name is "anchor". +info: | + String.prototype.anchor ( name ) + + 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] +---*/ + +verifyProperty(String.prototype.anchor, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "anchor" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/not-a-constructor.js new file mode 100644 index 0000000000..ca59226cbf --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.anchor 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(String.prototype.anchor), + false, + 'isConstructor(String.prototype.anchor) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.anchor(); +}, '`new String.prototype.anchor()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/prop-desc.js new file mode 100644 index 0000000000..b1412c4a1c --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.anchor +es6id: B.2.3.2 +description: Property descriptor for String.prototype.anchor +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "anchor", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/this-val-tostring-err.js new file mode 100644 index 0000000000..c6d9d25d41 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.anchor +es6id: B.2.3.2 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.anchor.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/big/B.2.3.3.js b/js/src/tests/test262/annexB/built-ins/String/prototype/big/B.2.3.3.js new file mode 100644 index 0000000000..16a179283f --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/big/B.2.3.3.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.big returns a string of HTML describing a single HTML + big element. The element's content is the `this` value of the function + invocation, coerced to a string. + es6id: B.2.3.3 +---*/ + +assert.sameValue('_'.big(), '<big>_</big>'); +assert.sameValue('<'.big(), '<big><</big>'); +assert.sameValue(String.prototype.big.call(0x2A), '<big>42</big>'); +assert.throws(TypeError, function() { + String.prototype.big.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.big.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/big/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/big/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/big/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/big/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/big/length.js new file mode 100644 index 0000000000..bc94e5fdc4 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/big/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.3 +description: > + String.prototype.big.length is 0. +info: | + String.prototype.big ( ) + + 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] +---*/ + +verifyProperty(String.prototype.big, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/big/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/big/name.js new file mode 100644 index 0000000000..29dad81234 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/big/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.3 +description: > + String.prototype.big.name is "big". +info: | + String.prototype.big ( ) + + 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] +---*/ + +verifyProperty(String.prototype.big, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "big" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/big/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/big/not-a-constructor.js new file mode 100644 index 0000000000..f2e5f3bfc7 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/big/not-a-constructor.js @@ -0,0 +1,30 @@ +// 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: > + String.prototype.big 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(String.prototype.big), false, 'isConstructor(String.prototype.big) must return false'); + +assert.throws(TypeError, () => { + new String.prototype.big(); +}, '`new String.prototype.big()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/big/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/big/prop-desc.js new file mode 100644 index 0000000000..80a2b7ef72 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/big/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.big +es6id: B.2.3.3 +description: Property descriptor for String.prototype.big +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "big", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/big/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/big/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/big/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/big/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/big/this-val-tostring-err.js new file mode 100644 index 0000000000..63326e834a --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/big/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.big +es6id: B.2.3.3 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.big.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/B.2.3.4.js b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/B.2.3.4.js new file mode 100644 index 0000000000..5aa5620c82 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/B.2.3.4.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.blink returns a string of HTML describing a single HTML + blink element. The element's content is the `this` value of the function + invocation, coerced to a string. + es6id: B.2.3.4 +---*/ + +assert.sameValue('_'.blink(), '<blink>_</blink>'); +assert.sameValue('<'.blink(), '<blink><</blink>'); +assert.sameValue(String.prototype.blink.call(0x2A), '<blink>42</blink>'); +assert.throws(TypeError, function() { + String.prototype.blink.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.blink.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/length.js new file mode 100644 index 0000000000..06c85b49dc --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.4 +description: > + String.prototype.blink.length is 0. +info: | + String.prototype.blink ( ) + + 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] +---*/ + +verifyProperty(String.prototype.blink, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/name.js new file mode 100644 index 0000000000..617b2d6993 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.4 +description: > + String.prototype.blink.name is "blink". +info: | + String.prototype.blink ( ) + + 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] +---*/ + +verifyProperty(String.prototype.blink, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "blink" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/not-a-constructor.js new file mode 100644 index 0000000000..73d5488203 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.blink 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(String.prototype.blink), + false, + 'isConstructor(String.prototype.blink) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.blink(); +}, '`new String.prototype.blink()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/prop-desc.js new file mode 100644 index 0000000000..8c875db468 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.blink +es6id: B.2.3.4 +description: Property descriptor for String.prototype.blink +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "blink", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/this-val-tostring-err.js new file mode 100644 index 0000000000..4a2f900e23 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.blink +es6id: B.2.3.4 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.blink.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/B.2.3.5.js b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/B.2.3.5.js new file mode 100644 index 0000000000..3a9a73052e --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/B.2.3.5.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.bold returns a string of HTML describing a single HTML + bold element. The element's content is the `this` value of the function + invocation, coerced to a string. + es6id: B.2.3.5 +---*/ + +assert.sameValue('_'.bold(), '<b>_</b>'); +assert.sameValue('<'.bold(), '<b><</b>'); +assert.sameValue(String.prototype.bold.call(0x2A), '<b>42</b>'); +assert.throws(TypeError, function() { + String.prototype.bold.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.bold.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/length.js new file mode 100644 index 0000000000..151964b7ec --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.5 +description: > + String.prototype.bold.length is 0. +info: | + String.prototype.bold ( ) + + 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] +---*/ + +verifyProperty(String.prototype.bold, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/name.js new file mode 100644 index 0000000000..21c7beafd0 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.5 +description: > + String.prototype.bold.name is "bold". +info: | + String.prototype.bold ( ) + + 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] +---*/ + +verifyProperty(String.prototype.bold, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "bold" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/not-a-constructor.js new file mode 100644 index 0000000000..1f8a7a155d --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.bold 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(String.prototype.bold), + false, + 'isConstructor(String.prototype.bold) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.bold(); +}, '`new String.prototype.bold()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/prop-desc.js new file mode 100644 index 0000000000..1eb27ef8bc --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.bold +es6id: B.2.3.5 +description: Property descriptor for String.prototype.bold +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "bold", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/this-val-tostring-err.js new file mode 100644 index 0000000000..7f1fdd05ec --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.bold +es6id: B.2.3.5 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.bold.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/B.2.3.6.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/B.2.3.6.js new file mode 100644 index 0000000000..2c20e91f4c --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/B.2.3.6.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.fixed returns a string of HTML describing a single HTML + teletype text element. The element's content is the `this` value of the + function invocation, coerced to a string. + es6id: B.2.3.6 +---*/ + +assert.sameValue('_'.fixed(), '<tt>_</tt>'); +assert.sameValue('<'.fixed(), '<tt><</tt>'); +assert.sameValue(String.prototype.fixed.call(0x2A), '<tt>42</tt>'); +assert.throws(TypeError, function() { + String.prototype.fixed.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.fixed.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/length.js new file mode 100644 index 0000000000..bc2d83974b --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.6 +description: > + String.prototype.fixed.length is 0. +info: | + String.prototype.fixed ( ) + + 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] +---*/ + +verifyProperty(String.prototype.fixed, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/name.js new file mode 100644 index 0000000000..a5b546cd76 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.6 +description: > + String.prototype.fixed.name is "fixed". +info: | + String.prototype.fixed ( ) + + 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] +---*/ + +verifyProperty(String.prototype.fixed, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "fixed" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/not-a-constructor.js new file mode 100644 index 0000000000..64fa0c534d --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.fixed 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(String.prototype.fixed), + false, + 'isConstructor(String.prototype.fixed) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.fixed(); +}, '`new String.prototype.fixed()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/prop-desc.js new file mode 100644 index 0000000000..c6691e668b --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.fixed +es6id: B.2.3.6 +description: Property descriptor for String.prototype.fixed +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "fixed", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/this-val-tostring-err.js new file mode 100644 index 0000000000..96b339a0f0 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.fixed +es6id: B.2.3.6 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.fixed.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/B.2.3.7.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/B.2.3.7.js new file mode 100644 index 0000000000..497e24654d --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/B.2.3.7.js @@ -0,0 +1,30 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.fontcolor returns a string of HTML describing a single + HTML font element. The element's content is the `this` value of the + function invocation, coerced to a string. If specified, the first argument + will be coerced to a string, escaped, and set as the element's `color` + attribute. + es6id: B.2.3.7 +---*/ + +assert.sameValue('_'.fontcolor('b'), '<font color="b">_</font>'); +assert.sameValue('<'.fontcolor('<'), '<font color="<"><</font>'); +assert.sameValue('_'.fontcolor(0x2A), '<font color="42">_</font>'); +assert.sameValue('_'.fontcolor('\x22'), '<font color=""">_</font>'); +assert.sameValue(String.prototype.fontcolor.call(0x2A, 0x2A), + '<font color="42">42</font>'); +assert.throws(TypeError, function() { + String.prototype.fontcolor.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.fontcolor.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/attr-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/attr-tostring-err.js new file mode 100644 index 0000000000..bc4604f7b9 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/attr-tostring-err.js @@ -0,0 +1,25 @@ +// 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-string.prototype.fontcolor +es6id: B.2.3.7 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + [...] + 4. If attribute is not the empty String, then + a. Let V be ? ToString(value). +---*/ + +var attr = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.fontcolor(attr); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/length.js new file mode 100644 index 0000000000..d12fa78837 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.7 +description: > + String.prototype.fontcolor.length is 1. +info: | + String.prototype.fontcolor ( color ) + + 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] +---*/ + +verifyProperty(String.prototype.fontcolor, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/name.js new file mode 100644 index 0000000000..237ce1debc --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.7 +description: > + String.prototype.fontcolor.name is "fontcolor". +info: | + String.prototype.fontcolor ( color ) + + 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] +---*/ + +verifyProperty(String.prototype.fontcolor, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "fontcolor" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/not-a-constructor.js new file mode 100644 index 0000000000..a5bfa4415c --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.fontcolor 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(String.prototype.fontcolor), + false, + 'isConstructor(String.prototype.fontcolor) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.fontcolor(); +}, '`new String.prototype.fontcolor()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/prop-desc.js new file mode 100644 index 0000000000..0473c209ce --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.fontcolor +es6id: B.2.3.7 +description: Property descriptor for String.prototype.fontcolor +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "fontcolor", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/this-val-tostring-err.js new file mode 100644 index 0000000000..2fdacd804b --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.fontcolor +es6id: B.2.3.7 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.fontcolor.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/B.2.3.8.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/B.2.3.8.js new file mode 100644 index 0000000000..b6f51d9f3b --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/B.2.3.8.js @@ -0,0 +1,30 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.fontsize returns a string of HTML describing a single + HTML font element. The element's content is the `this` value of the + function invocation, coerced to a string. If specified, the first argument + will be coerced to a string, escaped, and set as the element's `size` + attribute. + es6id: B.2.3.8 +---*/ + +assert.sameValue('_'.fontsize('b'), '<font size="b">_</font>'); +assert.sameValue('<'.fontsize('<'), '<font size="<"><</font>'); +assert.sameValue('_'.fontsize(0x2A), '<font size="42">_</font>'); +assert.sameValue('_'.fontsize('\x22'), '<font size=""">_</font>'); +assert.sameValue(String.prototype.fontsize.call(0x2A, 0x2A), + '<font size="42">42</font>'); +assert.throws(TypeError, function() { + String.prototype.fontsize.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.fontsize.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/attr-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/attr-tostring-err.js new file mode 100644 index 0000000000..be60430f40 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/attr-tostring-err.js @@ -0,0 +1,25 @@ +// 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-string.prototype.fontsize +es6id: B.2.3.8 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + [...] + 4. If attribute is not the empty String, then + a. Let V be ? ToString(value). +---*/ + +var attr = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.fontsize(attr); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/length.js new file mode 100644 index 0000000000..94cf9e7f4e --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.8 +description: > + String.prototype.fontsize.length is 1. +info: | + String.prototype.fontsize ( size ) + + 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] +---*/ + +verifyProperty(String.prototype.fontsize, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/name.js new file mode 100644 index 0000000000..42d7b00105 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.8 +description: > + String.prototype.fontsize.name is "fontsize". +info: | + String.prototype.fontsize ( color ) + + 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] +---*/ + +verifyProperty(String.prototype.fontsize, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "fontsize" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/not-a-constructor.js new file mode 100644 index 0000000000..d221a1348a --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.fontsize 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(String.prototype.fontsize), + false, + 'isConstructor(String.prototype.fontsize) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.fontsize(); +}, '`new String.prototype.fontsize()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/prop-desc.js new file mode 100644 index 0000000000..d25aceb2e8 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.fontsize +es6id: B.2.3.8 +description: Property descriptor for String.prototype.fontsize +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "fontsize", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/this-val-tostring-err.js new file mode 100644 index 0000000000..9bb7b11da6 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.fontsize +es6id: B.2.3.8 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.fontsize.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/B.2.3.9.js b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/B.2.3.9.js new file mode 100644 index 0000000000..5421037edb --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/B.2.3.9.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.italics returns a string of HTML describing a single HTML + italic element. The element's content is the `this` value of the function + invocation, coerced to a string. + es6id: B.2.3.9 +---*/ + +assert.sameValue('_'.italics(), '<i>_</i>'); +assert.sameValue('<'.italics(), '<i><</i>'); +assert.sameValue(String.prototype.italics.call(0x2A), '<i>42</i>'); +assert.throws(TypeError, function() { + String.prototype.italics.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.italics.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/length.js new file mode 100644 index 0000000000..1c2a517ffa --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.9 +description: > + String.prototype.italics.length is 0. +info: | + String.prototype.italics ( ) + + 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] +---*/ + +verifyProperty(String.prototype.italics, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/name.js new file mode 100644 index 0000000000..56139bf62b --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.9 +description: > + String.prototype.italics.name is "italics". +info: | + String.prototype.italics ( ) + + 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] +---*/ + +verifyProperty(String.prototype.italics, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "italics" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/not-a-constructor.js new file mode 100644 index 0000000000..4833d9b0e5 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.italics 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(String.prototype.italics), + false, + 'isConstructor(String.prototype.italics) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.italics(); +}, '`new String.prototype.italics()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/prop-desc.js new file mode 100644 index 0000000000..041b5ad7f4 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.italics +es6id: B.2.3.9 +description: Property descriptor for String.prototype.italics +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "italics", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/this-val-tostring-err.js new file mode 100644 index 0000000000..db693918dd --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.italics +es6id: B.2.3.9 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.italics.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/B.2.3.10.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/B.2.3.10.js new file mode 100644 index 0000000000..01d0268cdd --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/B.2.3.10.js @@ -0,0 +1,28 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.link returns a string of HTML describing a single HTML + link element. The element's content is the `this` value of the function + invocation, coerced to a string. If specified, the first argument will be + coerced to a string, escaped, and set as the element's `href` attribute. + es6id: B.2.3.10 +---*/ + +assert.sameValue('_'.link('b'), '<a href="b">_</a>'); +assert.sameValue('<'.link('<'), '<a href="<"><</a>'); +assert.sameValue('_'.link(0x2A), '<a href="42">_</a>'); +assert.sameValue('_'.link('\x22'), '<a href=""">_</a>'); +assert.sameValue(String.prototype.link.call(0x2A, 0x2A), '<a href="42">42</a>'); +assert.throws(TypeError, function() { + String.prototype.link.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.link.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/attr-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/attr-tostring-err.js new file mode 100644 index 0000000000..88b6d3e301 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/attr-tostring-err.js @@ -0,0 +1,25 @@ +// 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-string.prototype.link +es6id: B.2.3.10 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + [...] + 4. If attribute is not the empty String, then + a. Let V be ? ToString(value). +---*/ + +var attr = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.link(attr); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/length.js new file mode 100644 index 0000000000..f51904e982 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.10 +description: > + String.prototype.link.length is 1. +info: | + String.prototype.link ( url ) + + 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] +---*/ + +verifyProperty(String.prototype.link, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/name.js new file mode 100644 index 0000000000..fb7ea3ee2a --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.10 +description: > + String.prototype.link.name is "link". +info: | + String.prototype.link ( url ) + + 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] +---*/ + +verifyProperty(String.prototype.link, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "link" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/not-a-constructor.js new file mode 100644 index 0000000000..afd8d81733 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.link 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(String.prototype.link), + false, + 'isConstructor(String.prototype.link) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.link(); +}, '`new String.prototype.link()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/prop-desc.js new file mode 100644 index 0000000000..75bf7df731 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.link +es6id: B.2.3.10 +description: Property descriptor for String.prototype.link +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "link", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/this-val-tostring-err.js new file mode 100644 index 0000000000..b14c932f59 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.link +es6id: B.2.3.10 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.link.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/match/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/match/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/match/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/match/custom-matcher-emulates-undefined.js b/js/src/tests/test262/annexB/built-ins/String/prototype/match/custom-matcher-emulates-undefined.js new file mode 100644 index 0000000000..55e6d28feb --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/match/custom-matcher-emulates-undefined.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.match +description: > + [[IsHTMLDDA]] object as @@match method gets called. +info: | + String.prototype.match ( regexp ) + + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@match). + b. If matcher is not undefined, then + i. Return ? Call(matcher, regexp, « O »). +features: [Symbol.match, IsHTMLDDA] +---*/ + +var regexp = $262.IsHTMLDDA; +var matcherGets = 0; +Object.defineProperty(regexp, Symbol.match, { + get: function() { + matcherGets += 1; + return regexp; + }, + configurable: true, +}); + +assert.sameValue("".match(regexp), null); +assert.sameValue(matcherGets, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/match/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/match/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/match/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/matchAll/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/matchAll/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/matchAll/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/matchAll/custom-matcher-emulates-undefined.js b/js/src/tests/test262/annexB/built-ins/String/prototype/matchAll/custom-matcher-emulates-undefined.js new file mode 100644 index 0000000000..5abb9d10d3 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/matchAll/custom-matcher-emulates-undefined.js @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.matchall +description: > + [[IsHTMLDDA]] object as @@matchAll method gets called. +info: | + String.prototype.matchAll ( regexp ) + + [...] + 2. If regexp is neither undefined nor null, then + [...] + c. Let matcher be ? GetMethod(regexp, @@matchAll). + d. If matcher is not undefined, then + i. Return ? Call(matcher, regexp, « O »). +features: [Symbol.matchAll, String.prototype.matchAll, IsHTMLDDA] +---*/ + +var regexp = $262.IsHTMLDDA; +var matcherGets = 0; +Object.defineProperty(regexp, Symbol.matchAll, { + get: function() { + matcherGets += 1; + return regexp; + }, + configurable: true, +}); + +assert.sameValue("".matchAll(regexp), null); +assert.sameValue(matcherGets, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/matchAll/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/matchAll/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/matchAll/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/replace/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/replace/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/replace/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/replace/custom-replacer-emulates-undefined.js b/js/src/tests/test262/annexB/built-ins/String/prototype/replace/custom-replacer-emulates-undefined.js new file mode 100644 index 0000000000..07c5ad606f --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/replace/custom-replacer-emulates-undefined.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.replace +description: > + [[IsHTMLDDA]] object as @@replace method gets called. +info: | + String.prototype.replace ( searchValue, replaceValue ) + + [...] + 2. If searchValue is neither undefined nor null, then + a. Let replacer be ? GetMethod(searchValue, @@replace). + b. If replacer is not undefined, then + i. Return ? Call(replacer, searchValue, « O, replaceValue »). +features: [Symbol.replace, IsHTMLDDA] +---*/ + +var searchValue = $262.IsHTMLDDA; +var replacerGets = 0; +Object.defineProperty(searchValue, Symbol.replace, { + get: function() { + replacerGets += 1; + return searchValue; + }, + configurable: true, +}); + +assert.sameValue("".replace(searchValue), null); +assert.sameValue(replacerGets, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/replace/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/replace/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/replace/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js b/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js new file mode 100644 index 0000000000..7fec73440a --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.replaceall +description: > + [[IsHTMLDDA]] object as @@replace method gets called. +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + [...] + 2. If searchValue is neither undefined nor null, then + [...] + c. Let replacer be ? GetMethod(searchValue, @@replace). + d. If replacer is not undefined, then + i. Return ? Call(replacer, searchValue, « O, replaceValue »). +features: [Symbol.replace, String.prototype.replaceAll, IsHTMLDDA] +---*/ + +var searchValue = $262.IsHTMLDDA; +var replacerGets = 0; +Object.defineProperty(searchValue, Symbol.replace, { + get: function() { + replacerGets += 1; + return searchValue; + }, + configurable: true, +}); + +assert.sameValue("".replaceAll(searchValue), null); +assert.sameValue(replacerGets, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/search/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/search/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/search/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/search/custom-searcher-emulates-undefined.js b/js/src/tests/test262/annexB/built-ins/String/prototype/search/custom-searcher-emulates-undefined.js new file mode 100644 index 0000000000..d96bbb1ff7 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/search/custom-searcher-emulates-undefined.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.search +description: > + [[IsHTMLDDA]] object as @@search method gets called. +info: | + String.prototype.search ( regexp ) + + [...] + 2. If regexp is neither undefined nor null, then + a. Let searcher be ? GetMethod(regexp, @@search). + b. If searcher is not undefined, then + i. Return ? Call(searcher, regexp, « O »). +features: [Symbol.search, IsHTMLDDA] +---*/ + +var regexp = $262.IsHTMLDDA; +var searcherGets = 0; +Object.defineProperty(regexp, Symbol.search, { + get: function() { + searcherGets += 1; + return regexp; + }, + configurable: true, +}); + +assert.sameValue("".search(regexp), null); +assert.sameValue(searcherGets, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/search/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/search/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/search/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/small/B.2.3.11.js b/js/src/tests/test262/annexB/built-ins/String/prototype/small/B.2.3.11.js new file mode 100644 index 0000000000..52274f8b0a --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/small/B.2.3.11.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.small returns a string of HTML describing a single HTML + small print element. The element's content is the `this` value of the + function invocation, coerced to a string. + es6id: B.2.3.11 +---*/ + +assert.sameValue('_'.small(), '<small>_</small>'); +assert.sameValue('<'.small(), '<small><</small>'); +assert.sameValue(String.prototype.small.call(0x2A), '<small>42</small>'); +assert.throws(TypeError, function() { + String.prototype.small.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.small.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/small/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/small/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/small/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/small/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/small/length.js new file mode 100644 index 0000000000..0809743f95 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/small/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.11 +description: > + String.prototype.small.length is 0. +info: | + String.prototype.small ( ) + + 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] +---*/ + +verifyProperty(String.prototype.small, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/small/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/small/name.js new file mode 100644 index 0000000000..cc439add06 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/small/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.11 +description: > + String.prototype.small.name is "small". +info: | + String.prototype.small ( ) + + 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] +---*/ + +verifyProperty(String.prototype.small, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "small" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/small/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/small/not-a-constructor.js new file mode 100644 index 0000000000..a0a9aa6090 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/small/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.small 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(String.prototype.small), + false, + 'isConstructor(String.prototype.small) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.small(); +}, '`new String.prototype.small()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/small/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/small/prop-desc.js new file mode 100644 index 0000000000..631b31349d --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/small/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.small +es6id: B.2.3.11 +description: Property descriptor for String.prototype.small +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "small", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/small/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/small/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/small/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/small/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/small/this-val-tostring-err.js new file mode 100644 index 0000000000..b546cc6ea7 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/small/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.small +es6id: B.2.3.11 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.small.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/split/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/split/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/split/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/split/custom-splitter-emulates-undefined.js b/js/src/tests/test262/annexB/built-ins/String/prototype/split/custom-splitter-emulates-undefined.js new file mode 100644 index 0000000000..fe120958cd --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/split/custom-splitter-emulates-undefined.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: > + [[IsHTMLDDA]] object as @@split method gets called. +info: | + String.prototype.split ( separator, limit ) + + [...] + 2. If separator is neither undefined nor null, then + a. Let splitter be ? GetMethod(separator, @@split). + b. If splitter is not undefined, then + i. Return ? Call(splitter, separator, « O, limit »). +features: [Symbol.split, IsHTMLDDA] +---*/ + +var separator = $262.IsHTMLDDA; +var splitterGets = 0; +Object.defineProperty(separator, Symbol.split, { + get: function() { + splitterGets += 1; + return separator; + }, + configurable: true, +}); + +assert.sameValue("".split(separator), null); +assert.sameValue(splitterGets, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/split/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/split/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/split/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/B.2.3.12.js b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/B.2.3.12.js new file mode 100644 index 0000000000..7fef1de75d --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/B.2.3.12.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.strike returns a string of HTML describing a single HTML + strikethrough element. The element's content is the `this` value of the + function invocation, coerced to a string. + es6id: B.2.3.12 +---*/ + +assert.sameValue('_'.strike(), '<strike>_</strike>'); +assert.sameValue('<'.strike(), '<strike><</strike>'); +assert.sameValue(String.prototype.strike.call(0x2A), '<strike>42</strike>'); +assert.throws(TypeError, function() { + String.prototype.strike.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.strike.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/length.js new file mode 100644 index 0000000000..7fc3ac2ff0 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.12 +description: > + String.prototype.strike.length is 0. +info: | + String.prototype.strike ( ) + + 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] +---*/ + +verifyProperty(String.prototype.strike, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/name.js new file mode 100644 index 0000000000..ed8b2cc4d9 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.12 +description: > + String.prototype.strike.name is "strike". +info: | + String.prototype.strike ( ) + + 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] +---*/ + +verifyProperty(String.prototype.strike, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "strike" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/not-a-constructor.js new file mode 100644 index 0000000000..5f7bc6cbd1 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.strike 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(String.prototype.strike), + false, + 'isConstructor(String.prototype.strike) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.strike(); +}, '`new String.prototype.strike()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/prop-desc.js new file mode 100644 index 0000000000..61061060d1 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.strike +es6id: B.2.3.12 +description: Property descriptor for String.prototype.strike +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "strike", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/this-val-tostring-err.js new file mode 100644 index 0000000000..77cd44264e --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.strike +es6id: B.2.3.12 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.strike.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/B.2.3.13.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/B.2.3.13.js new file mode 100644 index 0000000000..53f0bcda58 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/B.2.3.13.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.sub returns a string of HTML describing a single HTML + subscript element. The element's content is the `this` value of the + function invocation, coerced to a string. + es6id: B.2.3.13 +---*/ + +assert.sameValue('_'.sub(), '<sub>_</sub>'); +assert.sameValue('<'.sub(), '<sub><</sub>'); +assert.sameValue(String.prototype.sub.call(0x2A), '<sub>42</sub>'); +assert.throws(TypeError, function() { + String.prototype.sub.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.sub.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/length.js new file mode 100644 index 0000000000..974cc7036a --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.13 +description: > + String.prototype.sub.length is 0. +info: | + String.prototype.sub ( ) + + 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] +---*/ + +verifyProperty(String.prototype.sub, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/name.js new file mode 100644 index 0000000000..4b2ed6a5d4 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.13 +description: > + String.prototype.sub.name is "sub". +info: | + String.prototype.sub ( ) + + 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] +---*/ + +verifyProperty(String.prototype.sub, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "sub" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/not-a-constructor.js new file mode 100644 index 0000000000..3c8b054e9a --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/not-a-constructor.js @@ -0,0 +1,30 @@ +// 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: > + String.prototype.sub 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(String.prototype.sub), false, 'isConstructor(String.prototype.sub) must return false'); + +assert.throws(TypeError, () => { + new String.prototype.sub(); +}, '`new String.prototype.sub()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/prop-desc.js new file mode 100644 index 0000000000..775210ff41 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.sub +es6id: B.2.3.13 +description: Property descriptor for String.prototype.sub +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "sub", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/this-val-tostring-err.js new file mode 100644 index 0000000000..1b91b44e57 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.sub +es6id: B.2.3.13 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.sub.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/B.2.3.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/B.2.3.js new file mode 100644 index 0000000000..fb9eb065b8 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/B.2.3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: B.2.3 +description: > + Object.getOwnPropertyDescriptor returns data desc for functions on + built-ins (String.prototype.substr) +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "substr", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-falsey.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-falsey.js new file mode 100644 index 0000000000..3de74fd5cf --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-falsey.js @@ -0,0 +1,39 @@ +// 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-string.prototype.substr +es6id: B.2.3.1 +description: > + Behavior when "length" is a false-converting value other than `undefined` +info: | + [...] + 4. If length is undefined, let end be +∞; otherwise let end be ? + ToInteger(length). + [...] + 7. Let resultLength be min(max(end, 0), size - intStart). + 8. If resultLength ≤ 0, return the empty String "". + 9. Return a String containing resultLength consecutive code units from S + beginning with the code unit at index intStart. +---*/ + +assert.sameValue('abc'.substr(0, false), '', 'start: 0, length: false'); +assert.sameValue('abc'.substr(1, false), '', 'start: 1, length: false'); +assert.sameValue('abc'.substr(2, false), '', 'start: 2, length: false'); +assert.sameValue('abc'.substr(3, false), '', 'start: 3, length: false'); + +assert.sameValue('abc'.substr(0, NaN), '', 'start: 0, length: NaN'); +assert.sameValue('abc'.substr(1, NaN), '', 'start: 1, length: NaN'); +assert.sameValue('abc'.substr(2, NaN), '', 'start: 2, length: NaN'); +assert.sameValue('abc'.substr(3, NaN), '', 'start: 3, length: NaN'); + +assert.sameValue('abc'.substr(0, ''), '', 'start: 0, length: ""'); +assert.sameValue('abc'.substr(1, ''), '', 'start: 1, length: ""'); +assert.sameValue('abc'.substr(2, ''), '', 'start: 2, length: ""'); +assert.sameValue('abc'.substr(3, ''), '', 'start: 3, length: ""'); + +assert.sameValue('abc'.substr(0, null), '', 'start: 0, length: null'); +assert.sameValue('abc'.substr(1, null), '', 'start: 1, length: null'); +assert.sameValue('abc'.substr(2, null), '', 'start: 2, length: null'); +assert.sameValue('abc'.substr(3, null), '', 'start: 3, length: null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-negative.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-negative.js new file mode 100644 index 0000000000..48e90b1aac --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-negative.js @@ -0,0 +1,33 @@ +// 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-string.prototype.substr +es6id: B.2.3.1 +description: Behavior when "length" is a negative number +info: | + [...] + 7. Let resultLength be min(max(end, 0), size - intStart). + 8. If resultLength ≤ 0, return the empty String "". +---*/ + +assert.sameValue('abc'.substr(0, -1), '', '0, -1'); +assert.sameValue('abc'.substr(0, -2), '', '0, -2'); +assert.sameValue('abc'.substr(0, -3), '', '0, -3'); +assert.sameValue('abc'.substr(0, -4), '', '0, -4'); + +assert.sameValue('abc'.substr(1, -1), '', '1, -1'); +assert.sameValue('abc'.substr(1, -2), '', '1, -2'); +assert.sameValue('abc'.substr(1, -3), '', '1, -3'); +assert.sameValue('abc'.substr(1, -4), '', '1, -4'); + +assert.sameValue('abc'.substr(2, -1), '', '2, -1'); +assert.sameValue('abc'.substr(2, -2), '', '2, -2'); +assert.sameValue('abc'.substr(2, -3), '', '2, -3'); +assert.sameValue('abc'.substr(2, -4), '', '2, -4'); + +assert.sameValue('abc'.substr(3, -1), '', '3, -1'); +assert.sameValue('abc'.substr(3, -2), '', '3, -2'); +assert.sameValue('abc'.substr(3, -3), '', '3, -3'); +assert.sameValue('abc'.substr(3, -4), '', '3, -4'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-positive.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-positive.js new file mode 100644 index 0000000000..e95b688bd7 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-positive.js @@ -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-string.prototype.substr +es6id: B.2.3.1 +description: Behavior when "length" is a positive number +info: | + [...] + 4. If length is undefined, let end be +∞; otherwise let end be ? + ToInteger(length). + [...] + 7. Let resultLength be min(max(end, 0), size - intStart). + 8. If resultLength ≤ 0, return the empty String "". + 9. Return a String containing resultLength consecutive code units from S + beginning with the code unit at index intStart. +---*/ + +assert.sameValue('abc'.substr(0, 1), 'a', '0, 1'); +assert.sameValue('abc'.substr(0, 2), 'ab', '0, 1'); +assert.sameValue('abc'.substr(0, 3), 'abc', '0, 1'); +assert.sameValue('abc'.substr(0, 4), 'abc', '0, 1'); + +assert.sameValue('abc'.substr(1, 1), 'b', '1, 1'); +assert.sameValue('abc'.substr(1, 2), 'bc', '1, 1'); +assert.sameValue('abc'.substr(1, 3), 'bc', '1, 1'); +assert.sameValue('abc'.substr(1, 4), 'bc', '1, 1'); + +assert.sameValue('abc'.substr(2, 1), 'c', '2, 1'); +assert.sameValue('abc'.substr(2, 2), 'c', '2, 1'); +assert.sameValue('abc'.substr(2, 3), 'c', '2, 1'); +assert.sameValue('abc'.substr(2, 4), 'c', '2, 1'); + +assert.sameValue('abc'.substr(3, 1), '', '3, 1'); +assert.sameValue('abc'.substr(3, 2), '', '3, 1'); +assert.sameValue('abc'.substr(3, 3), '', '3, 1'); +assert.sameValue('abc'.substr(3, 4), '', '3, 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-to-int-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-to-int-err.js new file mode 100644 index 0000000000..fe367827b0 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-to-int-err.js @@ -0,0 +1,29 @@ +// 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-string.prototype.substr +es6id: B.2.3.1 +description: > + Behavior when "length" integer conversion triggers an abrupt completion +info: | + [...] + 3. Let intStart be ? ToInteger(start). +features: [Symbol] +---*/ + +var symbol = Symbol(''); +var len = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.substr(0, len); +}); + +assert.throws(TypeError, function() { + ''.substr(0, symbol); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-undef.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-undef.js new file mode 100644 index 0000000000..abaee99f0e --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-undef.js @@ -0,0 +1,36 @@ +// 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-string.prototype.substr +es6id: B.2.3.1 +description: Behavior when "length" is not defined +info: | + [...] + 4. If length is undefined, let end be +∞; otherwise let end be ? + ToInteger(length). + [...] + 7. Let resultLength be min(max(end, 0), size - intStart). + 8. If resultLength ≤ 0, return the empty String "". + 9. Return a String containing resultLength consecutive code units from S + beginning with the code unit at index intStart. +---*/ + +assert.sameValue('abc'.substr(0), 'abc', 'start: 0, length: unspecified'); +assert.sameValue('abc'.substr(1), 'bc', 'start: 1, length: unspecified'); +assert.sameValue('abc'.substr(2), 'c', 'start: 2, length: unspecified'); +assert.sameValue('abc'.substr(3), '', 'start: 3, length: unspecified'); + +assert.sameValue( + 'abc'.substr(0, undefined), 'abc', 'start: 0, length: undefined' +); +assert.sameValue( + 'abc'.substr(1, undefined), 'bc', 'start: 1, length: undefined' +); +assert.sameValue( + 'abc'.substr(2, undefined), 'c', 'start: 2, length: undefined' +); +assert.sameValue( + 'abc'.substr(3, undefined), '', 'start: 3, length: undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length.js new file mode 100644 index 0000000000..93654798c4 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.1 +description: > + String.prototype.substr.length is 2. +info: | + String.prototype.substr (start, length) + + 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] +---*/ + +verifyProperty(String.prototype.substr, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 2 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/name.js new file mode 100644 index 0000000000..d9b3306250 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.1 +description: > + String.prototype.substr.name is "substr". +info: | + String.prototype.substr (start, length) + + 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] +---*/ + +verifyProperty(String.prototype.substr, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "substr" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/not-a-constructor.js new file mode 100644 index 0000000000..821d6473a4 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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: > + String.prototype.substr 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(String.prototype.substr), + false, + 'isConstructor(String.prototype.substr) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.substr(); +}, '`new String.prototype.substr()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-and-length-as-numbers.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-and-length-as-numbers.js new file mode 100644 index 0000000000..0b0df5427a --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-and-length-as-numbers.js @@ -0,0 +1,94 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.substr +description: > + Test String.prototype.substr with number inputs for start and length. +---*/ + +function ToIntegerOrInfinity(arg) { + assert.sameValue(typeof arg, "number"); + + return Number.isNaN(arg) ? 0 : Math.trunc(arg); +} + +// Basic reference implementation. Expects all inputs have the correct type. +function StringSubstr(string, start, length) { + // Steps 1-2. + assert.sameValue(typeof string, "string"); + + // Step 3. + let size = string.length; + + // Step 4. + let intStart = ToIntegerOrInfinity(start); + + // Steps 5-7. + if (intStart === -Infinity) { + intStart = 0; + } else if (intStart < 0) { + intStart = Math.max(size + intStart, 0); + } else { + intStart = Math.min(intStart, size) + } + + // |0 <= intStart <= size| now holds. + assert(0 <= intStart && intStart <= size); + + // Step 8. + let intLength = length === undefined ? size : ToIntegerOrInfinity(length); + + // Step 9. + intLength = Math.min(Math.max(intLength, 0), size); + + // |0 <= intLength <= size| now holds. + assert(0 <= intLength && intLength <= size); + + // Step 10. + let intEnd = Math.min(intStart + intLength, size); + + // |intStart <= intEnd <= size| now holds. + assert(intStart <= intEnd && intEnd <= size); + + // Step 11. + // + // Call `substring` and check the result is correct. + let result = string.substring(intStart, intEnd); + + assert.sameValue(result.length, intEnd - intStart); + + for (let i = 0; i < result.length; ++i) { + assert.sameValue(result[i], string[intStart + i]); + } + + return result; +} + +const positiveIntegers = [ + 0, 1, 2, 3, 4, 5, 10, 100, +]; + +const integers = [ + ...positiveIntegers, + ...positiveIntegers.map(v => -v), +]; + +const numbers = [ + ...integers, + ...integers.map(v => v + 0.5), + -Infinity, Infinity, NaN, +]; + +for (let string of ["", "a", "ab", "abc"]) { + for (let start of numbers) { + for (let length of [...numbers, undefined]) { + let actual = string.substr(start, length); + let expected = StringSubstr(string, start, length); + + assert.sameValue(actual, expected, `"${string}".substr(${start}, ${length})`); + } + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-negative.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-negative.js new file mode 100644 index 0000000000..de56b29e68 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-negative.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-string.prototype.substr +es6id: B.2.3.1 +description: Behavior when "start" is a negative number +info: | + [...] + 6. If intStart < 0, let intStart be max(size + intStart, 0). +---*/ + +assert.sameValue('abc'.substr(-1), 'c'); +assert.sameValue('abc'.substr(-2), 'bc'); +assert.sameValue('abc'.substr(-3), 'abc'); +assert.sameValue('abc'.substr(-4), 'abc', 'size + intStart < 0'); + +assert.sameValue('abc'.substr(-1.1), 'c', 'floating point rounding semantics'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-to-int-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-to-int-err.js new file mode 100644 index 0000000000..4511de91ba --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-to-int-err.js @@ -0,0 +1,37 @@ +// 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-string.prototype.substr +es6id: B.2.3.1 +description: > + Behavior when "start" integer conversion triggers an abrupt completion +info: | + [...] + 3. Let intStart be ? ToInteger(start). +features: [Symbol] +---*/ + +var lengthCallCount = 0; +var symbol = Symbol(''); +var start = { + valueOf: function() { + throw new Test262Error(); + } +}; +var len = { + valueOf: function() { + lengthCallCount += 1; + } +}; + +assert.throws(Test262Error, function() { + ''.substr(start, len); +}); + +assert.throws(TypeError, function() { + ''.substr(symbol, len); +}); + +assert.sameValue(lengthCallCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/surrogate-pairs.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/surrogate-pairs.js new file mode 100644 index 0000000000..605596d335 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/surrogate-pairs.js @@ -0,0 +1,26 @@ +// 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-string.prototype.substr +es6id: B.2.3.1 +description: > + Behavior when input string contains a surrogate pair +info: | + [...] + 4. If length is undefined, let end be +∞; otherwise let end be ? + ToInteger(length). + [...] + 7. Let resultLength be min(max(end, 0), size - intStart). + 8. If resultLength ≤ 0, return the empty String "". + 9. Return a String containing resultLength consecutive code units from S + beginning with the code unit at index intStart. +---*/ + +assert.sameValue('\ud834\udf06'.substr(0), '\ud834\udf06', 'start: 0'); +assert.sameValue('\ud834\udf06'.substr(1), '\udf06', 'start: 1'); +assert.sameValue('\ud834\udf06'.substr(2), '', 'start: 2'); +assert.sameValue('\ud834\udf06'.substr(0, 0), '', 'end: 0'); +assert.sameValue('\ud834\udf06'.substr(0, 1), '\ud834', 'end: 1'); +assert.sameValue('\ud834\udf06'.substr(0, 2), '\ud834\udf06', 'end: 2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/this-non-obj-coerce.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/this-non-obj-coerce.js new file mode 100644 index 0000000000..7036c9e250 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/this-non-obj-coerce.js @@ -0,0 +1,23 @@ +// 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-string.prototype.substr +es6id: B.2.3.1 +description: Behavior when "this" value is not Object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var substr = String.prototype.substr; + +assert.sameValue(typeof substr, 'function'); + +assert.throws(TypeError, function() { + substr.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + substr.call(null); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/this-to-str-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/this-to-str-err.js new file mode 100644 index 0000000000..669f572a04 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/this-to-str-err.js @@ -0,0 +1,23 @@ +// 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-string.prototype.substr +es6id: B.2.3.1 +description: Behavior when string conversion triggers an abrupt completion +info: | + 1. Let O be ? RequireObjectCoercible(this value). + 2. Let S be ? ToString(O). +---*/ + +var substr = String.prototype.substr; +var thisValue = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + substr.call(thisValue); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/B.2.3.14.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/B.2.3.14.js new file mode 100644 index 0000000000..a54131b658 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/B.2.3.14.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// Tests taken from: +// http://mathias.html5.org/tests/javascript/string/ + +/*--- + description: > + String.prototype.sup returns a string of HTML describing a single HTML + superscript element. The element's content is the `this` value of the + function invocation, coerced to a string. + es6id: B.2.3.14 +---*/ + +assert.sameValue('_'.sup(), '<sup>_</sup>'); +assert.sameValue('<'.sup(), '<sup><</sup>'); +assert.sameValue(String.prototype.sup.call(0x2A), '<sup>42</sup>'); +assert.throws(TypeError, function() { + String.prototype.sup.call(undefined); +}); +assert.throws(TypeError, function() { + String.prototype.sup.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/length.js new file mode 100644 index 0000000000..d05dc61b42 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.14 +description: > + String.prototype.sup.length is 0. +info: | + String.prototype.sup ( ) + + 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] +---*/ + +verifyProperty(String.prototype.sup, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/name.js new file mode 100644 index 0000000000..054d5484ef --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.3.14 +description: > + String.prototype.sup.name is "sup". +info: | + String.prototype.sup ( ) + + 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] +---*/ + +verifyProperty(String.prototype.sup, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "sup" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/not-a-constructor.js new file mode 100644 index 0000000000..461a34d60e --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/not-a-constructor.js @@ -0,0 +1,30 @@ +// 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: > + String.prototype.sup 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(String.prototype.sup), false, 'isConstructor(String.prototype.sup) must return false'); + +assert.throws(TypeError, () => { + new String.prototype.sup(); +}, '`new String.prototype.sup()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/prop-desc.js new file mode 100644 index 0000000000..c22448d3fb --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/prop-desc.js @@ -0,0 +1,20 @@ +// 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-string.prototype.sup +es6id: B.2.3.14 +description: Property descriptor for String.prototype.sup +info: | + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype, "sup", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/this-val-tostring-err.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/this-val-tostring-err.js new file mode 100644 index 0000000000..ef2669921f --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/this-val-tostring-err.js @@ -0,0 +1,24 @@ +// 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-string.prototype.sup +es6id: B.2.3.14 +description: Abrupt completion when coercing "this" value to string +info: | + B.2.3.2.1 Runtime Semantics: CreateHTML + + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). +---*/ + +var thisVal = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.sup.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/length.js new file mode 100644 index 0000000000..76d4b87fc5 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimLeft +description: > + String.prototype.trimLeft.length is 0. +info: > + String.prototype.trimLeft ( ) + + 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] +features: [string-trimming] +---*/ + +verifyProperty(String.prototype.trimLeft, "length", { + value: 0, + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/name.js new file mode 100644 index 0000000000..277da5d95f --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimLeft +description: > + String.prototype.trimLeft.name is "trimStart". +info: > + String.prototype.trimLeft ( ) + + The function object that is the initial value of String.prototype.trimLeft is the same function object that is the initial value of String.prototype.trimStart. + +includes: [propertyHelper.js] +features: [string-trimming, String.prototype.trimStart] +---*/ + +verifyProperty(String.prototype.trimLeft, "name", { + value: "trimStart", + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/prop-desc.js new file mode 100644 index 0000000000..f1589dbacc --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/prop-desc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 The Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimLeft +description: > + "trimLeft" property of String.prototype +info: > + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [string-trimming] +---*/ + +verifyProperty(String.prototype, "trimLeft", { + enumerable: false, + writable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/reference-trimStart.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/reference-trimStart.js new file mode 100644 index 0000000000..d9c709aff1 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/reference-trimStart.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimLeft +description: > + String.prototype.trimLeft is a reference to String.prototype.trimStart. +info: > + String.prototype.trimLeft ( ) + + The function object that is the initial value of String.prototype.trimLeft + is the same function object that is the initial value of + String.prototype.trimStart. +features: [string-trimming] +---*/ + +assert.sameValue(String.prototype.trimLeft, String.prototype.trimStart); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimLeft/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/browser.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/length.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/length.js new file mode 100644 index 0000000000..53ece40072 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimRight +description: > + String.prototype.trimRight.length is 0. +info: > + String.prototype.trimRight ( ) + + 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] +features: [string-trimming] +---*/ + +verifyProperty(String.prototype.trimRight, "length", { + value: 0, + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/name.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/name.js new file mode 100644 index 0000000000..43f7b94849 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimRight +description: > + String.prototype.trimRight.name is "trimEnd". +info: > + String.prototype.trimRight ( )# + + The function object that is the initial value of String.prototype.trimRight is the same function object that is the initial value of String.prototype.trimEnd. +includes: [propertyHelper.js] +features: [string-trimming, String.prototype.trimEnd] +---*/ + +verifyProperty(String.prototype.trimRight, "name", { + value: "trimEnd", + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/prop-desc.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/prop-desc.js new file mode 100644 index 0000000000..a2b1e52c90 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/prop-desc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 The Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimRight +description: > + "trimRight" property of String.prototype +info: > + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [string-trimming] +---*/ + +verifyProperty(String.prototype, "trimRight", { + enumerable: false, + writable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/reference-trimEnd.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/reference-trimEnd.js new file mode 100644 index 0000000000..23a375af15 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/reference-trimEnd.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimRight +description: > + String.prototype.trimRight is a reference to String.prototype.trimEnd. +info: > + String.prototype.trimRight ( ) + + The function object that is the initial value of String.prototype.trimRight + is the same function object that is the initial value of + String.prototype.trimEnd. +features: [string-trimming] +---*/ + +assert.sameValue(String.prototype.trimRight, String.prototype.trimEnd); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/shell.js b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/trimRight/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/String/shell.js b/js/src/tests/test262/annexB/built-ins/String/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/shell.js |