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/built-ins/String/prototype/normalize | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.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/built-ins/String/prototype/normalize')
16 files changed, 384 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/browser.js b/js/src/tests/test262/built-ins/String/prototype/normalize/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/form-is-not-valid-throws.js b/js/src/tests/test262/built-ins/String/prototype/normalize/form-is-not-valid-throws.js new file mode 100644 index 0000000000..85db8ba768 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/form-is-not-valid-throws.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Throws a RangeError if ToString(form) value is not a valid form name. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 7. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", throw a RangeError + exception. +---*/ + +assert.throws(RangeError, function() { + 'foo'.normalize('bar'); +}); + +assert.throws(RangeError, function() { + 'foo'.normalize('NFC1'); +}); + +assert.throws(RangeError, function() { + 'foo'.normalize(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/length.js b/js/src/tests/test262/built-ins/String/prototype/normalize/length.js new file mode 100644 index 0000000000..f95c97046e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + String.prototype.normalize.length value and descriptor. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.normalize.length, 0, + 'The value of `String.prototype.normalize.length` is `0`' +); + +verifyNotEnumerable(String.prototype.normalize, 'length'); +verifyNotWritable(String.prototype.normalize, 'length'); +verifyConfigurable(String.prototype.normalize, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/name.js b/js/src/tests/test262/built-ins/String/prototype/normalize/name.js new file mode 100644 index 0000000000..e3d3ef3acc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + String.prototype.normalize.name value and descriptor. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.normalize.name, 'normalize', + 'The value of `String.prototype.normalize.name` is `"normalize"`' +); + +verifyNotEnumerable(String.prototype.normalize, 'name'); +verifyNotWritable(String.prototype.normalize, 'name'); +verifyConfigurable(String.prototype.normalize, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/normalize.js b/js/src/tests/test262/built-ins/String/prototype/normalize/normalize.js new file mode 100644 index 0000000000..4304be9bbf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/normalize.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Property type and descriptor. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof String.prototype.normalize, + 'function', + '`typeof String.prototype.normalize` is `function`' +); + +verifyNotEnumerable(String.prototype, 'normalize'); +verifyWritable(String.prototype, 'normalize'); +verifyConfigurable(String.prototype, 'normalize'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/normalize/not-a-constructor.js new file mode 100644 index 0000000000..e1c16b4e10 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + String.prototype.normalize 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.normalize), + false, + 'isConstructor(String.prototype.normalize) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.normalize(); +}, '`new String.prototype.normalize()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form-as-symbol.js new file mode 100644 index 0000000000..b8e6a56ec8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form-as-symbol.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns abrupt from ToString(form) as a Symbol. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 4. If form is not provided or form is undefined, let form be "NFC". + 5. Let f be ToString(form). + 6. ReturnIfAbrupt(f). +features: [Symbol] +---*/ + +var s = Symbol('foo'); + +assert.throws(TypeError, function() { + 'foo'.normalize(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form.js new file mode 100644 index 0000000000..907bc55a05 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns abrupt from ToString(form) +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 4. If form is not provided or form is undefined, let form be "NFC". + 5. Let f be ToString(form). + 6. ReturnIfAbrupt(f). +---*/ + +var o = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + 'foo'.normalize(o); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this-as-symbol.js new file mode 100644 index 0000000000..67004180bc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this-as-symbol.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns abrupt from ToString(this) where this is a Symbol +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [Symbol] +---*/ + +var s = Symbol('foo'); + +assert.throws(TypeError, function() { + String.prototype.normalize.call(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this.js new file mode 100644 index 0000000000..217a13754b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns abrupt from ToString(this) +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +---*/ + +var o = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.normalize.call(o); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-from-coerced-form.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-from-coerced-form.js new file mode 100644 index 0000000000..63c4f5a3c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-from-coerced-form.js @@ -0,0 +1,43 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns normalized string from coerced form. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 4. If form is not provided or form is undefined, let form be "NFC". + 5. Let f be ToString(form). + 6. ReturnIfAbrupt(f). + 7. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", throw a RangeError + exception. + 8. Let ns be the String value that is the result of normalizing S into the + normalization form named by f as specified in + http://www.unicode.org/reports/tr15/tr15-29.html. + 9. Return ns. +---*/ + +var s = '\u00C5\u2ADC\u0958\u2126\u0344'; +var nfc = '\xC5\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301'; +var nfd = 'A\u030A\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301'; +var o = { + toString: function() { + return 'NFC'; + } +}; + +assert.sameValue(s.normalize(['NFC']), nfc, 'coerced array - NFC'); +assert.sameValue(s.normalize(o), nfc, 'coerced object - NFC'); + +o = { + toString: function() { + return 'NFD'; + } +}; + +assert.sameValue(s.normalize(['NFD']), nfd, 'coerced array - NFD'); +assert.sameValue(s.normalize(o), nfd, 'coerced object - NFD'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-using-default-parameter.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-using-default-parameter.js new file mode 100644 index 0000000000..06219727ba --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-using-default-parameter.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns normalized string. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 4. If form is not provided or form is undefined, let form be "NFC". + ... + 8. Let ns be the String value that is the result of normalizing S into the + normalization form named by f as specified in + http://www.unicode.org/reports/tr15/tr15-29.html. + 9. Return ns. +---*/ + +var s = '\u00C5\u2ADC\u0958\u2126\u0344'; +var nfc = '\xC5\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301'; + +assert.sameValue(s.normalize(), nfc, 'Use NFC as the default form'); +assert.sameValue(s.normalize(undefined), nfc, 'Use NFC as the default form'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string.js new file mode 100644 index 0000000000..d7caf14ea7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string.js @@ -0,0 +1,50 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns normalized string. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 7. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", throw a RangeError + exception. + 8. Let ns be the String value that is the result of normalizing S into the + normalization form named by f as specified in + http://www.unicode.org/reports/tr15/tr15-29.html. + 9. Return ns. +---*/ + +var s = '\u1E9B\u0323'; + +assert.sameValue(s.normalize('NFC'), '\u1E9B\u0323', 'Normalized on NFC'); +assert.sameValue(s.normalize('NFD'), '\u017F\u0323\u0307', 'Normalized on NFD'); +assert.sameValue(s.normalize('NFKC'), '\u1E69', 'Normalized on NFKC'); +assert.sameValue(s.normalize('NFKD'), '\u0073\u0323\u0307', 'Normalized on NFKD'); + +assert.sameValue( + '\u00C5\u2ADC\u0958\u2126\u0344'.normalize('NFC'), + '\xC5\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301', + 'Normalized on NFC' +); + +assert.sameValue( + '\u00C5\u2ADC\u0958\u2126\u0344'.normalize('NFD'), + 'A\u030A\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301', + 'Normalized on NFD' +); + +assert.sameValue( + '\u00C5\u2ADC\u0958\u2126\u0344'.normalize('NFKC'), + '\xC5\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301', + 'Normalized on NFKC' +); + +assert.sameValue( + '\u00C5\u2ADC\u0958\u2126\u0344'.normalize('NFKD'), + 'A\u030A\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301', + 'Normalized on NFKD' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/shell.js b/js/src/tests/test262/built-ins/String/prototype/normalize/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-null-throws.js b/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-null-throws.js new file mode 100644 index 0000000000..899eec94fd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-null-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Throws TypeError when `this` is null +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.normalize.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-undefined-throws.js new file mode 100644 index 0000000000..41ef7ba087 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-undefined-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Throws TypeError when `this` is undefined +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.normalize.call(undefined); +}); + +reportCompare(0, 0); |