Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Attempt on Generic Numerical EqualConstraint #4456

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

stevenaw
Copy link
Member

Moved the work from @manfred-brands into a shared branch in the nunit repo for collaboration
Contributes to #53

@stevenaw
Copy link
Member Author

There were two failures at the time I had to stop working on this yesterday, shown below.

The second error, where two ValueTuples which should be equal but aren't reporting as such, was failing when trying to use the default Equals() function here:

The first error, it appears an AssertionException should be thrown but isn't as it's going into the fallback comparer in that case.

Errors, Failures and Warnings

1) Failed : NUnit.Framework.Tests.Constraints.EqualConstraintTests.SameValueDifferentTypeExactMessageMatch
  Assert.That(ex?.Message, Does.Contain("  Expected: 0 (Int32)" + NL + "  But was:  0 (IntPtr)" + NL))
  Expected: String containing "  Expected: 0 (Int32)
  But was:  0 (IntPtr)
"
  But was:  "  Assert.That(new IntPtr(0), Is.EqualTo(0))
  Expected: 0
  But was:  0
"
   at NUnit.Framework.Tests.Constraints.EqualConstraintTests.SameValueDifferentTypeExactMessageMatch() in C:\Users\sweer\Documents\Development\OSS-stevenaw\nunit\src\NUnitFramework\tests\Constraints\EqualConstraintTests.cs:line 838

2) Failed : NUnit.Framework.Tests.Constraints.ValueTupleEqualityTests.ValueTupleElementsAreComparedUsingNUnitEqualityComparer
  Assert.That(a, Is.EqualTo(b))
  Expected: (<empty>)
  But was:  (<empty>)
   at NUnit.Framework.Tests.Constraints.ValueTupleEqualityTests.ValueTupleElementsAreComparedUsingNUnitEqualityComparer() in C:\Users\sweer\Documents\Development\OSS-stevenaw\nunit\src\NUnitFramework\tests\Constraints\ValueTupleEqualityTests.cs:line 74

@stevenaw
Copy link
Member Author

Update: I tried my hand at an IResolvableConstraint<T> and IConstraint<T> in order to support a signature like Assert.That(TActual, IResolvableConstraint<TActual>) so that we could get compile-time wiring to an overload when the expected and actual are the same type.

The implementation kept them distinct from the existing non-generic versions in order to avoid lots of internal rework but caused innumerable overload resolution conflicts for the compiler.

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.

None yet

2 participants