Project

General

Profile

Actions

Bug #14772

closed

Revision 63453 triggers 3 Active Support test failures

Added by yahonda (Yasuo Honda) almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-05-17 trunk 63453) [x86_64-linux]
[ruby-core:87151]

Description

Steps to reproduce:

git clone https://github.com/rails/rails.git
cd rails/activesupport
sudo gem install bundler
bundle install
bundle exec ruby -w -Itest test/core_ext/range_ext_test.rb -n /test_should_compare/

Expected results:

It should pass as revision 63452 passes these tests:

$ ruby -v
ruby 2.6.0dev (2018-05-17 trunk 63452) [x86_64-linux]
$ bundle exec ruby -w -Itest test/core_ext/range_ext_test.rb -n /test_should_compare/
Run options: -n /test_should_compare/ --seed 53093

# Running:

...

Finished in 0.001067s, 2811.8560 runs/s, 2811.8560 assertions/s.
3 runs, 3 assertions, 0 failures, 0 errors, 0 skips
$

Actual results:

$ ruby -v
ruby 2.6.0dev (2018-05-17 trunk 63453) [x86_64-linux]
$ bundle exec ruby -w -Itest test/core_ext/range_ext_test.rb -n /test_should_compare/
Run options: -n /test_should_compare/ --seed 13526

# Running:

F

Failure:
RangeTest#test_should_compare_other_with_exclusive_end [test/core_ext/range_ext_test.rb:72]:
Expected false to be truthy.


bin/rails test test/core_ext/range_ext_test.rb:71

F

Failure:
RangeTest#test_should_compare_identical_exclusive [test/core_ext/range_ext_test.rb:68]:
Expected false to be truthy.


bin/rails test test/core_ext/range_ext_test.rb:67

F

Failure:
RangeTest#test_should_compare_identical_inclusive [test/core_ext/range_ext_test.rb:64]:
Expected false to be truthy.


bin/rails test test/core_ext/range_ext_test.rb:63



Finished in 0.002352s, 1275.4549 runs/s, 1275.4549 assertions/s.
3 runs, 3 assertions, 3 failures, 0 errors, 0 skips
$

Here are code snippets of failed tests:


 63   def test_should_compare_identical_inclusive
 64     assert((1..10) === (1..10))
 65   end
 66
 67   def test_should_compare_identical_exclusive
 68     assert((1...10) === (1...10))
 69   end
 70
 71   def test_should_compare_other_with_exclusive_end
 72     assert((1..10) === (1...10))
 73   end

Updated by nobu (Nobuyoshi Nakada) almost 6 years ago

How does Active Support extend Range?

Updated by yahonda (Yasuo Honda) almost 6 years ago

ActiveSupports's Range#include? is defined as follows:

https://github.com/rails/rails/blob/870766017ab20541a1e3b10bf026d82522028028/activesupport/lib/active_support/core_ext/range/include_range.rb#L13-L21

    def include?(value)
      if value.is_a?(::Range)
        # 1...10 includes 1..9 but it does not include 1..10.
        operator = exclude_end? && !value.exclude_end? ? :< : :<=
        super(value.first) && value.last.send(operator, last)
      else
        super
      end

Other ActiveSupport Range can be found from https://github.com/rails/rails/tree/master/activesupport/lib/active_support/core_ext/range

Updated by nobu (Nobuyoshi Nakada) almost 6 years ago

  • Status changed from Open to Feedback

It seems cover? semantics, rather than include?'s one.
Isn't it possible to define cover? too, or make the alias, in Active Support?

Updated by yahonda (Yasuo Honda) almost 6 years ago

Hi,

Based on the feedback and commit message, I have created alias_method :range?, :include? just below the include?(value) method but did not help.

https://github.com/yahonda/rails/commit/fb6344a524440fdb37c7d1dfe1d149c9976b7fd9

Let me open an issue at https://github.com/rails/rails/ to get more wider information from other Rails developers.

Thank you.

Updated by yahonda (Yasuo Honda) almost 6 years ago

  • Status changed from Feedback to Closed

Closing since https://github.com/rails/rails/pull/32938/commits/0fcb921a65e615c301450d7820b03473acd53898 addressed these 3 failures by changing Active Support.

Thanks for the help.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0