Project

General

Profile

Actions

Bug #19564

closed

Range.cover? fails for Range wrapped in SimpleDelegator

Added by PeteMichaud (Pete Michaud) over 1 year ago. Updated over 1 year ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-darwin22]
[ruby-core:113060]

Description

test 'built-in cover? method is broken for SimpleDelegator' do

  class TimeRangeDelegator < SimpleDelegator
  end

  t1 = Time.now
  t2 = t1+1.day
  t3 = t1+1.week

  r_long = t1..t3
  r_short = t1..t2

  assert r_long.cover?(r_short) #passes correctly, assert == true

  r_long_delegated = TimeRangeDelegator.new(r_long)
  r_short_delegated = TimeRangeDelegator.new(r_short)

  assert r_long_delegated.cover?(r_short_delegated) #fails incorrectly, assert == false
end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0