v8/test/intl/locale/locale-info-ext.js
Frank Tang 0f0ead74b0 Implement proposal-intl-locale-info
Spec: https://tc39.es/proposal-intl-locale-info/
Design Doc: https://docs.google.com/document/d/1OwEsvs8VQwvR-ug01xLyIwpgcvUfaP24u9owc7aBKJ4/edit#
https://www.chromestatus.com/feature/5566859262820352

Behind flag --harmony_intl_locale_info

Bug: v8:11638

Change-Id: Ie616b3394d047c99d95ae46f112b5f0b367afe74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2570218
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74394}
2021-05-06 02:05:48 +00:00

27 lines
890 B
JavaScript

// Copyright 2021 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_locale_info
// Test Unicode extension.
function testExt(base, ukey, uvalue, property) {
let baseLocale = new Intl.Locale(base);
let extLocale = new Intl.Locale(base + "-u-" + ukey + "-" + uvalue);
let baseActual = baseLocale[property];
assertTrue(Array.isArray(baseActual));
assertTrue(baseActual.length > 0);
assertFalse(uvalue == baseActual[0]);
let extActual = extLocale[property];
assertTrue(Array.isArray(extActual));
assertEquals(1, extActual.length);
assertEquals(uvalue, extActual[0]);
}
testExt("ar", "ca", "roc", "calendars");
testExt("fr", "nu", "thai", "numberingSystems");
testExt("th", "co", "pinyin", "collations");
testExt("ko", "hc", "h11", "hourCycles");