File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change
1
+ Sun May 3 10:02:12 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
2
+
3
+ * range.c (linear_object_p, range_include): test if covered for
4
+ linear objects. [ruby-core:69052] [Bug #11113]
5
+
1
6
Fri May 1 13:30:24 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
2
7
3
8
* dln.c (dln_load): check if a different libruby is loaded by the
Original file line number Diff line number Diff line change @@ -331,6 +331,21 @@ discrete_object_p(VALUE obj)
331
331
return rb_respond_to (obj , id_succ );
332
332
}
333
333
334
+ static int
335
+ linear_object_p (VALUE obj )
336
+ {
337
+ if (FIXNUM_P (obj ) || FLONUM_P (obj )) return TRUE;
338
+ if (SPECIAL_CONST_P (obj )) return FALSE;
339
+ switch (BUILTIN_TYPE (obj )) {
340
+ case T_FLOAT :
341
+ case T_BIGNUM :
342
+ return TRUE;
343
+ }
344
+ if (rb_obj_is_kind_of (obj , rb_cNumeric )) return TRUE;
345
+ if (rb_obj_is_kind_of (obj , rb_cTime )) return TRUE;
346
+ return FALSE;
347
+ }
348
+
334
349
static VALUE
335
350
range_step_size (VALUE range , VALUE args , VALUE eobj )
336
351
{
@@ -1156,8 +1171,7 @@ range_include(VALUE range, VALUE val)
1156
1171
VALUE beg = RANGE_BEG (range );
1157
1172
VALUE end = RANGE_END (range );
1158
1173
int nv = FIXNUM_P (beg ) || FIXNUM_P (end ) ||
1159
- rb_obj_is_kind_of (beg , rb_cNumeric ) ||
1160
- rb_obj_is_kind_of (end , rb_cNumeric );
1174
+ linear_object_p (beg ) || linear_object_p (end );
1161
1175
1162
1176
if (nv ||
1163
1177
!NIL_P (rb_check_to_integer (beg , "to_int" )) ||
Original file line number Diff line number Diff line change @@ -283,6 +283,14 @@ def test_eqq
283
283
assert_not_operator ( 0 ..10 , :=== , 11 )
284
284
end
285
285
286
+ def test_eqq_time
287
+ bug11113 = '[ruby-core:69052] [Bug #11113]'
288
+ t = Time . now
289
+ assert_nothing_raised ( TypeError , bug11113 ) {
290
+ assert_operator ( t ..( t +10 ) , :=== , t +5 )
291
+ }
292
+ end
293
+
286
294
def test_include
287
295
assert_include ( "a" .."z" , "c" )
288
296
assert_not_include ( "a" .."z" , "5" )
You can’t perform that action at this time.
0 commit comments