2018-05-15 20:50:46 +00:00
|
|
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
// Locale constructor can't be called as function.
|
|
|
|
assertThrows(() => Intl.Locale('sr'), TypeError);
|
|
|
|
|
|
|
|
// Non-string locale.
|
|
|
|
assertThrows(() => new Intl.Locale(5), TypeError);
|
2018-08-08 14:35:07 +00:00
|
|
|
assertThrows(() => new Intl.Locale(Symbol()), TypeError);
|
|
|
|
assertThrows(() => new Intl.Locale(null), TypeError);
|
|
|
|
assertThrows(() => new Intl.Locale(undefined), TypeError);
|
|
|
|
assertThrows(() => new Intl.Locale(false), TypeError);
|
|
|
|
assertThrows(() => new Intl.Locale(true), TypeError);
|
2018-05-15 20:50:46 +00:00
|
|
|
|
2018-06-01 17:28:40 +00:00
|
|
|
// Invalid locale string.
|
|
|
|
assertThrows(() => new Intl.Locale('abcdefghi'), RangeError);
|
2018-05-15 20:50:46 +00:00
|
|
|
|
|
|
|
// Options will be force converted into Object.
|
|
|
|
assertDoesNotThrow(() => new Intl.Locale('sr', 5));
|
|
|
|
|
Reland "Roll ICU from 65.1 to 67.1 & correct tests"
The fix is in 630b884f84 not f2223961.
This reverts commit 464ee4b7ad358b8cb5fee672eeb8a74f016ca156.
Reason for revert: roll to 67.1 after the landing of the fix
Original change's description:
> Revert "Roll ICU from 65.1 to 67.1 (f2223961) & correct tests"
>
> This reverts commit e270b6d6154ef9280929e398a9d6fc337630916e.
>
> Reason for revert: V8 DEPS roll stuck https://crbug.com/v8/10567#c1
>
> Original change's description:
> > Roll ICU from 65.1 to 67.1 (f2223961) & correct tests
> >
> > Rolling to chrome/src is in
> > https://chromium-review.googlesource.com/c/chromium/src/+/2155530
> >
> > Since auto rolling stop after 3/24/2020 and the rolling will cause
> > change of test status, I get this cl ready (but not running trybot due
> > to 1074260) and plan to hand roll after the submission of 2155530.
> >
> > Bug: chromium:1064326, v8:9515, v8:10379, v8:10380, v8:10437
> > Change-Id: I19554f68cfdc5b717dfc7fc4b1222e9dc25b8d69
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2158486
> > Auto-Submit: Frank Tang <ftang@chromium.org>
> > Commit-Queue: Michael Achenbach <machenbach@chromium.org>
> > Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> > Reviewed-by: Michael Achenbach <machenbach@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#67493}
>
> TBR=jkummerow@chromium.org,machenbach@chromium.org,jshin@chromium.org,ftang@chromium.org,syg@chromium.org
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: chromium:1064326, v8:9515, v8:10379, v8:10380, v8:10437
> Change-Id: I3f4233815ed7414f2cde3d4d996696575b5f6e3a
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2219334
> Reviewed-by: Zhi An Ng <zhin@chromium.org>
> Reviewed-by: Michael Achenbach <machenbach@chromium.org>
> Commit-Queue: Zhi An Ng <zhin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#68051}
TBR=jkummerow@chromium.org,machenbach@chromium.org,jshin@chromium.org,zhin@chromium.org,ftang@chromium.org,syg@chromium.org
# Not skipping CQ checks because this is a reland.
Bug: chromium:1064326, v8:9515, v8:10379, v8:10380, v8:10437
Change-Id: I1de5eb36eff420482a12205682b153a2493d5249
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2220781
Reviewed-by: Frank Tang <ftang@chromium.org>
Reviewed-by: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68160}
2020-05-29 04:54:12 +00:00
|
|
|
// Regression for http://bugs.icu-project.org/trac/ticket/13417.
|
|
|
|
assertDoesNotThrow(
|
2018-05-15 20:50:46 +00:00
|
|
|
() => new Intl.Locale(
|
|
|
|
'sr-cyrl-rs-t-ja-u-ca-islamic-cu-rsd-tz-uslax-x-whatever', {
|
|
|
|
calendar: 'buddhist',
|
|
|
|
caseFirst: 'true',
|
|
|
|
collation: 'phonebk',
|
|
|
|
hourCycle: 'h23',
|
|
|
|
caseFirst: 'upper',
|
|
|
|
numeric: 'true',
|
|
|
|
numberingSystem: 'roman',
|
|
|
|
}),
|
2018-06-01 17:28:40 +00:00
|
|
|
RangeError);
|
|
|
|
|
|
|
|
// Throws only once during construction.
|
|
|
|
// Check for all getters to prevent regression.
|
|
|
|
assertThrows(
|
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get calendar() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
|
|
|
|
|
|
|
assertThrows(
|
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get caseFirst() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
|
|
|
|
|
|
|
assertThrows(
|
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get collation() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
|
|
|
|
|
|
|
assertThrows(
|
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get hourCycle() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
|
|
|
|
|
|
|
assertThrows(
|
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get numeric() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
|
|
|
|
|
|
|
assertThrows(
|
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get numberingSystem() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
|
|
|
|
2019-01-03 02:44:11 +00:00
|
|
|
assertThrows(
|
2018-06-01 17:28:40 +00:00
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get language() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
|
|
|
|
2019-01-03 02:44:11 +00:00
|
|
|
assertThrows(
|
2018-06-01 17:28:40 +00:00
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get script() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
|
|
|
|
2019-01-03 02:44:11 +00:00
|
|
|
assertThrows(
|
2018-06-01 17:28:40 +00:00
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get region() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
|
|
|
|
|
|
|
// There won't be an override for baseName so we don't expect it to throw.
|
|
|
|
assertDoesNotThrow(
|
|
|
|
() => new Intl.Locale('en-US', {
|
|
|
|
get baseName() {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Error);
|
2018-06-13 20:53:29 +00:00
|
|
|
|
|
|
|
// Preserve the order of getter initialization.
|
|
|
|
let getCount = 0;
|
|
|
|
let calendar = -1;
|
|
|
|
let collation = -1;
|
|
|
|
let hourCycle = -1;
|
|
|
|
let caseFirst = -1;
|
|
|
|
let numeric = -1;
|
|
|
|
let numberingSystem = -1;
|
|
|
|
|
|
|
|
|
|
|
|
new Intl.Locale('en-US', {
|
|
|
|
get calendar() {
|
|
|
|
calendar = ++getCount;
|
|
|
|
},
|
|
|
|
get collation() {
|
|
|
|
collation = ++getCount;
|
|
|
|
},
|
|
|
|
get hourCycle() {
|
|
|
|
hourCycle = ++getCount;
|
|
|
|
},
|
|
|
|
get caseFirst() {
|
|
|
|
caseFirst = ++getCount;
|
|
|
|
},
|
|
|
|
get numeric() {
|
|
|
|
numeric = ++getCount;
|
|
|
|
},
|
|
|
|
get numberingSystem() {
|
|
|
|
numberingSystem = ++getCount;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
assertEquals(1, calendar);
|
|
|
|
assertEquals(2, collation);
|
|
|
|
assertEquals(3, hourCycle);
|
|
|
|
assertEquals(4, caseFirst);
|
|
|
|
assertEquals(5, numeric);
|
|
|
|
assertEquals(6, numberingSystem);
|
|
|
|
|
|
|
|
// Check getter properties against the spec.
|
|
|
|
function checkProperties(property) {
|
|
|
|
let desc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, property);
|
|
|
|
assertEquals(`get ${property}`, desc.get.name);
|
|
|
|
assertEquals('function', typeof desc.get)
|
|
|
|
assertEquals(undefined, desc.set);
|
|
|
|
assertFalse(desc.enumerable);
|
|
|
|
assertTrue(desc.configurable);
|
|
|
|
}
|
|
|
|
|
|
|
|
checkProperties('language');
|
|
|
|
checkProperties('script');
|
|
|
|
checkProperties('region');
|
|
|
|
checkProperties('baseName');
|
|
|
|
checkProperties('calendar');
|
|
|
|
checkProperties('collation');
|
|
|
|
checkProperties('hourCycle');
|
|
|
|
checkProperties('caseFirst');
|
|
|
|
checkProperties('numeric');
|
|
|
|
checkProperties('numberingSystem');
|