Commit 47922400 authored by Brian Stell's avatar Brian Stell Committed by Commit Bot

[Intl] Add tests for duplicate subtag detection.

Also removed an obsolete test that is covered by test262/intl402

Bug: v8:7954, v8:5751

Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I41113653cd27c165e6f0a52e4b63bb9ddc553cba
Reviewed-on: https://chromium-review.googlesource.com/1150453
Commit-Queue: Jungshik Shin <jshin@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarJungshik Shin <jshin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54757}
parent 7f614962
......@@ -2,24 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var locales = ['en-US', 'fr'];
var result = Intl.getCanonicalLocales(locales);
var len = result.length
// Ignore the first tag when checking for duplicate subtags.
assertDoesNotThrow(() => Intl.getCanonicalLocales("foobar-foobar"));
// TODO(jshin): Remove the following when
// https://github.com/tc39/test262/issues/745 is resolved and
// test262 in v8 is updated.
// Ignore duplicate subtags in different namespaces; eg, 'a' vs 'u'.
assertDoesNotThrow(() => Intl.getCanonicalLocales("en-a-ca-Chinese-u-ca-Chinese"));
assertEquals(Object.getPrototypeOf(result), Array.prototype);
assertEquals(result.constructor, Array);
for (var key in result) {
var desc = Object.getOwnPropertyDescriptor(result, key);
assertTrue(desc.writable);
assertTrue(desc.configurable);
assertTrue(desc.enumerable);
}
var desc = Object.getOwnPropertyDescriptor(result, 'length');
assertTrue(desc.writable);
assertEquals(result.push('de'), desc.value + 1);
// Check duplicate subtags (after the first tag) are detected.
assertThrows(() => Intl.getCanonicalLocales("en-foobar-foobar"), RangeError);
assertThrows(() => Intl.getCanonicalLocales("en-u-ca-gregory-ca-chinese"), RangeError);
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