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

v1.0.0 Assert.equal(double, int literal) behave different from v0.13.3 #100

Open
mw66 opened this issue Nov 20, 2022 · 2 comments
Open

v1.0.0 Assert.equal(double, int literal) behave different from v0.13.3 #100

mw66 opened this issue Nov 20, 2022 · 2 comments

Comments

@mw66
Copy link

mw66 commented Nov 20, 2022

This assert used works in v0.13.3:

  Assert.equal(1003200.0, 1003200);

but in v1.0.0:

/.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/base.d(506): 1.0032e+06 should equal 1003200. 1.0032e+06 is not equal to 1003200.
Diff:
1[+.]0032[+e+]0[-0][+6]

 Expected:1003200
   Actual:1.0032e+06

need to change it to:

  Assert.equal(1003200.0, 1003200.0);

to make it pass in v1.0.0.

I'm wondering in such case, should the int 1003200 be cast to double (in the fluent-asserts library) can then compare?

@mw66
Copy link
Author

mw66 commented Nov 20, 2022

Same problem with (int, bool) literal pair, different behavior from v0.13.3:

Assert.equal(0, false);


/.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/base.d(506): 0 should equal false. 0 is not equal to false.
Diff:
[-false][+0]

 Expected:false
   Actual:0

can fluentasserts promote the bool to int internally? (and always promote the smaller type to the bigger type)?

@mw66
Copy link
Author

mw66 commented Nov 20, 2022

Find another related one, and is more serious: this assert failed in v1.0.0, but works fine in v0.13.3.

  double dn = 43.5001 / 4.35;
  Assert.greaterThan(dn, 10.0);  // 10.00002298850574712643


/.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/base.d(506): 10 should be greater than 10. 10 is less than or equal to 10.

 Expected:greater than 10
   Actual:10

Why in this case, the double should not be promoted to int, but somehow promoted (from the message, it's comparing the ints instead of doubles?)

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

No branches or pull requests

1 participant