Commit 04446360 authored by Nebojsa Ciric's avatar Nebojsa Ciric Committed by Commit Bot

Add regression tests for Intl.Locale constructor.

- Test that order of getter initialization doesn't change.
- Test properties of each getter against the spec.

Bug: v8:7684
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I85d0d80947e55233f10f62f96fe33d4281db4315
Reviewed-on: https://chromium-review.googlesource.com/1083879
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53721}
parent ab2538d8
......@@ -115,3 +115,62 @@ assertDoesNotThrow(
}
}),
Error);
// 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');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment