Project

General

Profile

Bug #15432

Float の NaN のみを含む配列比較のテスト

Added by shuujii (Shuji KOBAYASHI) 10 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0rc2 (2018-12-15 trunk 66408) [x86_64-linux]
[ruby-dev:50715]

Description

Float の NaN のみを含む配列比較のテストが以下にあります。

## spec/ruby/core/array/equal_value_spec.rb:47

# As per bug #1720
it "returns false for [NaN] == [NaN]" do
  [nan_value].should_not == [nan_value]
end

しかし、これは #1720 で未定義動作とするとなったと思うので不要ではないでしょうか。

現状では以下のようになるので意味のないテストだと思います。

[Float::NAN] == [Float::NAN]  #=> true
[Float::NAN] == [0/0.0]       #=> false

Associated revisions

Revision a0af60c7
Added by jeremyevans (Jeremy Evans) 4 months ago

Remove spec testing undefined behavior

Fixes [Bug #15432]

History

Updated by jeremyevans0 (Jeremy Evans) 4 months ago

I agree that keeping this spec does not make sense. If nobody objects within the next week, I will delete the spec.

#2

Updated by jeremyevans (Jeremy Evans) 4 months ago

  • Status changed from Open to Closed

Applied in changeset git|a0af60c7f2d852faa6d3263874224dd7950bda43.


Remove spec testing undefined behavior

Fixes [Bug #15432]

Updated by Eregon (Benoit Daloze) 4 months ago

It makes sense in the context of #1720.

I.e., all Ruby implementations behave that way, because Float::NAN.equal? Float::NAN must be true, and Array#== uses an #equal? + a #== check, not just #==. I want to restore the spec and add that explanation.

IMHO there is no "undefined behavior" in Ruby, there is MRI behavior and that's what other Ruby implementations have to comply to, unless proven a bug or desirable to differ.

Updated by Eregon (Benoit Daloze) 4 months ago

Actually, the should_not above indeed doesn't make much sense, because it relies on nan_value returning different NaNs, which is probably platform-specific.

I added a spec for this case: [Float::NAN].should == [Float::NAN].

Also available in: Atom PDF