ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
From: eregontp@gmail•com
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:50807] [Ruby trunk Bug#15432] Float の NaN のみを含む配列比較のテスト
Date: Thu, 27 Jun 2019 17:44:35 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-78914.20190627174435.56985c3c273541b3@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15432.20181218084648@ruby-lang.org

Issue #15432 has been updated by Eregon (Benoit Daloze).


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.

----------------------------------------
Bug #15432: Float の NaN のみを含む配列比較のテスト
https://bugs.ruby-lang.org/issues/15432#change-78914

* Author: shuujii (Shuji KOBAYASHI)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0rc2 (2018-12-15 trunk 66408) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Float の NaN のみを含む配列比較のテストが以下にあります。

~~~ ruby
## 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 で未定義動作とするとなったと思うので不要ではないでしょうか。

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

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



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2019-06-27 17:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15432.20181218084648@ruby-lang.org>
2018-12-18  8:46 ` [ruby-dev:50715] [Ruby trunk Bug#15432] Float の NaN のみを含む配列比較のテスト shuujii
2019-06-13  1:45 ` [ruby-dev:50799] " merch-redmine
2019-06-27 17:44 ` eregontp [this message]
2019-06-27 17:58 ` [ruby-dev:50808] " eregontp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-78914.20190627174435.56985c3c273541b3@ruby-lang.org \
    --to=ruby-dev@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).