diff --git a/test/built-ins/String/prototype/trimEnd/this-value-object-cannot-convert-to-primitive-err.js b/test/built-ins/String/prototype/trimEnd/this-value-object-cannot-convert-to-primitive-err.js index 1a9d5418ac7606f96a6adf9dad1681b70305bb42..5868746d28cbe0134cab5446076c501ada74673a 100644 --- a/test/built-ins/String/prototype/trimEnd/this-value-object-cannot-convert-to-primitive-err.js +++ b/test/built-ins/String/prototype/trimEnd/this-value-object-cannot-convert-to-primitive-err.js @@ -43,6 +43,8 @@ info: | features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] ---*/ +assert.sameValue(typeof String.prototype.trimEnd, "function"); + var thisVal = { [Symbol.toPrimitive]: undefined, toString: undefined, diff --git a/test/built-ins/String/prototype/trimEnd/this-value-symbol-typeerror.js b/test/built-ins/String/prototype/trimEnd/this-value-symbol-typeerror.js index d043708aac0084f0f4793e57563e165ff5f5910d..b01bf3a9e083129a21810e01bbe7a8cf91810be8 100644 --- a/test/built-ins/String/prototype/trimEnd/this-value-symbol-typeerror.js +++ b/test/built-ins/String/prototype/trimEnd/this-value-symbol-typeerror.js @@ -14,6 +14,8 @@ info: | features: [string-trimming, String.prototype.trimEnd] ---*/ +assert.sameValue(typeof String.prototype.trimEnd, "function"); + var trimEnd = String.prototype.trimEnd; var symbol = Symbol(); diff --git a/test/built-ins/String/prototype/trimStart/this-value-object-cannot-convert-to-primitive-err.js b/test/built-ins/String/prototype/trimStart/this-value-object-cannot-convert-to-primitive-err.js index 36db2ae6714585ce21a971dc905f3e17072dc29b..7005c12815602697f0b2eb71543b34bd7b8e4aea 100644 --- a/test/built-ins/String/prototype/trimStart/this-value-object-cannot-convert-to-primitive-err.js +++ b/test/built-ins/String/prototype/trimStart/this-value-object-cannot-convert-to-primitive-err.js @@ -43,6 +43,8 @@ info: | features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] ---*/ +assert.sameValue(typeof String.prototype.trimStart, "function"); + var thisVal = { [Symbol.toPrimitive]: undefined, toString: undefined, diff --git a/test/built-ins/String/prototype/trimStart/this-value-symbol-typeerror.js b/test/built-ins/String/prototype/trimStart/this-value-symbol-typeerror.js index f49280759733509f41b3284e9d7a4f60f7996778..cf5568bec5fd54bd819e8353321f6551718e205f 100644 --- a/test/built-ins/String/prototype/trimStart/this-value-symbol-typeerror.js +++ b/test/built-ins/String/prototype/trimStart/this-value-symbol-typeerror.js @@ -14,6 +14,8 @@ info: | features: [string-trimming, String.prototype.trimStart] ---*/ +assert.sameValue(typeof String.prototype.trimStart, "function"); + var trimStart = String.prototype.trimStart; var symbol = Symbol(); diff --git a/test/intl402/Locale/constructor-newtarget-undefined.js b/test/intl402/Locale/constructor-newtarget-undefined.js index e8e542976d60339c609a6182776af514c4857d08..a0583b7039ce752d2c9826e13f50f6a7bd24bf1b 100644 --- a/test/intl402/Locale/constructor-newtarget-undefined.js +++ b/test/intl402/Locale/constructor-newtarget-undefined.js @@ -12,6 +12,8 @@ info: | features: [Intl.Locale] ---*/ +assert.sameValue(typeof Intl.Locale, "function"); + assert.throws(TypeError, function() { Intl.Locale(); }, 'Intl.Locale() throws TypeError'); diff --git a/test/intl402/Locale/invalid-tag-throws-boolean.js b/test/intl402/Locale/invalid-tag-throws-boolean.js index ce6937e2ea60a20ea3e62f23ddd04cb495fd8109..55226570c034c861cee8b28cc598db0c87fa9ad6 100644 --- a/test/intl402/Locale/invalid-tag-throws-boolean.js +++ b/test/intl402/Locale/invalid-tag-throws-boolean.js @@ -12,6 +12,8 @@ info: | features: [Intl.Locale] ---*/ +assert.sameValue(typeof Intl.Locale, "function"); + assert.throws(TypeError, function() { new Intl.Locale(true); }, "true is an invalid tag value"); diff --git a/test/intl402/Locale/invalid-tag-throws-null.js b/test/intl402/Locale/invalid-tag-throws-null.js index 6d08c26286aa2c0b003aeb14eaae03ea1c12f2e2..d611f1c477e2e01fdcdebb9ae8302b22c2af5ffd 100644 --- a/test/intl402/Locale/invalid-tag-throws-null.js +++ b/test/intl402/Locale/invalid-tag-throws-null.js @@ -12,6 +12,8 @@ info: | features: [Intl.Locale] ---*/ +assert.sameValue(typeof Intl.Locale, "function"); + assert.throws(TypeError, function() { new Intl.Locale(null); }, "null is an invalid tag value"); diff --git a/test/intl402/Locale/invalid-tag-throws-number.js b/test/intl402/Locale/invalid-tag-throws-number.js index 805d36c525e4bf8c0199202c8337fcf287032fa7..eef4a85110f5757316e141ccb6773889b5cce3a5 100644 --- a/test/intl402/Locale/invalid-tag-throws-number.js +++ b/test/intl402/Locale/invalid-tag-throws-number.js @@ -12,6 +12,8 @@ info: | features: [Intl.Locale] ---*/ +assert.sameValue(typeof Intl.Locale, "function"); + assert.throws(TypeError, function() { new Intl.Locale(0); }, "0 is an invalid tag value"); diff --git a/test/intl402/Locale/invalid-tag-throws-symbol.js b/test/intl402/Locale/invalid-tag-throws-symbol.js index d99264671df54e6f7c64fc671347c80117af4880..7274916db64ba11d51254ab2b39d63320b654c82 100644 --- a/test/intl402/Locale/invalid-tag-throws-symbol.js +++ b/test/intl402/Locale/invalid-tag-throws-symbol.js @@ -12,6 +12,8 @@ info: | features: [Intl.Locale, Symbol] ---*/ +assert.sameValue(typeof Intl.Locale, "function"); + assert.throws(TypeError, function() { new Intl.Locale(Symbol()); }, "Symbol() is an invalid tag value"); diff --git a/test/intl402/Locale/invalid-tag-throws-undefined.js b/test/intl402/Locale/invalid-tag-throws-undefined.js index 609c20b38439a01077532e19b85ea856474da11a..c3a35dd93f3cee9e8a355ed375cf75e2f7d0e6e9 100644 --- a/test/intl402/Locale/invalid-tag-throws-undefined.js +++ b/test/intl402/Locale/invalid-tag-throws-undefined.js @@ -12,6 +12,8 @@ info: | features: [Intl.Locale] ---*/ +assert.sameValue(typeof Intl.Locale, "function"); + assert.throws(TypeError, function() { new Intl.Locale(); }, "(empty) is an invalid tag value"); diff --git a/test/intl402/Locale/invalid-tag-throws.js b/test/intl402/Locale/invalid-tag-throws.js index ee6449510f18f41ecef442b5a0d7b74118ec9583..86e5a130700000337ec4c2692246724ad19b158f 100644 --- a/test/intl402/Locale/invalid-tag-throws.js +++ b/test/intl402/Locale/invalid-tag-throws.js @@ -24,10 +24,11 @@ includes: [testIntl.js] features: [Intl.Locale] ---*/ +assert.sameValue(typeof Intl.Locale, "function"); + // Intl.Locale step 11.a. assert.throws(TypeError, function() { new Intl.Locale("en", null) }) - // ApplyOptionsToTag step 2. for (const invalidTag of getInvalidLanguageTags()) { assert.throws(RangeError, function() { diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/locales-invalid.js b/test/intl402/RelativeTimeFormat/constructor/constructor/locales-invalid.js index 9c98223d41738affe7ae3dc6bb59cf53ea38322c..8d3dcd8354ed0970f36a2fc6218ac5d4a9236ac6 100644 --- a/test/intl402/RelativeTimeFormat/constructor/constructor/locales-invalid.js +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/locales-invalid.js @@ -11,6 +11,10 @@ includes: [testIntl.js] features: [Intl.RelativeTimeFormat] ---*/ +assert.sameValue(typeof Intl.RelativeTimeFormat, "function"); + for (const [locales, expectedError] of getInvalidLocaleArguments()) { - assert.throws(expectedError, function() { new Intl.RelativeTimeFormat(locales) }) + assert.throws(expectedError, function() { + new Intl.RelativeTimeFormat(locales) + }, `using ${String(locales)} expects ${expectedError}`); } diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js b/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js index e4775cc5174bcb51b066f6633c547efcc287ba32..53a169fb688677b1427941cbe2223a01924e5a4a 100644 --- a/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js @@ -12,6 +12,8 @@ info: | features: [Intl.RelativeTimeFormat] ---*/ +assert.sameValue(typeof Intl.RelativeTimeFormat, "function"); + assert.throws(TypeError, function() { Intl.RelativeTimeFormat(); }); diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/options-invalid.js b/test/intl402/RelativeTimeFormat/constructor/constructor/options-invalid.js index 90df4ffdb47a7820c65ce27d270fe5bfc4c4028e..287f7e4b49bf73a71afe7a30804a7ba9ef4d4032 100644 --- a/test/intl402/RelativeTimeFormat/constructor/constructor/options-invalid.js +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/options-invalid.js @@ -11,4 +11,6 @@ info: | features: [Intl.RelativeTimeFormat] ---*/ +assert.sameValue(typeof Intl.RelativeTimeFormat, "function"); + assert.throws(TypeError, function() { new Intl.RelativeTimeFormat([], null) }) diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/options-numeric-invalid.js b/test/intl402/RelativeTimeFormat/constructor/constructor/options-numeric-invalid.js index d0733a06e45fc816172532286279a844fd5c61d8..4b27d069026eddc802df9c841157e4631d3c68db 100644 --- a/test/intl402/RelativeTimeFormat/constructor/constructor/options-numeric-invalid.js +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/options-numeric-invalid.js @@ -10,6 +10,8 @@ info: | features: [Intl.RelativeTimeFormat] ---*/ +assert.sameValue(typeof Intl.RelativeTimeFormat, "function"); + const invalidOptions = [ null, 1, diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/options-throwing-getters.js b/test/intl402/RelativeTimeFormat/constructor/constructor/options-throwing-getters.js index 705574c4d3c6ea8250ba506106d9aa579bbb75fb..273995b2c1a5c31cdff8ad8b0cb828ed716298f1 100644 --- a/test/intl402/RelativeTimeFormat/constructor/constructor/options-throwing-getters.js +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/options-throwing-getters.js @@ -4,23 +4,82 @@ /*--- esid: sec-InitializeRelativeTimeFormat description: Checks the propagation of exceptions from the options for the RelativeTimeFormat constructor. +info: | + InitializeRelativeTimeFormat + + 5. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit"). + ... + 12. Let s be ? GetOption(options, "style", "string", «"long", "short", "narrow"», "long"). + ... + 14. Let numeric be ? GetOption(options, "numeric", "string", «"always", "auto"», "always"). + + GetOption ( options, property, type, values, fallback ) + + 1. Let value be ? Get(options, property). + 2. If value is not undefined, then + a. Assert: type is "boolean" or "string". + b. If type is "boolean", then + i. Let value be ToBoolean(value). + c. If type is "string", then + i. Let value be ? ToString(value). + d. If values is not undefined, then + i. If values does not contain an element equal to value, throw a RangeError exception. + e. Return value. + 3. Else, return fallback. features: [Intl.RelativeTimeFormat] +includes: [compareArray.js] ---*/ function CustomError() {} -const options = [ - "localeMatcher", - "style", - "numeric", -]; - -for (const option of options) { - assert.throws(CustomError, () => { - new Intl.RelativeTimeFormat("en", { - get [option]() { - throw new CustomError(); - } - }); - }, `Exception from ${option} getter should be propagated`); -} +const o1 = { + get localeMatcher() { + throw new CustomError(); + }, + get style() { + throw "should not get the style option before localeMatcher"; + }, + get numeric() { + throw "should not get the numeric option before localeMatcher"; + } +}; + +const o2captures = []; +const o2 = { + get localeMatcher() { + o2captures.push('localeMatcher'); + }, + get style() { + throw new CustomError(); + }, + get numeric() { + throw "should not get the numeric option before style"; + } +}; + +const o3captures = []; +const o3 = { + get localeMatcher() { + o3captures.push('localeMatcher'); + }, + get style() { + o3captures.push('style'); + }, + get numeric() { + throw new CustomError(); + } +}; + +assert.throws(CustomError, () => { + new Intl.RelativeTimeFormat("en", o1); +}, `Exception from localeMatcher getter should be propagated`); + +assert.throws(CustomError, () => { + new Intl.RelativeTimeFormat("en", o2); +}, `Exception from style getter should be propagated`); +assert.compareArray(o2captures, ['localeMatcher']); + +assert.throws(CustomError, () => { + new Intl.RelativeTimeFormat("en", o3); +}, `Exception from numeric getter should be propagated`); +assert.compareArray(o3captures, ['localeMatcher', 'style']); diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/options-undefined.js b/test/intl402/RelativeTimeFormat/constructor/constructor/options-undefined.js index f5ab4bf838bfb2bbbb3b0f1d244445f84ed1c085..c2cd1c3df14810059afda75ba8c7e48c959c33a0 100644 --- a/test/intl402/RelativeTimeFormat/constructor/constructor/options-undefined.js +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/options-undefined.js @@ -10,12 +10,12 @@ features: [Intl.RelativeTimeFormat] ---*/ Object.defineProperties(Object.prototype, { - "style": { + style: { get() { throw new Error("Should not call style getter"); } }, - "numeric": { + numeric: { get() { throw new Error("Should not call numeric getter"); } @@ -32,7 +32,7 @@ for (const args of optionsArguments) { const rtf = new Intl.RelativeTimeFormat(...args); const resolvedOptions = rtf.resolvedOptions(); assert.sameValue(resolvedOptions.style, "long", - `Calling with ${args.length} empty arguments should yield the correct value for "style"`); + `Calling with ${args.length} empty arguments should yield the fallback value for "style"`); assert.sameValue(resolvedOptions.numeric, "always", - `Calling with ${args.length} empty arguments should yield the correct value for "numeric"`); + `Calling with ${args.length} empty arguments should yield the fallback value for "numeric"`); } diff --git a/test/intl402/Segmenter/constructor/constructor/newtarget-undefined.js b/test/intl402/Segmenter/constructor/constructor/newtarget-undefined.js index 248263488433b283092f0278911da28ccb9ba8e6..387304e9e886a9c69c144f8dc9dd3a1c135295c0 100644 --- a/test/intl402/Segmenter/constructor/constructor/newtarget-undefined.js +++ b/test/intl402/Segmenter/constructor/constructor/newtarget-undefined.js @@ -11,6 +11,8 @@ info: | features: [Intl.Segmenter] ---*/ +assert.sameValue(typeof Intl.Segmenter, "function"); + assert.throws(TypeError, function() { Intl.Segmenter(); });