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/non262/Intl/Locale/surface.js | |
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 '')
-rw-r--r-- | js/src/tests/non262/Intl/Locale/surface.js | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/js/src/tests/non262/Intl/Locale/surface.js b/js/src/tests/non262/Intl/Locale/surface.js new file mode 100644 index 0000000000..ba90182436 --- /dev/null +++ b/js/src/tests/non262/Intl/Locale/surface.js @@ -0,0 +1,98 @@ +// |reftest| skip-if(!this.hasOwnProperty('Intl')) + +function assertProperty(object, name, desc) { + assertEq(desc === undefined || (typeof desc === "object" && desc !== null), true, + "desc is a property descriptor"); + + var actual = Object.getOwnPropertyDescriptor(object, name); + if (desc === undefined) { + assertEq(actual, desc, `property ${String(name)} is absent`); + return; + } + assertEq(actual !== undefined, true, `property ${String(name)} is present`); + + var fields = ["value", "writable", "enumerable", "configurable", "get", "set"]; + for (var field of fields) { + if (Object.prototype.hasOwnProperty.call(desc, field)) { + assertEq(actual[field], desc[field], `unexpected value for ${field}`); + } + } +} + +function assertBuiltinFunction(fn, length, name) { + assertProperty(fn, "length", { + value: length, writable: false, enumerable: false, configurable: true, + }); +} + +function assertBuiltinMethod(object, propName, length, name) { + var desc = Object.getOwnPropertyDescriptor(object, propName); + assertProperty(object, propName, { + value: desc.value, writable: true, enumerable: false, configurable: true + }); + assertBuiltinFunction(desc.value, length, name); +} + +function assertBuiltinGetter(object, propName, length, name) { + var desc = Object.getOwnPropertyDescriptor(object, propName); + + assertBuiltinFunction(desc.get, length, name); +} + +// Intl.Locale( tag[, options] ) +assertBuiltinFunction(Intl.Locale, 1, "Locale"); + +// Properties of the Intl.Locale Constructor + +// Intl.Locale.prototype +assertProperty(Intl.Locale, "prototype", { + value: Intl.Locale.prototype, writable: false, enumerable: false, configurable: false, +}); + +// Properties of the Intl.Locale Prototype Object + +// Intl.Locale.prototype.constructor +assertProperty(Intl.Locale.prototype, "constructor", { + value: Intl.Locale, writable: true, enumerable: false, configurable: true, +}); + +// Intl.Locale.prototype[ @@toStringTag ] +assertProperty(Intl.Locale.prototype, Symbol.toStringTag, { + value: "Intl.Locale", writable: false, enumerable: false, configurable: true, +}); + +// Intl.Locale.prototype.toString () +assertBuiltinMethod(Intl.Locale.prototype, "toString", 0, "toString"); + +// get Intl.Locale.prototype.baseName +assertBuiltinGetter(Intl.Locale.prototype, "baseName", 0, "get baseName"); + +// get Intl.Locale.prototype.calendar +assertBuiltinGetter(Intl.Locale.prototype, "calendar", 0, "get calendar"); + +// get Intl.Locale.prototype.collation +assertBuiltinGetter(Intl.Locale.prototype, "collation", 0, "get collation"); + +// get Intl.Locale.prototype.hourCycle +assertBuiltinGetter(Intl.Locale.prototype, "hourCycle", 0, "get hourCycle"); + +// get Intl.Locale.prototype.caseFirst +assertBuiltinGetter(Intl.Locale.prototype, "caseFirst", 0, "get caseFirst"); + +// get Intl.Locale.prototype.numeric +assertBuiltinGetter(Intl.Locale.prototype, "numeric", 0, "get numeric"); + +// get Intl.Locale.prototype.numberingSystem +assertBuiltinGetter(Intl.Locale.prototype, "numberingSystem", 0, "get numberingSystem"); + +// get Intl.Locale.prototype.language +assertBuiltinGetter(Intl.Locale.prototype, "language", 0, "get language"); + +// get Intl.Locale.prototype.script +assertBuiltinGetter(Intl.Locale.prototype, "script", 0, "get script"); + +// get Intl.Locale.prototype.region +assertBuiltinGetter(Intl.Locale.prototype, "region", 0, "get region"); + +if (typeof reportCompare === "function") + reportCompare(0, 0); |