Add missing explicit ToString conversion for symbol values and ensure the expected NaN result is a (locale-dependent) string

This commit is contained in:
André Bargull 2018-09-24 08:49:37 -04:00 committed by Rick Waldron
parent 3febd4c536
commit 4bc96880a1
4 changed files with 12 additions and 6 deletions

View File

@ -10,8 +10,14 @@ info: |
11.1.4 Number Format Functions 11.1.4 Number Format Functions
3. If value is not provided, let value be undefined. 3. If value is not provided, let value be undefined.
4. Let x be ? ToNumber(value).
---*/ ---*/
const nf = new Intl.NumberFormat(); const nf = new Intl.NumberFormat();
assert.sameValue(nf.format(), NaN);
assert.sameValue(nf.format(undefined), NaN); // In most locales this is string "NaN", but there are exceptions, cf. "ليس رقم"
// in Arabic, "epäluku" in Finnish, "не число" in Russian, "son emas" in Uzbek etc.
const resultNaN = nf.format(NaN);
assert.sameValue(nf.format(), resultNaN);
assert.sameValue(nf.format(undefined), resultNaN);

View File

@ -16,6 +16,6 @@ invalidTargets.forEach(target => {
assert.throws( assert.throws(
TypeError, TypeError,
() => fn.call(target), () => fn.call(target),
`Calling format getter on ${target} should throw a TypeError.` `Calling format getter on ${String(target)} should throw a TypeError.`
); );
}); });

View File

@ -16,6 +16,6 @@ invalidTargets.forEach(target => {
assert.throws( assert.throws(
TypeError, TypeError,
() => fn.call(target), () => fn.call(target),
`Calling formatToParts on ${target} should throw a TypeError.` `Calling formatToParts on ${String(target)} should throw a TypeError.`
); );
}); });

View File

@ -16,6 +16,6 @@ invalidTargets.forEach(target => {
assert.throws( assert.throws(
TypeError, TypeError,
() => fn.call(target), () => fn.call(target),
`Calling resolvedOptions on ${target} should throw a TypeError.` `Calling resolvedOptions on ${String(target)} should throw a TypeError.`
); );
}); });