Changeset 287543 in webkit


Ignore:
Timestamp:
Jan 3, 2022 8:31:18 AM (7 months ago)
Author:
ysuzuki@apple.com
Message:

[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):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r287541 r287543  
     12022-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
    1122022-01-03  Yusuke Suzuki  <ysuzuki@apple.com>
    213
  • trunk/JSTests/stress/intl-numberformat-format-range-v3.js

    r286255 r287543  
    6464        let f = nf[method];
    6565        shouldThrow(() => { f(1, 23) }, TypeError);
     66        shouldBe(f.length, 2);
    6667
    6768        // Assert normal call success
  • trunk/JSTests/stress/intl-pluralrules-selectrange.js

    r285418 r287543  
    3333if (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}
  • trunk/JSTests/test262/expectations.yaml

    r287541 r287543  
    13871387  default: 'Test262Error: Expected SameValue(«1», «1.0000000000000001») to be true'
    13881388  strict mode: 'Test262Error: Expected SameValue(«1», «1.0000000000000001») to be true'
     1389test/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'
     1392test/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)"
     1395test/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'
    13891398test/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)')"
     1401test/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)')"
     1404test/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'
     1407test/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'
    13921410test/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)"
     1413test/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'
    13951416test/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'
     
    14481469  strict mode: 'Test262Error: -0.0001 (negative): length Expected SameValue(«2», «1») to be true'
    14491470test/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)"
     1473test/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'
    14521476test/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)')"
     1479test/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)')"
    14551482test/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'
     1485test/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'
     1488test/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'
    14611491test/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'
  • trunk/Source/JavaScriptCore/ChangeLog

    r287531 r287543  
     12022-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
    1152022-01-02  Yusuke Suzuki  <ysuzuki@apple.com>
    216
  • trunk/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp

    r286255 r287543  
    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)
  • trunk/Source/JavaScriptCore/runtime/IntlPluralRulesPrototype.cpp

    r285730 r287543  
    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}
Note: See TracChangeset for help on using the changeset viewer.