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

Quelle  timer-delay.test.ts

  Sprache: JAVA
 

import { describe, expect, it, vi } from "vitest";
import {
  MAX_SAFE_TIMEOUT_DELAY_MS,
  resolveSafeTimeoutDelayMs,
  setSafeTimeout,
} from "./timer-delay.js";

describe("resolveSafeTimeoutDelayMs", () => {
  it("clamps to Node's signed-32-bit timer ceiling", () => {
    expect(resolveSafeTimeoutDelayMs(3_000_000_000)).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);
  });

  it("respects custom minimums", () => {
    expect(resolveSafeTimeoutDelayMs(10, { minMs: 250 })).toBe(250);
    expect(resolveSafeTimeoutDelayMs(10, { minMs: 0 })).toBe(10);
  });

  it("falls back to the minimum for non-finite input", () => {
    expect(resolveSafeTimeoutDelayMs(Number.POSITIVE_INFINITY, { minMs: 250 })).toBe(250);
    expect(resolveSafeTimeoutDelayMs(Number.NaN)).toBe(1);
  });
});

describe("setSafeTimeout", () => {
  it("arms setTimeout with the clamped delay", () => {
    const timeoutSpy = vi.spyOn(globalThis, "setTimeout");

    const timer = setSafeTimeout(() => undefined, 3_000_000_000);
    clearTimeout(timer);

    expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_SAFE_TIMEOUT_DELAY_MS);
    timeoutSpy.mockRestore();
  });
});

Messung V0.5 in Prozent
C=97 H=100 G=98

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-05-26) ¤

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