Skip to content

Commit dc5fb4e

Browse files
committed
[JSC] Fix length of Intl.NumberFormat.formatRange and Intl.PluralRules.selectRange
https://bugs.webkit.org/show_bug.cgi?id=234806 Reviewed by Alexey Shvayka. JSTests: * stress/intl-numberformat-format-range-v3.js: (nf.formatRange.nf.formatRangeToParts.methods.forEach): * stress/intl-pluralrules-selectrange.js: Source/JavaScriptCore: These length's numbers are wrong. This patch fixes them. * runtime/IntlNumberFormatPrototype.cpp: (JSC::IntlNumberFormatPrototype::finishCreation): * runtime/IntlPluralRulesPrototype.cpp: (JSC::IntlPluralRulesPrototype::finishCreation): Canonical link: https://commits.webkit.org/245678@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 7434574 commit dc5fb4e

7 files changed

Lines changed: 72 additions & 15 deletions

File tree

JSTests/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2022-01-03 Yusuke Suzuki <ysuzuki@apple.com>
2+
3+
[JSC] Fix length of Intl.NumberFormat.formatRange and Intl.PluralRules.selectRange
4+
https://bugs.webkit.org/show_bug.cgi?id=234806
5+
6+
Reviewed by Alexey Shvayka.
7+
8+
* stress/intl-numberformat-format-range-v3.js:
9+
(nf.formatRange.nf.formatRangeToParts.methods.forEach):
10+
* stress/intl-pluralrules-selectrange.js:
11+
112
2022-01-03 Yusuke Suzuki <ysuzuki@apple.com>
213

314
[JSC] Update test262

JSTests/stress/intl-numberformat-format-range-v3.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ if (nf.formatRange || nf.formatRangeToParts) {
6363
// Assert if called without nf
6464
let f = nf[method];
6565
shouldThrow(() => { f(1, 23) }, TypeError);
66+
shouldBe(f.length, 2);
6667

6768
// Assert normal call success
6869
shouldNotThrow(() => nf[method](1, 23));

JSTests/stress/intl-pluralrules-selectrange.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ function shouldBe(actual, expected) {
3232

3333
if (Intl.PluralRules.prototype.selectRange) {
3434
const pl = new Intl.PluralRules("sl");
35+
shouldBe(pl.selectRange.length, 2);
3536
shouldBe("few", pl.selectRange(102, 201));
3637
}

JSTests/test262/expectations.yaml

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,12 +1386,33 @@ test/intl402/NumberFormat/prototype/format/useGrouping-extended-en-IN.js:
13861386
test/intl402/NumberFormat/prototype/format/value-decimal-string.js:
13871387
default: 'Test262Error: Expected SameValue(«1», «1.0000000000000001») to be true'
13881388
strict mode: 'Test262Error: Expected SameValue(«1», «1.0000000000000001») to be true'
1389+
test/intl402/NumberFormat/prototype/formatRange/builtin.js:
1390+
default: 'Test262Error: The [[Class]] internal property of a built-in function must be "Function". Expected SameValue(«[object Undefined]», «[object Function]») to be true'
1391+
strict mode: 'Test262Error: The [[Class]] internal property of a built-in function must be "Function". Expected SameValue(«[object Undefined]», «[object Function]») to be true'
1392+
test/intl402/NumberFormat/prototype/formatRange/en-US.js:
1393+
default: "TypeError: nf.formatRange is not a function. (In 'nf.formatRange(3, 5)', 'nf.formatRange' is undefined)"
1394+
strict mode: "TypeError: nf.formatRange is not a function. (In 'nf.formatRange(3, 5)', 'nf.formatRange' is undefined)"
1395+
test/intl402/NumberFormat/prototype/formatRange/invoked-as-func.js:
1396+
default: 'Test262Error: Expected SameValue(«undefined», «function») to be true'
1397+
strict mode: 'Test262Error: Expected SameValue(«undefined», «function») to be true'
13891398
test/intl402/NumberFormat/prototype/formatRange/length.js:
1390-
default: 'Test262Error: descriptor value should be 2'
1391-
strict mode: 'Test262Error: descriptor value should be 2'
1399+
default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
1400+
strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
1401+
test/intl402/NumberFormat/prototype/formatRange/name.js:
1402+
default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
1403+
strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
1404+
test/intl402/NumberFormat/prototype/formatRange/nan-arguments-throws.js:
1405+
default: 'Test262Error: Expected a RangeError but got a TypeError'
1406+
strict mode: 'Test262Error: Expected a RangeError but got a TypeError'
1407+
test/intl402/NumberFormat/prototype/formatRange/prop-desc.js:
1408+
default: 'Test262Error: `typeof Intl.NumberFormat.prototype.formatRange` is `function` Expected SameValue(«undefined», «function») to be true'
1409+
strict mode: 'Test262Error: `typeof Intl.NumberFormat.prototype.formatRange` is `function` Expected SameValue(«undefined», «function») to be true'
13921410
test/intl402/NumberFormat/prototype/formatRange/pt-PT.js:
1393-
default: 'Test262Error: Expected SameValue(«3 - 5 €», «3 - 5 €») to be true'
1394-
strict mode: 'Test262Error: Expected SameValue(«3 - 5 €», «3 - 5 €») to be true'
1411+
default: "TypeError: nf.formatRange is not a function. (In 'nf.formatRange(3, 5)', 'nf.formatRange' is undefined)"
1412+
strict mode: "TypeError: nf.formatRange is not a function. (In 'nf.formatRange(3, 5)', 'nf.formatRange' is undefined)"
1413+
test/intl402/NumberFormat/prototype/formatRange/x-greater-than-y-throws.js:
1414+
default: 'Test262Error: Expected a RangeError but got a TypeError'
1415+
strict mode: 'Test262Error: Expected a RangeError but got a TypeError'
13951416
test/intl402/NumberFormat/prototype/formatRangeToParts/builtin.js:
13961417
default: 'Test262Error: The [[Class]] internal property of a built-in function must be "Function". Expected SameValue(«[object Undefined]», «[object Function]») to be true'
13971418
strict mode: 'Test262Error: The [[Class]] internal property of a built-in function must be "Function". Expected SameValue(«[object Undefined]», «[object Function]») to be true'
@@ -1447,17 +1468,26 @@ test/intl402/NumberFormat/prototype/formatToParts/signDisplay-negative-zh-TW.js:
14471468
default: 'Test262Error: -0.0001 (negative): length Expected SameValue(«2», «1») to be true'
14481469
strict mode: 'Test262Error: -0.0001 (negative): length Expected SameValue(«2», «1») to be true'
14491470
test/intl402/PluralRules/prototype/selectRange/default-en-us.js:
1450-
default: 'Test262Error: Expected SameValue(«other», «few») to be true'
1451-
strict mode: 'Test262Error: Expected SameValue(«other», «few») to be true'
1471+
default: "TypeError: pr.selectRange is not a function. (In 'pr.selectRange(102, 201)', 'pr.selectRange' is undefined)"
1472+
strict mode: "TypeError: pr.selectRange is not a function. (In 'pr.selectRange(102, 201)', 'pr.selectRange' is undefined)"
1473+
test/intl402/PluralRules/prototype/selectRange/invoked-as-func.js:
1474+
default: 'Test262Error: Expected SameValue(«undefined», «function») to be true'
1475+
strict mode: 'Test262Error: Expected SameValue(«undefined», «function») to be true'
14521476
test/intl402/PluralRules/prototype/selectRange/length.js:
1453-
default: 'Test262Error: descriptor value should be 2'
1454-
strict mode: 'Test262Error: descriptor value should be 2'
1477+
default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
1478+
strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
1479+
test/intl402/PluralRules/prototype/selectRange/name.js:
1480+
default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
1481+
strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
14551482
test/intl402/PluralRules/prototype/selectRange/nan-arguments-throws.js:
1456-
default: 'Test262Error: NaN/Number Expected a RangeError to be thrown but no exception was thrown at all'
1457-
strict mode: 'Test262Error: NaN/Number Expected a RangeError to be thrown but no exception was thrown at all'
1458-
test/intl402/PluralRules/prototype/selectRange/undefined-arguments-throws.js:
1459-
default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
1460-
strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
1483+
default: 'Test262Error: NaN/Number Expected a RangeError but got a TypeError'
1484+
strict mode: 'Test262Error: NaN/Number Expected a RangeError but got a TypeError'
1485+
test/intl402/PluralRules/prototype/selectRange/prop-desc.js:
1486+
default: 'Test262Error: `typeof Intl.PluralRules.prototype.selectRange` is `function` Expected SameValue(«undefined», «function») to be true'
1487+
strict mode: 'Test262Error: `typeof Intl.PluralRules.prototype.selectRange` is `function` Expected SameValue(«undefined», «function») to be true'
1488+
test/intl402/PluralRules/prototype/selectRange/x-greater-than-y-throws.js:
1489+
default: 'Test262Error: Expected a RangeError but got a TypeError'
1490+
strict mode: 'Test262Error: Expected a RangeError but got a TypeError'
14611491
test/intl402/Temporal/PlainTime/prototype/toLocaleString/locales-undefined.js:
14621492
default: 'TypeError: Temporal.PlainTime.prototype.valueOf must not be called. To compare PlainTime values, use Temporal.PlainTime.compare'
14631493
strict mode: 'TypeError: Temporal.PlainTime.prototype.valueOf must not be called. To compare PlainTime values, use Temporal.PlainTime.compare'

Source/JavaScriptCore/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2022-01-03 Yusuke Suzuki <ysuzuki@apple.com>
2+
3+
[JSC] Fix length of Intl.NumberFormat.formatRange and Intl.PluralRules.selectRange
4+
https://bugs.webkit.org/show_bug.cgi?id=234806
5+
6+
Reviewed by Alexey Shvayka.
7+
8+
These length's numbers are wrong. This patch fixes them.
9+
10+
* runtime/IntlNumberFormatPrototype.cpp:
11+
(JSC::IntlNumberFormatPrototype::finishCreation):
12+
* runtime/IntlPluralRulesPrototype.cpp:
13+
(JSC::IntlPluralRulesPrototype::finishCreation):
14+
115
2022-01-02 Yusuke Suzuki <ysuzuki@apple.com>
216

317
[JSC] Use emitPutProperty / emitGetPropertyValue consistently to handle private names in edge cases

Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void IntlNumberFormatPrototype::finishCreation(VM& vm, JSGlobalObject* globalObj
8787
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
8888
UNUSED_PARAM(globalObject);
8989
#if HAVE(ICU_U_NUMBER_RANGE_FORMATTER)
90-
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("formatRange", intlNumberFormatPrototypeFuncFormatRange, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
90+
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("formatRange", intlNumberFormatPrototypeFuncFormatRange, static_cast<unsigned>(PropertyAttribute::DontEnum), 2);
9191
#endif
9292
#if HAVE(ICU_U_NUMBER_RANGE_FORMATTER_FORMAT_RANGE_TO_PARTS)
9393
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("formatRangeToParts", intlNumberFormatPrototypeFuncFormatRangeToParts, static_cast<unsigned>(PropertyAttribute::DontEnum), 2);

Source/JavaScriptCore/runtime/IntlPluralRulesPrototype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void IntlPluralRulesPrototype::finishCreation(VM& vm, JSGlobalObject* globalObje
7777
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
7878
UNUSED_PARAM(globalObject);
7979
#if HAVE(ICU_U_NUMBER_RANGE_FORMATTER)
80-
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->selectRange, intlPluralRulesPrototypeFuncSelectRange, static_cast<unsigned>(PropertyAttribute::DontEnum), 0);
80+
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->selectRange, intlPluralRulesPrototypeFuncSelectRange, static_cast<unsigned>(PropertyAttribute::DontEnum), 2);
8181
#endif
8282
}
8383

0 commit comments

Comments
 (0)