Skip to content

test: pin DateTimeKind and offsets through Shift, Expand and Split - #228

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
test/221-datetimekind-arithmetic
Oct 18, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
test/221-datetimekind-arithmetic

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #221

Problem

Nothing held that DateTimeRange.Shift, Expand and Split keep each bound's DateTimeKind. The pre-tag analysis (#179) seeded new DateTime(value.Add(delta).Ticks) into Shift, and every behavioural test passed. Only a clone-sweep waiver failed, and only because the source text changed. A tsrange holds no kind, so the kind lives only in memory. The EF Core write leg reads it (E09), so a bound that comes back Unspecified from a Utc one is a different instant on the way to the column, while every comparison in memory still agrees. The current code is right; this PR is tests only.

Change

  • RangeShiftExpandTests.DateTimeRange_ShiftExpandSplit_KeepEachBoundsKind, one row per kind. Each row gives the two bounds different kinds (Unspecified/Utc, Local/Unspecified, Utc/Local), so a rebuild that copies one bound's kind to both fails too. It checks:
    • Start.Kind and End.Kind through Shift(±1h) and Expand(±1h), and through UnboundedEnd.Shift and UnboundedStart.Expand
    • every Split piece: each starts with Start's kind, every piece but the last ends with it, and the last ends with End's kind
  • RangeShiftExpandTests.DateTimeOffsetRange_ShiftExpandSplit_KeepEachBoundsOffset does the same for each bound's offset. DateTimeOffset equality ignores the offset, so the test reads the offset off each bound instead of comparing values.
  • Claim R28 names the kind and the offset.

Tests

Proved by seeding, each in isolation on top of this branch:

Seed in DateTimeRange.cs Result
Shift: new DateTime(value.Add(delta).Ticks) (the issue's seed) fails: Shift: End.Kind
Expand: new DateTime(value.Subtract(amount).Ticks) fails: Expand: Start.Kind
Split: new DateTime(start.AddTicks(…).Ticks) fails: Split piece 0: End.Kind

dotnet test: core RangeShiftExpandTests 11/11 and conventions all green.

🤖 Generated with Claude Code

A tsrange holds no kind, so a DateTimeRange bound's DateTimeKind lives
only in memory, and the EF Core write leg reads it (E09). Nothing held
it through the 10.0.0 arithmetic: the pre-tag analysis seeded
new DateTime(value.Add(delta).Ticks) into Shift and only a clone-sweep
waiver noticed, because the source text changed.

RangeShiftExpandTests now holds each bound's kind through Shift,
Expand, the unbounded shapes and every Split piece, with the two bounds
of different kinds so a rebuild that copied one kind to both fails too,
and each bound's offset for DateTimeOffsetRange. Seeding the dropped
kind into Shift, into Expand and into Split each fails it.

Closes #221

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.0.0 milestone Oct 18, 2026
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (oracles, harnesses); no library code area/ranges Range unions, variants and the shape engines package/core Affects CodoMetis.ValueRanges labels Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit cc24233 into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the test/221-datetimekind-arithmetic branch October 18, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ranges Range unions, variants and the shape engines package/core Affects CodoMetis.ValueRanges tests Adds or changes tests only (oracles, harnesses); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nothing pins that DateTimeRange Shift, Expand and Split keep DateTimeKind

1 participant