diff --git a/src/primitive.test.ts b/src/primitive.test.ts index 6b1c9f8..3c445fe 100644 --- a/src/primitive.test.ts +++ b/src/primitive.test.ts @@ -326,6 +326,21 @@ test("getMatcherW factory rejects patterns outside its contract", () => { factory({ x: () => 1 as const }); }); +// ============================================================================ +// Dispatch — runtime behavior +// ============================================================================ + +test("getMatcher: an unhandled shape throws without a fallback", () => { + // Arrange — an open universe types its handler map as an index signature, + // so the type system cannot prove the runtime map is exhaustive. + const handlers: Record number> = { a: () => 1 }; + const matcher = getMatcher()(handlers); + + // Act / Assert + assert.equal(matcher("a"), 1); + assert.throws(() => matcher("b"), /Unhandled shape: b/); +}); + // ============================================================================ // Autocomplete — the language server is the oracle, not the type system // ============================================================================