summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstraptest/test_insns.rb1
-rw-r--r--include/ruby/internal/intern/time.h1
-rw-r--r--spec/ruby/core/time/succ_spec.rb56
-rw-r--r--test/ruby/test_time.rb3
-rw-r--r--time.c35
-rw-r--r--vm.c4
6 files changed, 33 insertions, 67 deletions
diff --git a/bootstraptest/test_insns.rb b/bootstraptest/test_insns.rb
index 5ffd953328..9052cad7bd 100644
--- a/bootstraptest/test_insns.rb
+++ b/bootstraptest/test_insns.rb
@@ -391,7 +391,6 @@ tests = [
[ '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 e01f40cfe8..c7ae6ec2f5 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);
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 532448a1dc..fa6343f8e2 100644
--- a/spec/ruby/core/time/succ_spec.rb
+++ b/spec/ruby/core/time/succ_spec.rb
@@ -1,38 +1,40 @@
-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 0fc7dd78ab..60c9395ec1 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -604,13 +604,12 @@ class TestTime < Test::Unit::TestCase
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 ae9fdc7104..d8f3b6a4aa 100644
--- a/time.c
+++ b/time.c
@@ -4260,40 +4260,6 @@ time_minus(VALUE time1, VALUE time2)
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)
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 1e8056a36d..6573925509 100644
--- a/vm.c
+++ b/vm.c
@@ -1810,7 +1810,9 @@ vm_redefinition_check_flag(VALUE klass)
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)
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));