-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JSC] Add precise IntlMathematicalValue
https://bugs.webkit.org/show_bug.cgi?id=263705 rdar://problem/117535507 Reviewed by Justin Michaud. This patch implements precise IntlMathematicalValue aligning to the spec[1]. 1. We should keep string representation if the string value may not be exactly converted to double. And we should pass string directly to ICU when it happens. 2. We should appropriately handle 0x / 0o / 0b patterns. [1]: https://tc39.es/ecma402/#sec-tointlmathematicalvalue * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/IntlNumberFormat.cpp: (JSC::IntlMathematicalValue::parseString): * Source/JavaScriptCore/runtime/IntlNumberFormat.h: * Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h: (JSC::toIntlMathematicalValue): Canonical link: https://commits.webkit.org/269825@main
- Loading branch information
1 parent
d0d25eb
commit c724273
Showing
5 changed files
with
112 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function shouldBe(actual, expected) { | ||
if (actual !== expected) | ||
throw new Error('bad value: ' + actual); | ||
} | ||
|
||
var nf = new Intl.NumberFormat('en-US', {maximumFractionDigits: 20}); | ||
|
||
shouldBe(nf.format('0x100000'), '1,048,576'); | ||
shouldBe(nf.format('0o100000'), '32,768'); | ||
shouldBe(nf.format('0b100000'), '32'); | ||
shouldBe(nf.format('0X100000'), '1,048,576'); | ||
shouldBe(nf.format('0O100000'), '32,768'); | ||
shouldBe(nf.format('0B100000'), '32'); | ||
|
||
shouldBe(nf.format('0x10000z'), 'NaN'); | ||
shouldBe(nf.format('0o10000a'), 'NaN'); | ||
shouldBe(nf.format('0b100002'), 'NaN'); | ||
shouldBe(nf.format('0X10000z'), 'NaN'); | ||
shouldBe(nf.format('0O10000a'), 'NaN'); | ||
shouldBe(nf.format('0B100002'), 'NaN'); | ||
|
||
shouldBe(nf.format('0x1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), '1,013,065,324,433,836,171,511,818,326,096,474,890,383,898,005,918,563,696,288,002,277,756,507,034,036,354,527,929,615,978,746,851,512,277,392,062,160,962,106,733,983,191,180,520,452,956,027,069,051,297,354,415,786,421,338,721,071,661,056'); | ||
shouldBe(nf.format('0o1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), '5,678,427,533,559,428,832,416,592,249,125,035,424,637,823,130,369,672,345,949,142,181,098,744,438,385,921,275,985,867,583,701,277,855,943,457,200,048,954,515,105,739,075,223,552'); | ||
shouldBe(nf.format('0b1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), '178,405,961,588,244,985,132,285,746,181,186,892,047,843,328'); | ||
shouldBe(nf.format('0X1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), '1,013,065,324,433,836,171,511,818,326,096,474,890,383,898,005,918,563,696,288,002,277,756,507,034,036,354,527,929,615,978,746,851,512,277,392,062,160,962,106,733,983,191,180,520,452,956,027,069,051,297,354,415,786,421,338,721,071,661,056'); | ||
shouldBe(nf.format('0O1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), '5,678,427,533,559,428,832,416,592,249,125,035,424,637,823,130,369,672,345,949,142,181,098,744,438,385,921,275,985,867,583,701,277,855,943,457,200,048,954,515,105,739,075,223,552'); | ||
shouldBe(nf.format('0B1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), '178,405,961,588,244,985,132,285,746,181,186,892,047,843,328'); | ||
|
||
shouldBe(nf.format('-0'), '-0'); | ||
shouldBe(nf.format('+0'), '0'); | ||
shouldBe(nf.format('-Infinity'), '-∞'); | ||
shouldBe(nf.format('+Infinity'), '∞'); | ||
shouldBe(nf.format('Infinity'), '∞'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters