Feature #14091 ยป remove-time-succ.diff
bootstraptest/test_insns.rb | ||
---|---|---|
[ 'opt_succ',%Q{ #{ $FIXNUM_MAX }.succ == #{ $FIXNUM_MAX + 1 } }, ]
|
||
end,
|
||
[ 'opt_succ', %q{ '1'.succ == '2' }, ],
|
||
[ 'opt_succ', %q{ x = Time.at(0); x.succ == Time.at(1) }, ],
|
||
[ 'opt_not', %q{ ! false }, ],
|
||
[ 'opt_neq', <<~'},', ], # {
|
include/ruby/intern.h | ||
---|---|---|
ID rb_frame_callee(void);
|
||
VALUE rb_str_succ(VALUE);
|
||
VALUE rb_time_succ(VALUE);
|
||
VALUE rb_make_backtrace(void);
|
||
VALUE rb_make_exception(int, const VALUE*);
|
||
range.c | ||
---|---|---|
static int
|
||
discrete_object_p(VALUE obj)
|
||
{
|
||
if (rb_obj_is_kind_of(obj, rb_cTime)) return FALSE; /* until Time#succ removed */
|
||
return rb_respond_to(obj, id_succ);
|
||
}
|
||
spec/ruby/core/time/succ_spec.rb | ||
---|---|---|
require File.expand_path('../../../spec_helper', __FILE__)
|
||
describe "Time#succ" do
|
||
it "returns a new time one second later than time" do
|
||
it "raises a NoMethodError" do
|
||
-> {
|
||
@result = Time.at(100).succ
|
||
}.should complain(/Time#succ is obsolete/)
|
||
@result.should == Time.at(101)
|
||
end
|
||
it "returns a new instance" do
|
||
t1 = Time.at(100)
|
||
t2 = nil
|
||
-> {
|
||
t2 = t1.succ
|
||
}.should complain(/Time#succ is obsolete/)
|
||
t1.object_id.should_not == t2.object_id
|
||
}.should raise_error(NoMethodError, /undefined method `succ'/)
|
||
end
|
||
end
|
time.c | ||
---|---|---|
/*
|
||
* call-seq:
|
||
* time.succ -> new_time
|
||
*
|
||
* Returns a new Time object, one second later than _time_.
|
||
* Time#succ is obsolete since 1.9.2 for time is not a discrete value.
|
||
*
|
||
* t = Time.now #=> 2007-11-19 08:23:57 -0600
|
||
* t.succ #=> 2007-11-19 08:23:58 -0600
|
||
*
|
||
* Use instead <code>time + 1</code>
|
||
*
|
||
* t + 1 #=> 2007-11-19 08:23:58 -0600
|
||
*/
|
||
VALUE
|
||
rb_time_succ(VALUE time)
|
||
{
|
||
struct time_object *tobj;
|
||
struct time_object *tobj2;
|
||
rb_warn("Time#succ is obsolete; use time + 1");
|
||
GetTimeval(time, tobj);
|
||
time = time_new_timew(rb_cTime, wadd(tobj->timew, WINT2FIXWV(TIME_SCALE)));
|
||
GetTimeval(time, tobj2);
|
||
TIME_COPY_GMT(tobj2, tobj);
|
||
return time;
|
||
}
|
||
#define time_succ rb_time_succ
|
||
/*
|
||
* call-seq:
|
||
* time.round([ndigits]) -> new_time
|
||
*
|
||
* Rounds sub seconds to a given precision in decimal digits (0 digits by default).
|
||
... | ... | |
rb_define_method(rb_cTime, "+", time_plus, 1);
|
||
rb_define_method(rb_cTime, "-", time_minus, 1);
|
||
rb_define_method(rb_cTime, "succ", time_succ, 0);
|
||
rb_define_method(rb_cTime, "round", time_round, -1);
|
||
rb_define_method(rb_cTime, "sec", time_sec, 0);
|
vm.c | ||
---|---|---|
OP(Length, LENGTH), (C(Array), C(String), C(Hash));
|
||
OP(Size, SIZE), (C(Array), C(String), C(Hash));
|
||
OP(EmptyP, EMPTY_P), (C(Array), C(String), C(Hash));
|
||
OP(Succ, SUCC), (C(Integer), C(String), C(Time));
|
||
OP(Succ, SUCC), (C(Integer), C(String));
|
||
OP(EqTilde, MATCH), (C(Regexp), C(String));
|
||
OP(Freeze, FREEZE), (C(String));
|
||
OP(UMinus, UMINUS), (C(String));
|