[Intl] Add order check test for Intl.*
Also split out some order check tests. Bug: v8:5751 Change-Id: I1765d1809b456c43e21d9a379f720a0ea12e794e Reviewed-on: https://chromium-review.googlesource.com/c/1352283 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/master@{#57988}
This commit is contained in:
parent
98493b9414
commit
62915f403e
30
test/intl/collator/constructor-order.js
Normal file
30
test/intl/collator/constructor-order.js
Normal file
@ -0,0 +1,30 @@
|
||||
// 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.
|
||||
|
||||
// Throws only once during construction.
|
||||
// Check for all getters to prevent regression.
|
||||
// Preserve the order of getter initialization.
|
||||
let getCount = 0;
|
||||
|
||||
new Intl.Collator(['en-US'], {
|
||||
get usage() {
|
||||
assertEquals(0, getCount++);
|
||||
},
|
||||
get localeMatcher() {
|
||||
assertEquals(1, getCount++);
|
||||
},
|
||||
get numeric() {
|
||||
assertEquals(2, getCount++);
|
||||
},
|
||||
get caseFirst() {
|
||||
assertEquals(3, getCount++);
|
||||
},
|
||||
get sensitivity() {
|
||||
assertEquals(4, getCount++);
|
||||
},
|
||||
get ignorePunctuation() {
|
||||
assertEquals(5, getCount++);
|
||||
},
|
||||
});
|
||||
assertEquals(6, getCount);
|
21
test/intl/list-format/constructor-order.js
Normal file
21
test/intl/list-format/constructor-order.js
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.
|
||||
|
||||
// Throws only once during construction.
|
||||
// Check for all getters to prevent regression.
|
||||
// Preserve the order of getter initialization.
|
||||
let getCount = 0;
|
||||
|
||||
new Intl.ListFormat(['en-US'], {
|
||||
get type() {
|
||||
assertEquals(0, getCount++);
|
||||
},
|
||||
get style() {
|
||||
assertEquals(1, getCount++);
|
||||
},
|
||||
get localeMatcher() {
|
||||
assertEquals(2, getCount++);
|
||||
},
|
||||
});
|
||||
assertEquals(3, getCount);
|
@ -88,22 +88,3 @@ assertDoesNotThrow(
|
||||
|
||||
assertDoesNotThrow(
|
||||
() => new Intl.ListFormat(['sr'], {type: 'unit', style: 'narrow'}));
|
||||
|
||||
// Throws only once during construction.
|
||||
// Check for all getters to prevent regression.
|
||||
// Preserve the order of getter initialization.
|
||||
let getCount = 0;
|
||||
let style = -1;
|
||||
let type = -1;
|
||||
|
||||
new Intl.ListFormat(['en-US'], {
|
||||
get style() {
|
||||
style = ++getCount;
|
||||
},
|
||||
get type() {
|
||||
type = ++getCount;
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(1, type);
|
||||
assertEquals(2, style);
|
||||
|
42
test/intl/number-format/constructor-order.js
Normal file
42
test/intl/number-format/constructor-order.js
Normal file
@ -0,0 +1,42 @@
|
||||
// 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.
|
||||
|
||||
// Throws only once during construction.
|
||||
// Check for all getters to prevent regression.
|
||||
// Preserve the order of getter initialization.
|
||||
let getCount = 0;
|
||||
|
||||
new Intl.NumberFormat(['en-US'], {
|
||||
get localeMatcher() {
|
||||
assertEquals(0, getCount++);
|
||||
},
|
||||
get style() {
|
||||
assertEquals(1, getCount++);
|
||||
},
|
||||
get currency() {
|
||||
assertEquals(2, getCount++);
|
||||
},
|
||||
get currencyDisplay() {
|
||||
assertEquals(3, getCount++);
|
||||
},
|
||||
get minimumIntegerDigits() {
|
||||
assertEquals(4, getCount++);
|
||||
},
|
||||
get minimumFractionDigits() {
|
||||
assertEquals(5, getCount++);
|
||||
},
|
||||
get maximumFractionDigits() {
|
||||
assertEquals(6, getCount++);
|
||||
},
|
||||
get minimumSignificantDigits() {
|
||||
assertEquals(7, getCount++);
|
||||
},
|
||||
get maximumSignificantDigits() {
|
||||
assertEquals(8, getCount++);
|
||||
},
|
||||
get useGrouping() {
|
||||
assertEquals(9, getCount++);
|
||||
},
|
||||
});
|
||||
assertEquals(10, getCount);
|
33
test/intl/plural-rules/constructor-order.js
Normal file
33
test/intl/plural-rules/constructor-order.js
Normal file
@ -0,0 +1,33 @@
|
||||
// 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.
|
||||
|
||||
// Throws only once during construction.
|
||||
// Check for all getters to prevent regression.
|
||||
// Preserve the order of getter initialization.
|
||||
let getCount = 0;
|
||||
|
||||
new Intl.PluralRules(['en-US'], {
|
||||
get localeMatcher() {
|
||||
assertEquals(0, getCount++);
|
||||
},
|
||||
get type() {
|
||||
assertEquals(1, getCount++);
|
||||
},
|
||||
get minimumIntegerDigits() {
|
||||
assertEquals(2, getCount++);
|
||||
},
|
||||
get minimumFractionDigits() {
|
||||
assertEquals(3, getCount++);
|
||||
},
|
||||
get maximumFractionDigits() {
|
||||
assertEquals(4, getCount++);
|
||||
},
|
||||
get minimumSignificantDigits() {
|
||||
assertEquals(5, getCount++);
|
||||
},
|
||||
get maximumSignificantDigits() {
|
||||
assertEquals(6, getCount++);
|
||||
},
|
||||
});
|
||||
assertEquals(7, getCount);
|
21
test/intl/relative-time-format/constructor-order.js
Normal file
21
test/intl/relative-time-format/constructor-order.js
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.
|
||||
|
||||
// Throws only once during construction.
|
||||
// Check for all getters to prevent regression.
|
||||
// Preserve the order of getter initialization.
|
||||
let getCount = 0;
|
||||
|
||||
new Intl.RelativeTimeFormat(['en-US'], {
|
||||
get localeMatcher() {
|
||||
assertEquals(0, getCount++);
|
||||
},
|
||||
get style() {
|
||||
assertEquals(1, getCount++);
|
||||
},
|
||||
get numeric() {
|
||||
assertEquals(2, getCount++);
|
||||
},
|
||||
});
|
||||
assertEquals(3, getCount);
|
@ -77,27 +77,3 @@ assertDoesNotThrow(
|
||||
assertThrows(
|
||||
() => new Intl.RelativeTimeFormat('sr', {numeric: 'never'}),
|
||||
RangeError);
|
||||
|
||||
// Throws only once during construction.
|
||||
// Check for all getters to prevent regression.
|
||||
// Preserve the order of getter initialization.
|
||||
let getCount = 0;
|
||||
let localeMatcher = -1;
|
||||
let style = -1;
|
||||
let numeric = -1;
|
||||
|
||||
new Intl.RelativeTimeFormat('en-US', {
|
||||
get localeMatcher() {
|
||||
localeMatcher = ++getCount;
|
||||
},
|
||||
get style() {
|
||||
style = ++getCount;
|
||||
},
|
||||
get numeric() {
|
||||
numeric = ++getCount;
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(1, localeMatcher);
|
||||
assertEquals(2, style);
|
||||
assertEquals(3, numeric);
|
||||
|
23
test/intl/segmenter/constructor-order.js
Normal file
23
test/intl/segmenter/constructor-order.js
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --harmony-intl-segmenter
|
||||
|
||||
// Throws only once during construction.
|
||||
// Check for all getters to prevent regression.
|
||||
// Preserve the order of getter initialization.
|
||||
let getCount = 0;
|
||||
|
||||
new Intl.Segmenter(['en-US'], {
|
||||
get localeMatcher() {
|
||||
assertEquals(0, getCount++);
|
||||
},
|
||||
get lineBreakStyle() {
|
||||
assertEquals(1, getCount++);
|
||||
},
|
||||
get granularity() {
|
||||
assertEquals(2, getCount++);
|
||||
},
|
||||
});
|
||||
assertEquals(3, getCount);
|
@ -190,27 +190,3 @@ assertThrows(
|
||||
}),
|
||||
TypeError
|
||||
);
|
||||
|
||||
// Throws only once during construction.
|
||||
// Check for all getters to prevent regression.
|
||||
// Preserve the order of getter initialization.
|
||||
let getCount = 0;
|
||||
let localeMatcher = -1;
|
||||
let lineBreakStyle = -1;
|
||||
let granularity = -1;
|
||||
|
||||
new Intl.Segmenter(["en-US"], {
|
||||
get localeMatcher() {
|
||||
localeMatcher = ++getCount;
|
||||
},
|
||||
get lineBreakStyle() {
|
||||
lineBreakStyle = ++getCount;
|
||||
},
|
||||
get granularity() {
|
||||
granularity = ++getCount;
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(1, localeMatcher);
|
||||
assertEquals(2, lineBreakStyle);
|
||||
assertEquals(3, granularity);
|
||||
|
Loading…
Reference in New Issue
Block a user