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

Inconsistent Tuple behavior. #893

Closed
constructor-igor opened this issue Oct 14, 2015 · 5 comments
Closed

Inconsistent Tuple behavior. #893

constructor-igor opened this issue Oct 14, 2015 · 5 comments

Comments

@constructor-igor
Copy link
Contributor

Next test fails (NUnit 2.6.4 and 3.0 Beta 4)

        [Test]
        public void TupleIntVsDouble()
        {
            Tuple<int, int> actual = Tuple.Create(1, 2);
            Tuple<double, double> expected = Tuple.Create(1.0, 2.0 );

            Assert.That(actual, Is.EqualTo(expected));
        }

with unclear message (R#):
image

VS adapter:
image

But "same" tests pass:

        [Test]
        public void IntVsDouble()
        {
            int actual = 1;
            double expected = 1.0;

            Assert.That(actual, Is.EqualTo(expected));
        }
        [Test]
        public void ListIntVsDouble()
        {
            List<int>actual = new List<int>{1, 2};
            List<double> expected = new List<double>{1.0, 2.0};

            Assert.That(actual, Is.EquivalentTo(expected));
        }
@rprouse
Copy link
Member

rprouse commented Oct 14, 2015

I've moved this out to 3.2 because comparing two Tuples of different types isn't valid C#. In other words, Assert.That(actual == expected) will not compile.

It highlights a sort of problem with NUnit in that we try to be much more lenient with equality so people expect the same amount of leniency with all types.

I think that Tuples are a valid extension of our leniency, but when we work on this issue, I would like to see us refactor NUnitEqualityComparer. It is becoming a monster of a class. I would prefer to see it as the central coordinator of a series of equality types that each handles specific equality conversions.

@CharliePoole
Copy link
Contributor

@rprouse Good approach. Let's do that for 3.2.

On Wed, Oct 14, 2015 at 6:47 AM, Rob Prouse notifications@github.com
wrote:

I've moved this out to 3.2 because comparing two Tuples of different types
isn't valid C#. In other words, Assert.That(actual == expected) will not
compile.

It highlights a sort of problem with NUnit in that we try to be much more
lenient with equality so people expect the same amount of leniency with all
types.

I think that Tuples are a valid extension of our leniency, but when we
work on this issue, I would like to see us refactor NUnitEqualityComparer.
It is becoming a monster of a class. I would prefer to see it as the
central coordinator of a series of equality types that each handles
specific equality conversions.


Reply to this email directly or view it on GitHub
#893 (comment).

@CharliePoole
Copy link
Contributor

I removed easyfix because refactoring NUnitEqualityComparer is not something I'd like a first-time contributor to try. Granted, @rprouse , it's easy for you or me... :-)

@CharliePoole CharliePoole modified the milestones: 3.0.1, 3.2 Nov 14, 2015
@CharliePoole CharliePoole modified the milestones: 3.2, Backlog Dec 5, 2015
@CharliePoole CharliePoole removed this from the Backlog milestone Jul 25, 2016
@jnm2
Copy link
Contributor

jnm2 commented Jul 2, 2017

@nunit/framework-team We just had the same discussion on the ValueTuple type now that C# has that type backing its tuple language feature. Would we be in agreement that the same purposes apply to Tuple? I was under the impression that Tuple plays a similar role in F#'s tuple language feature that ValueTuple now does in C#.

@mikkelbu Would you have any interest in this?
I'm thinking it's going to be almost identical to #2290. If not, we can put it up for grabs since the implementation spec would be #2290. 😄

@mikkelbu mikkelbu self-assigned this Jul 3, 2017
@mikkelbu
Copy link
Member

mikkelbu commented Jul 3, 2017

@jnm2 Sure. I can take a look at it.

@jnm2 jnm2 closed this as completed in #2415 Sep 4, 2017
@rprouse rprouse added this to the 3.9 milestone Nov 3, 2017
@rprouse rprouse changed the title Probably, Tuple has not consistent behavior. Inconsistent Tuple behavior. Nov 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants