Skip to content

fix: a valid value cannot fail a pattern on a slow first match; null-argument contract tests - #43

Merged
vaceslav merged 2 commits into
mainfrom
test/null-arguments
Sep 28, 2026
Merged

vaceslav merged 2 commits into
mainfrom
test/null-arguments

Conversation

@vaceslav

Copy link
Copy Markdown
Contributor

Part of #16, items 3 and 4.

fix(mapping): a flaky test was a real defect. I ran the whole suite 30 times in a row, and FieldConstraintTests.APatternMustMatchTheWholeValue("DE", true) failed once. The pattern constraint gave every match a 100 ms clock. The first match in a process builds .NET's non-backtracking engine, and under load that took longer than the budget. .NET then did not throw RegexMatchTimeoutException: it returned false without a word, so a valid value failed its rule.

This reproduces in a fresh process with a 1 ms budget: the first IsMatch("DE") returns false and the second returns true. The non-backtracking engine is linear in the value and cannot run away, so it now gets no clock at all. Only the backtracking fallback, used for lookarounds and backreferences, keeps its 100 ms budget, because it can run away. JudgesAPatternTheLinearEngineRunsWithoutAClock failed before the change. docs/KNOWN-ISSUES.md is updated to match.

test: null arguments. Every public entry point that takes a non-nullable reference argument now has a test: 45 of them, run on both targets. Each passes null and expects an ArgumentException naming that exact parameter. No test pinned this contract before: removing ArgumentNullException.ThrowIfNull(stream) from CsvCursor left the whole suite green. Now it fails.

On mutation testing: Stryker.NET 5.0 does not work with this suite yet. Its Microsoft.Testing.Platform runner, still a preview, gets no answer to its run-tests call from the xunit v4 test server (Test run RPC call timed out). So it records every surviving mutant as a timeout, and the score reads 100 % whatever the tests do. Its VSTest runner made the first test run take 26 minutes, and its coverage capture failed. Neither gives results to act on, so no Stryker configuration is committed here.

@vaceslav
vaceslav merged commit 994cb1f into main Sep 28, 2026
9 checks passed
@vaceslav
vaceslav deleted the test/null-arguments branch September 28, 2026 04:41
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