Project

General

Profile

Actions

Bug #15432

closed

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

Added by shuujii (Shuji KOBAYASHI) over 5 years ago. Updated almost 5 years ago.

Status:
Closed
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

Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago

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

Actions #2

Updated by jeremyevans (Jeremy Evans) almost 5 years 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) almost 5 years 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) almost 5 years 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].

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0