Giter Site home page Giter Site logo

Comments (11)

pbacz avatar pbacz commented on July 4, 2024 2

@scordio @joel-costigliola
I created a PR for this issue.

from assertj.

scordio avatar scordio commented on July 4, 2024 1

Sure, go for it, @pbacz!

from assertj.

scordio avatar scordio commented on July 4, 2024 1

I propose to replace == check with equals() check and also state clearly in the javadoc which is used.

I tend to favor this solution, consistent with what the Javadoc already states and also in line with OptionalDouble::equals.

It's indeed a breaking change and the workaround to get the previous behavior would be something like:

assertThat(OptionalDouble.of(Double.NaN).getAsDouble()).isSameAs(Double.NaN);

@joel-costigliola do you agree?

from assertj.

Caceresenzo avatar Caceresenzo commented on July 4, 2024

In the meantime, that can be bypassed by testing the double value directly:

@Test
void testNaN() {
	assertThat(OptionalDouble.of(Double.NaN).getAsDouble()).isNaN();
}

from assertj.

scordio avatar scordio commented on July 4, 2024

Thanks for reporting it, @Caceresenzo!

from assertj.

pbacz avatar pbacz commented on July 4, 2024

@scordio Do you need someone to make a change for this?

from assertj.

pbacz avatar pbacz commented on July 4, 2024

@scordio
The simplest solution here would be to replace == comparison with equals() comparison.
This will have a side effect causing any test that compares 0.0 to -0.0 to fail (currently passing).

From the javadoc stating that assertThat(OptionalDouble.of(Double.NaN)).hasValue(Double.NaN) should pass I conclude that this was always the intent to compare using equals().

I propose to replace == check with equals() check and also state clearly in the javadoc which is used.

As this is potentially a breaking change for an edge case I'd like you to confirm if I should proceed with that.

from assertj.

Caceresenzo avatar Caceresenzo commented on July 4, 2024

A solution could be to add isNaN() to match AbstractDoubleAssert's API. (and add isNotNaN() too?)

This would prevent breaking changes.

EDIT: typos

from assertj.

pbacz avatar pbacz commented on July 4, 2024

@Caceresenzo @scordio
Sure, I can do it either way. All I need is a decision

from assertj.

Caceresenzo avatar Caceresenzo commented on July 4, 2024

I think having both isNaN() and isNotNaN() would be best as there do not seems to be a method for the opposite of hasValue(...).

Currently this passes:

assertThat(OptionalDouble.of(Double.NaN))
	.isNotEqualTo(Double.NaN);

(but I am sure its because its testing against the OptionalDouble and not the optional's value itself)

from assertj.

joel-costigliola avatar joel-costigliola commented on July 4, 2024

Integrated thanks @pbacz !

from assertj.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.