regress-11860.js 1.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// 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_best_fit_matcher
//
// Test the return list is subset of the request list.
// https://tc39.es/ecma402/#sec-bestfitsupportedlocales
//  9.2.9 BestFitSupportedLocales ( availableLocales, requestedLocales )
// The BestFitSupportedLocales abstract operation returns the SUBSET of the
// provided BCP 47 language priority list requestedLocales for which
// availableLocales has a matching locale when using the Best Fit Matcher
// algorithm. Locales appear in the same order in the returned list as in
// requestedLocales. The steps taken are implementation dependent.


function assertSubarray(a, b) {
  assertTrue(a.every(val => b.includes(val)), ['returns:', a, 'requested:', b]);
}

function verifySupportedLocalesAreSubarray(f, ll) {
  assertSubarray(f(ll), ll);
}

verifySupportedLocalesAreSubarray(Intl.DateTimeFormat.supportedLocalesOf, ['en', 'ceb']);
verifySupportedLocalesAreSubarray(Intl.DateTimeFormat.supportedLocalesOf, ['en', 'ceb', 'fil']);