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

[Merged by Bors] - Fix PartialEq for JsBigInt and f64 #2461

Closed
wants to merge 2 commits into from

Conversation

raskad
Copy link
Member

@raskad raskad commented Nov 25, 2022

This Pull Request changes the following:

  • Use the BigInt::from_f64 function when checking JsBigInt and f64 for eqality.

@raskad raskad added the execution Issues or PRs related to code execution label Nov 25, 2022
@raskad raskad added this to the v0.17.0 milestone Nov 25, 2022
@raskad raskad added the bug Something isn't working label Nov 25, 2022
@github-actions
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 93,831 93,831 0
Passed 69,636 69,640 +4
Ignored 18,472 18,472 0
Failed 5,723 5,719 -4
Panics 0 0 0
Conformance 74.21% 74.22% +0.00%
Fixed tests (4):
test/language/expressions/equals/bigint-and-number-extremes.js [strict mode] (previously Failed)
test/language/expressions/equals/bigint-and-number-extremes.js (previously Failed)
test/language/expressions/does-not-equals/bigint-and-number-extremes.js [strict mode] (previously Failed)
test/language/expressions/does-not-equals/bigint-and-number-extremes.js (previously Failed)

@codecov
Copy link

codecov bot commented Nov 25, 2022

Codecov Report

Merging #2461 (6a15a13) into main (8c88281) will decrease coverage by 0.44%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2461      +/-   ##
==========================================
- Coverage   51.51%   51.07%   -0.45%     
==========================================
  Files         339      344       +5     
  Lines       35515    35825     +310     
==========================================
- Hits        18297    18296       -1     
- Misses      17218    17529     +311     
Impacted Files Coverage Δ
boa_engine/src/bigint.rs 68.38% <100.00%> (+0.26%) ⬆️
boa_engine/src/value/hash.rs 64.70% <0.00%> (-5.89%) ⬇️
boa_engine/src/object/mod.rs 46.17% <0.00%> (-0.11%) ⬇️
boa_cli/src/helper.rs 0.00% <0.00%> (ø)
boa_wasm/src/lib.rs
boa_examples/src/bin/jstypedarray.rs 0.00% <0.00%> (ø)
boa_examples/src/bin/jsarray.rs 0.00% <0.00%> (ø)
boa_examples/src/bin/closures.rs 0.00% <0.00%> (ø)
boa_examples/src/bin/jsset.rs 0.00% <0.00%> (ø)
boa_examples/src/bin/loadstring.rs 0.00% <0.00%> (ø)
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! It turns out the operation doesn't need an if/else. Check the comments :)

@@ -453,21 +453,21 @@ impl PartialEq<JsBigInt> for i32 {
impl PartialEq<f64> for JsBigInt {
#[inline]
fn eq(&self, other: &f64) -> bool {
if other.fract() != 0.0 {
return false;
if other.fract().is_zero() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could just be an && operation, right? Instead of an if/else

}
}

impl PartialEq<JsBigInt> for f64 {
#[inline]
fn eq(&self, other: &JsBigInt) -> bool {
if self.fract() != 0.0 {
return false;
if self.fract().is_zero() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, it could just be an && operation.

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect now, thanks!

@HalidOdat
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Nov 25, 2022
This Pull Request changes the following:

- Use the `BigInt::from_f64` function when checking `JsBigInt` and `f64` for eqality.
@bors
Copy link

bors bot commented Nov 25, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Fix PartialEq for JsBigInt and f64 [Merged by Bors] - Fix PartialEq for JsBigInt and f64 Nov 25, 2022
@bors bors bot closed this Nov 25, 2022
@bors bors bot deleted the bigint-f64-eq branch November 25, 2022 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants