Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/js/src/tests/non262/Intl/DisplayNames/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  weekday.js   Sprache: JAVA

 
// |reftest| skip-if(!this.hasOwnProperty('Intl')||!this.hasOwnProperty('addIntlExtras'))

addMozIntlDisplayNames(this);

const tests = {
  "en": {
    long: ["Monday""Tuesday""Wednesday""Thursday""Friday""Saturday""Sunday"],
    // short: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    short: ["Mo""Tu""We""Th""Fr""Sa""Su"],
    narrow: ["M""T""W""T""F""S""S"],
  },
  "de": {
    long: ["Montag""Dienstag""Mittwoch""Donnerstag""Freitag""Samstag""Sonntag"],
    // short: ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
    short: ["Mo.""Di.""Mi.""Do.""Fr.""Sa.""So."],
    narrow: ["M""D""M""D""F""S""S"],
  },
  "fr": {
    long: ["lundi""mardi""mercredi""jeudi""vendredi""samedi""dimanche"],
    // short: ["lun.", "mar.", "mer.", "jeu.", "ven.", "sam.", "dim."],
    short: ["lu""ma""me""je""ve""sa""di"],
    narrow: ["L""M""M""J""V""S""D"],
  },
  "zh": {
    long: ["星期一""星期二""星期三""星期四""星期五""星期六""星期日"],
    short: ["周一""周二""周三""周四""周五""周六""周日"],
    narrow: ["一""二""三""四""五""六""日"],
  },
};

for (let [locale, localeTests] of Object.entries(tests)) {
  let defaultCalendar = new Intl.DateTimeFormat(locale).resolvedOptions().calendar;

  for (let [style, styleTests] of Object.entries(localeTests)) {
    let dn = new Intl.DisplayNames(locale, {type: "weekday", style});

    let resolved = dn.resolvedOptions();
    assertEq(resolved.locale, locale);
    assertEq(resolved.calendar, defaultCalendar);
    assertEq(resolved.style, style);
    assertEq(resolved.type, "weekday");
    assertEq(resolved.fallback, "code");

    for (let i = 0; i < 7; i++) {
      assertEq(dn.of(i + 1), styleTests[i]);

      // Also works with strings.
      assertEq(dn.of(String(i + 1)), styleTests[i]);

      // Also works with objects.
      assertEq(dn.of(Object(i + 1)), styleTests[i]);
    }
  }
}

{
  let dn = new Intl.DisplayNames("en", {type: "weekday"});

  // Performs ToString on the input and then validates the stringified result.
  assertThrowsInstanceOf(() => dn.of(), RangeError);
  assertThrowsInstanceOf(() => dn.of(null), RangeError);
  assertThrowsInstanceOf(() => dn.of(Symbol()), TypeError);

  // Throws an error if |code| isn't an integer.
  assertThrowsInstanceOf(() => dn.of(1.5), RangeError);
  assertThrowsInstanceOf(() => dn.of(-Infinity), RangeError);
  assertThrowsInstanceOf(() => dn.of(Infinity), RangeError);
  assertThrowsInstanceOf(() => dn.of(NaN), RangeError);

  // Throws an error if outside of [1, 7].
  assertThrowsInstanceOf(() => dn.of(-1), RangeError);
  assertThrowsInstanceOf(() => dn.of(0), RangeError);
  assertThrowsInstanceOf(() => dn.of(8), RangeError);
}

if (typeof reportCompare === "function")
  reportCompare(truetrue);

Messung V0.5
C=93 H=91 G=91

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.