Skip to content

Commit

Permalink
changed order of parameters in assert.sameValue() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-allen committed Aug 28, 2023
1 parent 786f5e1 commit 0425c1c
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Google Inc. All rights reserved.
// Copyright 2019 Google Inc., 2023 Igalia S.L. All rights reserved.
// This code is governed by the license found in the LICENSE file.

/*---
Expand All @@ -24,23 +24,23 @@ info: |
locale: [en, fr, it, ja, zh, ko, ar, hi, en-u-hc-h24]
---*/

let locales = ["en", "fr", "it", "ja", "zh", "ko", "ar", "hi", "en-u-hc-h24"];
let locales = ["en", "fr", "it", "ja", "ja-u-hc-h11", "zh", "ko", "ar", "hi", "en-u-hc-h24"];

locales.forEach(function(locale){
let hcDefault = new Intl.DateTimeFormat(locale, {hour: "numeric"}).resolvedOptions().hourCycle;
if (hcDefault === "h11" || hcDefault === "h12"){
assert.sameValue(hcDefault, new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle);
assert.sameValue(new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle, hcDefault);

// no locale has "h24" as a default. see https://github.com/tc39/ecma402/pull/758#issue-1622377292
assert.sameValue("h23", new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle);
assert.sameValue(new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle, "h23");
}

// however, "h24" can be set via locale extension.
if (hcDefault === "h23" || hcDefault === "h24") {
assert.sameValue(hcDefault, new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle);
assert.sameValue(new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle, hcDefault);
}


let hcHour12 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle;
assert(hcHour12 === "h11" || hcHour12 === "h12", "Expected `hourCycle` to be in [\"h11\", \"h12\"]");
assert(hcHour12 === "h11" || hcHour12 === "h12", "Expected `hourCycle`: " + hcHour12 + " to be in [\"h11\", \"h12\"]");
});

0 comments on commit 0425c1c

Please sign in to comment.