Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openclaw/src/cli/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 1 kB image not shown  

Quelle  parse-timeout.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { describe, expect, it } from "vitest";
import { parseTimeoutMs, parseTimeoutMsWithFallback } from "./parse-timeout.js";

describe("parseTimeoutMs", () => {
  it("parses positive string values", () => {
    expect(parseTimeoutMs("1500")).toBe(1500);
  });

  it("returns undefined for empty or invalid values", () => {
    expect(parseTimeoutMs(undefined)).toBeUndefined();
    expect(parseTimeoutMs("")).toBeUndefined();
    expect(parseTimeoutMs("nope")).toBeUndefined();
  });
});

describe("parseTimeoutMsWithFallback", () => {
  it("returns the fallback for missing or empty values", () => {
    expect(parseTimeoutMsWithFallback(undefined, 3000)).toBe(3000);
    expect(parseTimeoutMsWithFallback(null, 3000)).toBe(3000);
    expect(parseTimeoutMsWithFallback("  ", 3000)).toBe(3000);
  });

  it("parses positive numbers and strings", () => {
    expect(parseTimeoutMsWithFallback(2500, 3000)).toBe(2500);
    expect(parseTimeoutMsWithFallback(2500n, 3000)).toBe(2500);
    expect(parseTimeoutMsWithFallback("2500", 3000)).toBe(2500);
  });

  it("falls back on unsupported types by default", () => {
    expect(parseTimeoutMsWithFallback({}, 3000)).toBe(3000);
  });

  it("throws on unsupported types when requested", () => {
    expect(() => parseTimeoutMsWithFallback({}, 3000, { invalidType: "error" })).toThrow(
      "invalid --timeout",
    );
  });

  it("throws on non-positive parsed values", () => {
    expect(() => parseTimeoutMsWithFallback("0", 3000)).toThrow("invalid --timeout: 0");
    expect(() => parseTimeoutMsWithFallback("-1", 3000)).toThrow("invalid --timeout: -1");
  });
});

¤ Dauer der Verarbeitung: 0.8 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© 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.