-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We should not crash when passed a bigint. This patch will make it so that the formatter will convert the bigint to a number if possible, else it will emit an overflow string (#####). A setting has been added so that instead of the overflow string, a string version of the bigint is emitted instead. This is similar how date overflows are handled. I have made an attempt at supporting bigint throughout the library with some success, but I have abandoned that because it was complicating the code a lot and I had some worries about performance. I think partial support would be possible with low cost. But I don't have the resources to spare for that right now. Closes #61
- Loading branch information
Showing
7 changed files
with
58 additions
and
7 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
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
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,30 @@ | ||
import test from './utils.js'; | ||
|
||
test('bigint', t => { | ||
t.format('0', Number.MAX_SAFE_INTEGER, String(Number.MAX_SAFE_INTEGER)); | ||
t.format('0', 10n, '10'); | ||
|
||
t.format('General', 10n, '10'); | ||
t.format('General', 9007199254740991n, '9.0072E+15'); | ||
|
||
t.format('0.0', 9007199254740991n, '9007199254740990.0'); | ||
|
||
t.format('#,##0.0', 9007199254740991n, '9,007,199,254,740,990.0'); | ||
t.format('#,##0.0', 9007199254750000n, '######'); | ||
t.format('#,##0.0', -9007199254750000n, '######'); | ||
|
||
t.format('#0-000-00', 9007199254750000n, '######'); | ||
t.format('0%', 9007199254750000n, '######'); | ||
|
||
t.format('#0-000-00', 9007199254750000n, '9007199254750000', { bigintErrorNumber: true }); | ||
t.format('0%', 9007199254750000n, '9007199254750000', { bigintErrorNumber: true }); | ||
|
||
// preferably we should support bigint throughout: | ||
// t.format('#0-000-00', 9007199254750000n, '90071992547-500-00'); | ||
// t.format('0%', 9007199254750000n, '900719925475000000%'); | ||
|
||
t.format('0.000E+00', 999990000, '1.000E+09'); | ||
t.format('0.000E+00', 999990000n, '1.000E+09'); | ||
|
||
t.end(); | ||
}); |
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