Repository navigation
test: sibling parity sweeps (wrapper vs primitive set, range vs one-element RangeSet, literal entry points) - #143
Merged
Conversation
…ge and its one-element RangeSet, and the literal entry points Three differential sweeps in the conventions project, one [DynamicData] row per discovered type, that compare two sites which must agree instead of asserting a ground truth: - SetWrapperParityTests: each primitive value set against its wrapper arity closed over an identity element (Same<T>, SameText): every operation, ParseValue/FormatValue, Parse and TryParse (string and span), ToString, the TypeConverter, JSON token kinds and cross-reads. - RangeSetLiftParityTests: each range against the one-element RangeSet holding it, over the shape matrix (RangeSpecs, extracted from DomainParityOracleTests) plus the domain extremes. - LiteralEntryPointParityTests: one literal through Parse/TryParse (string and span), JSON, the TypeConverter and IConfiguration binding, for unions, variants, multiranges and sets. Generic code under an ISpanParsable-derived constraint binds TSet.Parse(string, ...) to the span overload, so the sweeps reach the string overloads through StringOverloads (#142 for the existing sweeps). Each sweep is registered in oracles.json with a seed it catches. The disagreements are candidates: #141 (wrapper JSON element reads wider than the primitive's) and #109 (IsUnboundedStart/End on (,) against its own multirange). Closes #139 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the csproj (both sides added the configuration packages) and merges the candidates and claims entries of both sides. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #139
Problem
The claim-driven oracles check each promise where a document makes it, so they find a bug at one site and miss it at the sibling site that makes the same promise without saying so. The changelog shows that pattern repeatedly:
IsAdjacentTo(6.2.1) →IsStrictlyLeftOf/Except(7.0.0) →RangeSet.Except(TRange)(8.0.0), the wrapper arities lagging their primitive set, and==/!=untested on 18 of 20 set types. Nothing compared the siblings with each other.Change
Three differential sweeps in
test/CodoMetis.ValueRanges.Conventions.Tests/, one[DynamicData]row per discovered type. None asserts a ground truth; when two siblings disagree, one of them is the bug.SetWrapperParityTestscompares each primitive set with its wrapper arity closed over an identity element (Same<T>,SameTextinIdentityWrappers.cs). Across the family's probes and extremes, it checks every operation,ParseValue/FormatValue,Parse/TryParse(string and span),ToStringwith each format and provider, theTypeConverter, JSON token kinds, each sibling reading the other's JSON, and a grid of array literals and JSON documents (quoted, padded, duplicated, out of order, empty,NULL, malformed). Each comparison wants the same value, or the same exception type.RangeSetLiftParityTestscompares each range with the one-elementRangeSetholding it. It covers every predicate (set-set and set-range overloads), every operation (named method and operator), and every accessor,Merge,Complement, the literal andContains(T), over the shape matrix plus bounds at the domain's minimum and maximum. That's about 378k checks per type.LiteralEntryPointParityTestssends one literal through every entry point:Parse/TryParse(string and span), JSON, theTypeConverterandIConfigurationbinding. It covers every range union and each sealed variant, every multirange (including its explicitIParsableimplementation) and every value set. The result must be an equal value, or a refusal everywhere.Supporting changes:
RangeSpecs.cs: the shape-matrix enumeration, embeddings and new domain extremes, moved out ofDomainParityOracleTests. That test's behaviour is unchanged, and its seed is still caught.StringOverloads.cs: under anIRangeFactory/IValueSetFactoryconstraint,TSet.Parse(string, …)binds to the span overload, becauseISpanParsablehidesIParsablein overload resolution. The sweeps call the string overloads through a helper constrained onIParsable<T>alone. The existing generic sweeps have the same blind spot, filed as Generic sweeps call the span overload when they mean Parse(string): ISpanParsable hides IParsable in overload resolution #142.Microsoft.Extensions.Configurationand.Binder10.0.12 added to the conventions project, for the binding entry point.oracles.json. Named in theheldByof J11, J13, J28, S09, M03 and M07. Described indocs/testing.md#the-sibling-parity-sweepsanddocs/oracles.md#sibling-parity.What they found
Int32Set<T>reads["7"],[" 7 "]and["+7"], andGuidSet<T>reads padded, braced and unhyphenated Guids.Int32SetandGuidSetrefuse all of these. Five candidate rows.IsUnboundedStart()/IsUnboundedEnd()on(,)give a different answer from the one-elementRangeSetholding it, on all 11 range types. 22 candidate rows; issue commented.Tests
Each sweep has a seed it is shown to catch:
wrapper-integer-elements-written-as-stringsSetWrapperParityTests(token kinds, cross-reads)multirange-upper-inc-reads-lower-boundRangeSetLiftParityTests(11 of 11 rows).DomainParityOracleTestsmisses itset-tryparse-reads-blank-as-emptyLiteralEntryPointParityTests,SetWrapperParityTests. Missed until the string overloads were called throughStringOverloadsdotnet test test/CodoMetis.ValueRanges.Conventions.Tests: 245 passed. The three sweeps take about 4 s altogether.dotnet run tools/oracles.cs seeds: every seed caught, 47 (seed, oracle) pairs, Docker-backed ones included.🤖 Generated with Claude Code