Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/tests/non262/Intl/DurationFormat/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  basic-zero.js

  Sprache: JAVA
 

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

// Test formatting zero amount for a single unit and compare "auto" against
// "always" for the display option.

const {
  Integer, Literal, Unit
} = NumberFormatParts;

function ToDurationFormatPart(unit) {
  unit = unit.slice(0, -1);
  unit = unit[0].toUpperCase() + unit.slice(1);
  return DurationFormatParts[unit];
}

const tests = {
  "en": Object.fromEntries(units.map(unit => [unit, unit])),
  "de": {
    "years""Jahre",
    "months""Monate",
    "weeks""Wochen",
    "days""Tage",
    "hours""Stunden",
    "minutes""Minuten",
    "seconds""Sekunden",
    "milliseconds""Millisekunden",
    "microseconds""Mikrosekunden",
    "nanoseconds""Nanosekunden",
  },
};

for (let [locale, data] of Object.entries(tests)) {
  for (let unit of units) {
    let auto = new Intl.DurationFormat(locale, {
      style: "long",
      [unit + "Display"]: "auto",
    });
    let always = new Intl.DurationFormat(locale, {
      style: "long",
      [unit + "Display"]: "always",
    });

    let duration = {[unit]: 0};
    let expected = `0 ${data[unit]}`;

    // Empty string.
    assertEq(auto.format(duration), "", `auto: ${unit}`);

    // Empty array.
    assertEq(auto.formatToParts(duration).length, 0, `auto: ${unit}`);

    assertEq(always.format(duration), expected, `always: ${unit}`);

    let parts = always.formatToParts(duration);
    assertEq(PartsToString(parts), expected, `always: ${unit}`);

    assertDeepEq(parts, [
      ...ToDurationFormatPart(unit)(Integer("0"), Literal(" "), Unit(data[unit])),
    ]);
  }
}

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

Messung V0.5 in Prozent
C=93 H=93 G=92

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-07) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.