[前][次][番号順一覧][スレッド一覧]

ruby-changes:63995

From: Nobuyoshi <ko1@a...>
Date: Mon, 7 Dec 2020 18:39:16 +0900 (JST)
Subject: [ruby-changes:63995] 7817a438eb (master): Removed deprecated Time#succ

https://git.ruby-lang.org/ruby.git/commit/?id=7817a438eb

From 7817a438eb1803e7b3358f43bd1f38479badfbdc Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 2 Dec 2020 15:50:01 +0900
Subject: Removed deprecated Time#succ


diff --git a/bootstraptest/test_insns.rb b/bootstraptest/test_insns.rb
index 5ffd953..9052cad 100644
--- a/bootstraptest/test_insns.rb
+++ b/bootstraptest/test_insns.rb
@@ -391,7 +391,6 @@ tests = [ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_insns.rb#L391
     [ '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/internal/intern/time.h b/include/ruby/internal/intern/time.h
index e01f40c..c7ae6ec 100644
--- a/include/ruby/internal/intern/time.h
+++ b/include/ruby/internal/intern/time.h
@@ -45,7 +45,6 @@ struct timeval rb_time_timeval(VALUE time); https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/intern/time.h#L45
 struct timespec rb_time_timespec(VALUE time);
 struct timespec rb_time_timespec_interval(VALUE num);
 VALUE rb_time_utc_offset(VALUE time);
-VALUE rb_time_succ(VALUE);
 
 RBIMPL_SYMBOL_EXPORT_END()
 
diff --git a/spec/ruby/core/time/succ_spec.rb b/spec/ruby/core/time/succ_spec.rb
index 532448a..fa6343f 100644
--- a/spec/ruby/core/time/succ_spec.rb
+++ b/spec/ruby/core/time/succ_spec.rb
@@ -1,38 +1,40 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/time/succ_spec.rb#L1
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+ruby_version_is ""..."3.0" do
+  require_relative '../../spec_helper'
+  require_relative 'fixtures/classes'
 
-describe "Time#succ" do
-  it "returns a new time one second later than time" do
-    suppress_warning {
-      @result = Time.at(100).succ
-    }
+  describe "Time#succ" do
+    it "returns a new time one second later than time" do
+      suppress_warning {
+        @result = Time.at(100).succ
+      }
 
-    @result.should == Time.at(101)
-  end
+      @result.should == Time.at(101)
+    end
 
-  it "returns a new instance" do
-    time = Time.at(100)
+    it "returns a new instance" do
+      time = Time.at(100)
 
-    suppress_warning {
-      @result = time.succ
-    }
+      suppress_warning {
+        @result = time.succ
+      }
 
-    @result.should_not equal time
-  end
+      @result.should_not equal time
+    end
 
-  it "is obsolete" do
-    -> {
-      Time.at(100).succ
-    }.should complain(/Time#succ is obsolete/)
-  end
+    it "is obsolete" do
+      -> {
+        Time.at(100).succ
+      }.should complain(/Time#succ is obsolete/)
+    end
 
-  ruby_version_is "2.6" do
-    context "zone is a timezone object" do
-      it "preserves time zone" do
-        zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
-        time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 1
+    ruby_version_is "2.6" do
+      context "zone is a timezone object" do
+        it "preserves time zone" do
+          zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
+          time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 1
 
-        time.zone.should == zone
+          time.zone.should == zone
+        end
       end
     end
   end
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 0fc7dd7..60c9395 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -604,13 +604,12 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L604
     assert_nil(t.getlocal("+02:00").zone)
   end
 
-  def test_plus_minus_succ
+  def test_plus_minus
     t2000 = get_t2000
     # assert_raise(RangeError) { t2000 + 10000000000 }
     # assert_raise(RangeError)  t2000 - 3094168449 }
     # assert_raise(RangeError) { t2000 + 1200798848 }
     assert_raise(TypeError) { t2000 + Time.now }
-    assert_equal(t2000 + 1, t2000.succ)
   end
 
   def test_plus_type
diff --git a/time.c b/time.c
index ae9fdc7..d8f3b6a 100644
--- a/time.c
+++ b/time.c
@@ -4260,40 +4260,6 @@ time_minus(VALUE time1, VALUE time2) https://github.com/ruby/ruby/blob/trunk/time.c#L4260
     return time_add(tobj, time1, time2, -1);
 }
 
-/*
- * 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);
-    TZMODE_COPY(tobj2, tobj);
-    if (TZMODE_LOCALTIME_P(tobj2) && maybe_tzobj_p(tobj2->vtm.zone)) {
-        zone_localtime(tobj2->vtm.zone, time);
-    }
-    return time;
-}
-
-#define time_succ rb_time_succ
-
 static VALUE
 ndigits_denominator(VALUE ndigits)
 {
@@ -5923,7 +5889,6 @@ Init_Time(void) https://github.com/ruby/ruby/blob/trunk/time.c#L5889
     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, "floor", time_floor, -1);
     rb_define_method(rb_cTime, "ceil", time_ceil, -1);
diff --git a/vm.c b/vm.c
index 1e8056a..6573925 100644
--- a/vm.c
+++ b/vm.c
@@ -1810,7 +1810,9 @@ vm_redefinition_check_flag(VALUE klass) https://github.com/ruby/ruby/blob/trunk/vm.c#L1810
     if (klass == rb_cArray)  return ARRAY_REDEFINED_OP_FLAG;
     if (klass == rb_cHash)   return HASH_REDEFINED_OP_FLAG;
     if (klass == rb_cSymbol) return SYMBOL_REDEFINED_OP_FLAG;
+#if 0
     if (klass == rb_cTime)   return TIME_REDEFINED_OP_FLAG;
+#endif
     if (klass == rb_cRegexp) return REGEXP_REDEFINED_OP_FLAG;
     if (klass == rb_cNilClass) return NIL_REDEFINED_OP_FLAG;
     if (klass == rb_cTrueClass) return TRUE_REDEFINED_OP_FLAG;
@@ -1920,7 +1922,7 @@ vm_init_redefined_flag(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L1922
     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));
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]