ruby-changes:11589
From: yugui <ko1@a...>
Date: Sun, 19 Apr 2009 22:35:16 +0900 (JST)
Subject: [ruby-changes:11589] Ruby:r23227 (ruby_1_9_1): merges r23075 from trunk into ruby_1_9_1.
yugui 2009-04-19 22:34:51 +0900 (Sun, 19 Apr 2009) New Revision: 23227 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23227 Log: merges r23075 from trunk into ruby_1_9_1. -- * time.c (time_cmp): negate the result of reverse comparison. Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/test/ruby/test_time.rb branches/ruby_1_9_1/time.c Index: ruby_1_9_1/time.c =================================================================== --- ruby_1_9_1/time.c (revision 23226) +++ ruby_1_9_1/time.c (revision 23227) @@ -1109,7 +1109,7 @@ cmp = rb_funcall(time2, rb_intern("<=>"), 1, time1); if (NIL_P(cmp)) return Qnil; - n = rb_cmpint(cmp, time1, time2); + n = -rb_cmpint(cmp, time1, time2); if (n == 0) return INT2FIX(0); if (n > 0) return INT2FIX(1); return INT2FIX(-1); Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 23226) +++ ruby_1_9_1/ChangeLog (revision 23227) @@ -1,3 +1,7 @@ +Fri Mar 27 01:33:37 2009 Tanaka Akira <akr@f...> + + * time.c (time_cmp): negate the result of reverse comparison. + Fri Mar 27 01:19:50 2009 Tanaka Akira <akr@f...> * bignum.c (rb_cmpint): FIX2INT may fail on LP64 platforms. Index: ruby_1_9_1/test/ruby/test_time.rb =================================================================== --- ruby_1_9_1/test/ruby/test_time.rb (revision 23226) +++ ruby_1_9_1/test/ruby/test_time.rb (revision 23227) @@ -1,6 +1,7 @@ require 'test/unit' require 'rational' require 'timeout' +require 'delegate' class TestTime < Test::Unit::TestCase def setup @@ -470,4 +471,13 @@ assert_equal("JAN", T2000.strftime("%#h")) assert_equal("FRIDAY", Time.local(2008,1,4).strftime("%#A")) end + + def test_delegate + d1 = SimpleDelegator.new(t1 = Time.utc(2000)) + d2 = SimpleDelegator.new(t2 = Time.utc(2001)) + assert_equal(-1, t1 <=> t2) + assert_equal(1, t2 <=> t1) + assert_equal(-1, d1 <=> d2) + assert_equal(1, d2 <=> d1) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/