-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: fix i18n-test bugs in Node 13 #10595
Conversation
R: @paulirish since he was also looking at these failures |
// user-facing strings and it will eventually correct itself. | ||
const formattedNaNStr = i18n.getFormatted(helloNaNStr, 'en-US'); | ||
expect(formattedNaNStr === 'Hello NaN World' || formattedNaNStr === 'Hello -NaN World') | ||
.toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
originally I had this as a conditional
if (({a: NaN}).a.toLocaleString() === '-NaN') {
expect(helloNaNStr).toBeDisplayString('Hello -NaN World');
} else {
expect(helloNaNStr).toBeDisplayString('Hello NaN World');
}
but the conditional was always going to the else
clause and then failing on the Hello NaN World
assertion, so I gave up on figuring that out :) I assume some codegen thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Linguist experts in CLDR require two digits before the group separator for Spanish"
i love this. ahahaah
@@ -11,27 +11,27 @@ const lhr = require('../../results/sample_v2.json'); | |||
|
|||
/* eslint-env jest */ | |||
describe('swap-locale', () => { | |||
it('can change golden LHR english strings into spanish', () => { | |||
it('can change golden LHR english strings into german', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-Authored-By: Paul Irish <paulirish@google.com>
helps check off some of #10582
Two test issues here:
Node 13 has a
Intl.NumberFormat
bug where aNaN
that was stored in a property on an object will be formatted as-NaN
, e.g.({a: NaN}).a.toLocaleString() === '-NaN'
. This also happens in V8 7.9/8.0 (~Chrome 79 and 80) but works correctly before and after these versions.Formatting
NaN
s isn't exactly important to our report, we added the test to exercise the corner cases and make sure they wouldn't cause a crash, so this PR adds a narrow workaround to the test that can be removed later. Try not to putNaN
s in the report or they'll be negative for Node 13 users :)The thousands separator for Spanish was removed starting in Node 13, causing the swap-locale formatted-number test to fail. Looking for NaN bugs I ran across this crbug, where it turns out that "Linguist experts in CLDR require two digits before the group separator for Spanish" (so a number has to be ≥ 10000 before getting a separator) which was fixed in V8 by an ICU update at some point.
Unfortunately we don't have any 5+ digit formatted number in
sample_v2.json
to get the separator back, so this just switches the test to swap the locale tode
, which does have 1 as itsminimumGroupingDigits
.