diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-21 05:05:56 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-21 05:05:56 +0000 |
commit | 7a03d4637cefadadad31fff5bdd6c20a8e5a00bd (patch) | |
tree | 833ae8d0462d7b8ee277d9ae707776e162d39783 | |
parent | 137514a3992eba2be425d6f5df48d259428acb20 (diff) |
merge revision(s) 50421: [Backport #11113]
* range.c (linear_object_p, range_include): test if covered for
linear objects. [ruby-core:69052] [Bug #11113]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | range.c | 18 | ||||
-rw-r--r-- | test/ruby/test_range.rb | 8 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 30 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Thu May 21 14:04:06 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * range.c (linear_object_p, range_include): test if covered for + linear objects. [ruby-core:69052] [Bug #11113] + Thu May 21 14:01:40 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org> * rational.c: Added documentation for rational literal. @@ -329,6 +329,21 @@ discrete_object_p(VALUE obj) return rb_respond_to(obj, id_succ); } +static int +linear_object_p(VALUE obj) +{ + if (FIXNUM_P(obj) || FLONUM_P(obj)) return TRUE; + if (SPECIAL_CONST_P(obj)) return FALSE; + switch (BUILTIN_TYPE(obj)) { + case T_FLOAT: + case T_BIGNUM: + return TRUE; + } + if (rb_obj_is_kind_of(obj, rb_cNumeric)) return TRUE; + if (rb_obj_is_kind_of(obj, rb_cTime)) return TRUE; + return FALSE; +} + static VALUE range_step_size(VALUE range, VALUE args, VALUE eobj) { @@ -1148,8 +1163,7 @@ range_include(VALUE range, VALUE val) VALUE beg = RANGE_BEG(range); VALUE end = RANGE_END(range); int nv = FIXNUM_P(beg) || FIXNUM_P(end) || - rb_obj_is_kind_of(beg, rb_cNumeric) || - rb_obj_is_kind_of(end, rb_cNumeric); + linear_object_p(beg) || linear_object_p(end); if (nv || !NIL_P(rb_check_to_integer(beg, "to_int")) || diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 41107e094a..293818516d 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -278,6 +278,14 @@ class TestRange < Test::Unit::TestCase assert_not_operator(0..10, :===, 11) end + def test_eqq_time + bug11113 = '[ruby-core:69052] [Bug #11113]' + t = Time.now + assert_nothing_raised(TypeError, bug11113) { + assert_operator(t..(t+10), :===, t+5) + } + end + def test_include assert_include("a".."z", "c") assert_not_include("a".."z", "5") @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.7" #define RUBY_RELEASE_DATE "2015-05-21" -#define RUBY_PATCHLEVEL 353 +#define RUBY_PATCHLEVEL 354 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 5 |