Files
gitmost/packages/prosemirror-markdown/test/generative/env-int.test.ts
T
agent_coder 35f2c06f42 test(converter): #391 review round — orderedList start guard + nightly hardening (#351)
DO-1 (regression): the orderedList start hardening `Number(x)||1` let a
negative/fractional start through into the marker ("-3.", "2.5.") — marked
can't tokenize it, so the whole list re-imported as a paragraph (structure
corruption); start=0 churned. Both the markdown and raw-HTML export paths
now use `Number.isInteger(raw) && raw > 1 ? raw : 1`, so any degenerate
start collapses to the default "1." markers / bare <ol> (list always valid).
New ordered-list-start-normalization test pins {0,-3,2.5} → valid start=1
list, byte-stable; the round-trip fuzz keeps to integers >=2 (num 2,3,5,42).

DO-2 (nightly was non-functional): NUM_RUNS=5000 OOM'd the worker and the
crash was misreported as a "counterexample" issue whose prefix-dedup then
locked out all future issues. Reworked to shard 8 fresh vitest processes
(600 runs each, distinct seeds, --max-old-space-size) so deep fuzzing
never OOMs; a failing shard's output is preserved, and issue creation
discriminates a real fast-check counterexample from an infra/OOM failure
(distinct titles + scoped dedup). The two issue steps use `always() &&`
so they actually run on the failure path.

DO-3: envInt extracted to test/generative/env-int.ts + unit-tested.
DO-4: nightly dispatch inputs go through env: (no ${{ }} in run:).
DO-5: attr-arbitraries.ts docblock synced (column.width/orderedList.start
are fixed+fuzzed, not pinned it.fails).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 20:32:29 +03:00

30 lines
989 B
TypeScript

import { describe, expect, it } from 'vitest';
import { envInt } from './env-int.js';
// Unit coverage for the shared PROPERTY_SEED / PROPERTY_NUM_RUNS parser. The key
// contract is that an explicit "0" is honored (a valid fast-check seed) while
// empty/absent/non-numeric fall back to the default.
describe('envInt', () => {
it('honors an explicit "0" (does not fall back)', () => {
expect(envInt('0', 42)).toBe(0);
});
it('falls back on empty string', () => {
expect(envInt('', 42)).toBe(42);
});
it('falls back on undefined', () => {
expect(envInt(undefined, 42)).toBe(42);
});
it('falls back on a non-numeric string', () => {
expect(envInt('abc', 42)).toBe(42);
});
it('parses a plain integer string', () => {
expect(envInt('300', 42)).toBe(300);
});
it('parses a negative integer', () => {
expect(envInt('-5', 42)).toBe(-5);
});
it('parses a large integer', () => {
expect(envInt('1073741824', 42)).toBe(1073741824);
});
});