diff --git a/bootstraptest/test_insns.rb b/bootstraptest/test_insns.rb index 4dd8888..7ecb2d2 100644 --- a/bootstraptest/test_insns.rb +++ b/bootstraptest/test_insns.rb @@ -366,7 +366,6 @@ class X; def x; {}; end; end [ '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', <<~'},', ], # { diff --git a/include/ruby/intern.h b/include/ruby/intern.h index d77e5ec..ea36b04 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -943,7 +943,6 @@ VALUE rb_mod_remove_cvar(VALUE, VALUE); 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*); diff --git a/range.c b/range.c index 5897557..655d4ee 100644 --- a/range.c +++ b/range.c @@ -297,7 +297,6 @@ step_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg)) 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); } diff --git a/spec/ruby/core/time/succ_spec.rb b/spec/ruby/core/time/succ_spec.rb index 6831200..6e31ae2 100644 --- a/spec/ruby/core/time/succ_spec.rb +++ b/spec/ruby/core/time/succ_spec.rb @@ -1,19 +1,9 @@ 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 diff --git a/time.c b/time.c index 7a43e58..fc09893 100644 --- a/time.c +++ b/time.c @@ -3701,37 +3701,6 @@ time_minus(VALUE time1, VALUE time2) /* * 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 time + 1 - * - * 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). @@ -4885,7 +4854,6 @@ Init_Time(void) 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); diff --git a/vm.c b/vm.c index b867fdc..377fa3f 100644 --- a/vm.c +++ b/vm.c @@ -1597,7 +1597,7 @@ vm_init_redefined_flag(void) 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));