Skip to content

test(typia): cover boolean-literal discriminant in tagged unions#1876

Open
hexbinoct wants to merge 1 commit into
samchon:masterfrom
hexbinoct:test/reflect-schema-boolean-literal-union
Open

test(typia): cover boolean-literal discriminant in tagged unions#1876
hexbinoct wants to merge 1 commit into
samchon:masterfrom
hexbinoct:test/reflect-schema-boolean-literal-union

Conversation

@hexbinoct
Copy link
Copy Markdown

Summary

While looking into #1841 (a boolean-literal discriminant reportedly collapsing to a single value), I checked the current reflect.schema output and the metadata is correct — but our test suite doesn't actually pin that behavior. test_reflect_schema_constant only exercises a bare <true> literal; there is no coverage for <false> nor for a boolean-keyed discriminated union.

This adds that missing regression coverage so a future change can't silently collapse a union's false branch onto true (which would break discriminated-union narrowing) without a test going red.

What it checks

type U =
  | { ok: false; error: { code: string } }
  | { ok: true; code: string; data: { id: string } };

Test

  • New case test_reflect_schema_boolean_literal_union follows the existing reflect.schema suite shape (one case per file, TestValidator).
  • pnpm run build passes locally; the reflected output for the new case was verified to contain both branch values ([false, true]).

Refs #1841

Adds reflect.schema regression coverage for a boolean-literal discriminant
(`ok: false | true`) in a tagged union. The existing test_reflect_schema_constant
only exercises a bare `<true>` literal, so a regression that defaulted or
mis-compared the literal value could collapse a union's `false` branch onto
`true` (breaking discriminated-union narrowing) without any test going red.

The new case reflects a bare `<false>` literal and the discriminated union
from samchon#1841, then asserts both `false` and `true` survive across the union's
branch objects.

Refs samchon#1841
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant