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

ruby-changes:3909

From: ko1@a...
Date: Fri, 8 Feb 2008 00:09:35 +0900 (JST)
Subject: [ruby-changes:3909] mame - Ruby:r15399 (trunk): * test/ruby/test_hash.rb: follow the change of Hash#flatten.

mame	2008-02-08 00:09:12 +0900 (Fri, 08 Feb 2008)

  New Revision: 15399

  Added files:
    trunk/test/ruby/test_prec.rb
  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_hash.rb
    trunk/test/ruby/test_time.rb
    trunk/version.h

  Log:
    * test/ruby/test_hash.rb: follow the change of Hash#flatten.
    
    * test/ruby/test_time.rb: add tests to achieve over 70% test coverage
      of time.c.
    
    * test/ruby/test_prec.rb: ditto over 90% for prec.c.
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_hash.rb?r1=15399&r2=15398&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=15399&r2=15398&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15399&r2=15398&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_time.rb?r1=15399&r2=15398&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_prec.rb?revision=15399&view=markup
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_prec.rb?r1=15399&r2=15398&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15398)
+++ ChangeLog	(revision 15399)
@@ -1,3 +1,12 @@
+Fri Feb 08 00:07:24 2008  Yusuke Endoh  <mame@t...>
+
+	* test/ruby/test_hash.rb: follow the change of Hash#flatten.
+
+	* test/ruby/test_time.rb: add tests to achieve over 70% test coverage
+	  of time.c.
+
+	* test/ruby/test_prec.rb: ditto over 90% for prec.c.
+
 Thu Feb  7 19:11:39 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* string.c (rb_str_dup): reverted unneeded change.  [ruby-dev:33634]
@@ -82,6 +91,7 @@
 
 	* test/ruby/test_hash.rb: add tests to achieve over 90% test coverage
 	  of hash.c.
+
 	* test/ruby/test_env.rb: ditto.
 
 Wed Feb  6 00:24:49 2008  Yusuke Endoh  <mame@t...>
@@ -132,6 +142,7 @@
 Sun Feb  3 21:13:13 2008  Yusuke Endoh  <mame@t...>
 
 	* test/ruby/test_numeric.rb: forgot to add this (at r15360).
+
 	* test/ruby/test_file_exhaustive.rb: add tests to achieve over 80% test
 	  coverage of file.c.
 
@@ -175,12 +186,18 @@
 Thu Jan 31 23:06:42 2008  Yusuke Endoh  <mame@t...>
 
 	* test/ruby/test_bignum.rb: suppress warnings during test.
+
 	* test/ruby/test_enum.rb: ditto.
+
 	* test/ruby/test_integer.rb: add tests to achieve over 90% test
 	  coverage of numeric.c.
+
 	* test/ruby/test_float.rb: ditto.
+
 	* test/ruby/test_fixnum.rb: ditto.
+
 	* test/ruby/test_numeric.rb: ditto.
+
 	* test/ruby/test_pack.rb: add tests to achieve over 90% test coverage
 	  of pack.c.
 
@@ -288,6 +305,7 @@
 
 	* test/ruby/test_enumerator.rb: add tests to achieve over 90% test
 	  coverage of enumerator.c.
+
 	* test/ruby/test_enum.rb: add for enum.c.
 
 Tue Jan 29 22:29:48 2008  Yusuke Endoh  <mame@t...>
@@ -847,6 +865,7 @@
 Thu Jan 24 02:13:07 2008  Yusuke Endoh  <mame@t...>
 
 	* insns.def (expandarray): fix stack inc.  [ruby-dev:32892]
+
 	* bootstraptest/test_knownbug.rb, test_massign.rb: move a fixed test.
 
 Thu Jan 24 01:00:34 2008  NARUSE, Yui  <naruse@r...>
@@ -861,13 +880,16 @@
 Wed Jan 23 23:54:40 2008  Yusuke Endoh  <mame@t...>
 
 	* sprintf.c: fix comment.  [ruby-dev:33275]
+
 	* math.c: fix comment.  [ruby-dev:33276]
 
 Wed Jan 23 22:47:34 2008  Yusuke Endoh  <mame@t...>
 
 	* test/ruby/test_struct.rb: add tests to achieve over 90% test
 	  coverage of struct.c.
+
 	* test/ruby/test_sprintf.rb: ditto for sprintf.c.
+
 	* test/ruby/test_math.rb: ditto for math.c.
 
 Wed Jan 23 22:14:28 2008  Nobuyoshi Nakada  <nobu@r...>
Index: version.h
===================================================================
--- version.h	(revision 15398)
+++ version.h	(revision 15399)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2008-02-07"
+#define RUBY_RELEASE_DATE "2008-02-08"
 #define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20080207
+#define RUBY_RELEASE_CODE 20080208
 #define RUBY_PATCHLEVEL 0
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 0
 #define RUBY_RELEASE_YEAR 2008
 #define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 7
+#define RUBY_RELEASE_DAY 8
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: test/ruby/test_prec.rb
===================================================================
--- test/ruby/test_prec.rb	(revision 0)
+++ test/ruby/test_prec.rb	(revision 15399)
@@ -0,0 +1,21 @@
+require 'test/unit'
+
+class TestPrecision < Test::Unit::TestCase
+  def test_prec_i
+    assert_same(1, 1.0.prec(Integer))
+    assert_same(1, 1.0.prec_i)
+    assert_same(1, Integer.induced_from(1.0))
+  end
+
+  def test_prec_f
+    assert_equal(1.0, 1.prec(Float))
+    assert_equal(1.0, 1.prec_f)
+    assert_equal(1.0, Float.induced_from(1))
+  end
+
+  def test_induced_from
+    m = Module.new
+    m.instance_eval { include(Precision) }
+    assert_raise(TypeError) { m.induced_from(0) }
+  end
+end

Property changes on: test/ruby/test_prec.rb
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: test/ruby/test_time.rb
===================================================================
--- test/ruby/test_time.rb	(revision 15398)
+++ test/ruby/test_time.rb	(revision 15399)
@@ -145,4 +145,207 @@
     assert_marshal_roundtrip(Marshal.load(Marshal.dump(t)))
   end
 
+  # Sat Jan 01 00:00:00 UTC 2000
+  T2000 = Time.at(946684800).gmtime
+
+  def test_security_error
+    assert_raise(SecurityError) do
+      Thread.new do
+        t = Time.gm(2000)
+        $SAFE = 4
+        t.localtime
+      end.join
+    end
+  end
+
+  def test_at3
+    assert_equal(T2000, Time.at(T2000))
+    assert_raise(RangeError) { Time.at(2**31-1, 1_000_000) }
+    assert_raise(RangeError) { Time.at(-2**31, -1_000_000) }
+  end
+
+  def test_utc_or_local
+    assert_equal(T2000, Time.gm(2000))
+    assert_equal(T2000, Time.gm(0, 0, 0, 1, 1, 2000, :foo, :bar, false, :baz))
+    assert_equal(T2000, Time.gm(0))
+    assert_equal(T2000, Time.gm(100))
+    assert_equal(T2000, Time.gm(2000, "jan"))
+    assert_equal(T2000, Time.gm(2000, "1"))
+    assert_equal(T2000, Time.gm(2000, 1, 1, 0, 0, 0, 0))
+    assert_equal(T2000, Time.gm(2000, 1, 1, 0, 0, 0, "0"))
+    assert_equal(T2000, Time.gm(2000, 1, 1, 0, 0, "0", :foo, :foo))
+    assert_raise(ArgumentError) { Time.gm(2000, 1, 1, 0, 0, -1, :foo, :foo) }
+    assert_raise(ArgumentError) { Time.gm(2000, 1, 1, 0, 0, -1.0, :foo, :foo) }
+    assert_raise(RangeError) { Time.gm(2000, 1, 1, 0, 0, 10_000_000_000_000_001.0, :foo, :foo) }
+    assert_raise(ArgumentError) { Time.gm(2000, 1, 1, 0, 0, -(2**31), :foo, :foo) }
+    o = Object.new
+    def o.divmod(x); nil; end
+    assert_raise(TypeError) { Time.gm(2000, 1, 1, 0, 0, o, :foo, :foo) }
+    def o.divmod(x); [-1, 0]; end
+    assert_raise(ArgumentError) { Time.gm(2000, 1, 1, 0, 0, o, :foo, :foo) }
+    assert_raise(ArgumentError) { Time.gm(2000, 13) }
+
+    t = Time.local(2000)
+    assert_equal(t.gmt_offset, T2000 - t)
+  end
+
+  def test_time_interval
+    m = Mutex.new.lock
+    assert_nothing_raised { m.sleep(0) }
+    assert_raise(ArgumentError) { m.sleep(-1) }
+  end
+
+  def test_to_f
+    assert_equal(946684800.0, T2000.to_f)
+  end
+
+  def test_cmp
+    assert_equal(-1, T2000 <=> Time.gm(2001))
+    assert_equal(1, T2000 <=> Time.gm(1999))
+    assert_nil(T2000 <=> 0)
+  end
+
+  def test_eql
+    assert(T2000.eql?(T2000))
+    assert(!T2000.eql?(Time.gm(2001)))
+  end
+
+  def test_utc_p
+    assert(Time.gm(2000).gmt?)
+    assert(!Time.local(2000).gmt?)
+    assert(!Time.at(0).gmt?)
+  end
+
+  def test_hash
+    assert_kind_of(Integer, T2000.hash)
+  end
+
+  def test_init_copy
+    assert_equal(T2000, T2000.dup)
+    assert_raise(TypeError) do
+      T2000.instance_eval { initialize_copy(nil) }
+    end
+  end
+
+  def test_localtime_gmtime
+    assert_nothing_raised do
+      t = Time.gm(2000)
+      assert(t.gmt?)
+      t.localtime
+      assert(!t.gmt?)
+      t.localtime
+      assert(!t.gmt?)
+      t.gmtime
+      assert(t.gmt?)
+      t.gmtime
+      assert(t.gmt?)
+    end
+
+    t1 = Time.gm(2000)
+    t2 = t1.getlocal
+    assert_equal(t1, t2)
+    t1.localtime
+    assert_equal(t1, t2)
+    assert_equal(t1.gmt?, t2.gmt?)
+
+    t1 = Time.local(2000)
+    t2 = t1.getgm
+    assert_equal(t1, t2)
+    t1.gmtime
+    assert_equal(t1, t2)
+    assert_equal(t1.gmt?, t2.gmt?)
+  end
+
+  def test_asctime
+    assert_equal("Sat Jan  1 00:00:00 2000", T2000.asctime)
+    assert_kind_of(String, Time.at(0).asctime)
+  end
+
+  def test_to_s
+    assert_equal("2000-01-01 00:00:00 UTC", T2000.to_s)
+    assert_kind_of(String, Time.at(946684800).getlocal.to_s)
+    assert_equal(Time.at(946684800).getlocal.to_s, Time.at(946684800).to_s)
+  end
+
+  def test_plus_minus_succ
+    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_readers
+    assert_equal(0, T2000.sec)
+    assert_equal(0, T2000.min)
+    assert_equal(0, T2000.hour)
+    assert_equal(1, T2000.mday)
+    assert_equal(1, T2000.mon)
+    assert_equal(2000, T2000.year)
+    assert_equal(6, T2000.wday)
+    assert_equal(1, T2000.yday)
+    assert_equal(false, T2000.isdst)
+    assert_equal("UTC", T2000.zone)
+    assert_equal(0, T2000.gmt_offset)
+    assert(!T2000.sunday?)
+    assert(!T2000.monday?)
+    assert(!T2000.tuesday?)
+    assert(!T2000.wednesday?)
+    assert(!T2000.thursday?)
+    assert(!T2000.friday?)
+    assert(T2000.saturday?)
+    assert_equal([0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"], T2000.to_a)
+
+    t = Time.at(946684800).getlocal
+    assert_equal(t.sec, Time.at(946684800).sec)
+    assert_equal(t.min, Time.at(946684800).min)
+    assert_equal(t.hour, Time.at(946684800).hour)
+    assert_equal(t.mday, Time.at(946684800).mday)
+    assert_equal(t.mon, Time.at(946684800).mon)
+    assert_equal(t.year, Time.at(946684800).year)
+    assert_equal(t.wday, Time.at(946684800).wday)
+    assert_equal(t.yday, Time.at(946684800).yday)
+    assert_equal(t.isdst, Time.at(946684800).isdst)
+    assert_equal(t.zone, Time.at(946684800).zone)
+    assert_equal(t.gmt_offset, Time.at(946684800).gmt_offset)
+    assert_equal(t.sunday?, Time.at(946684800).sunday?)
+    assert_equal(t.monday?, Time.at(946684800).monday?)
+    assert_equal(t.tuesday?, Time.at(946684800).tuesday?)
+    assert_equal(t.wednesday?, Time.at(946684800).wednesday?)
+    assert_equal(t.thursday?, Time.at(946684800).thursday?)
+    assert_equal(t.friday?, Time.at(946684800).friday?)
+    assert_equal(t.saturday?, Time.at(946684800).saturday?)
+    assert_equal(t.to_a, Time.at(946684800).to_a)
+  end
+
+  def test_strftime
+    assert_equal("Sat", T2000.strftime("%a"))
+    assert_equal("Saturday", T2000.strftime("%A"))
+    assert_equal("Jan", T2000.strftime("%b"))
+    assert_equal("January", T2000.strftime("%B"))
+    assert_equal("Sat Jan  1 00:00:00 2000", T2000.strftime("%c"))
+    assert_equal("01", T2000.strftime("%d"))
+    assert_equal("00", T2000.strftime("%H"))
+    assert_equal("12", T2000.strftime("%I"))
+    assert_equal("001", T2000.strftime("%j"))
+    assert_equal("01", T2000.strftime("%m"))
+    assert_equal("00", T2000.strftime("%M"))
+    assert_equal("AM", T2000.strftime("%p"))
+    assert_equal("00", T2000.strftime("%S"))
+    assert_equal("00", T2000.strftime("%U"))
+    assert_equal("00", T2000.strftime("%W"))
+    assert_equal("6", T2000.strftime("%w"))
+    assert_equal("01/01/00", T2000.strftime("%x"))
+    assert_equal("00:00:00", T2000.strftime("%X"))
+    assert_equal("00", T2000.strftime("%y"))
+    assert_equal("2000", T2000.strftime("%Y"))
+    assert_equal("GMT", T2000.strftime("%Z"))
+    assert_equal("%", T2000.strftime("%%"))
+
+    assert_equal("", T2000.strftime(""))
+    assert_equal("foo\0bar\x0000\x0000\x0000", T2000.strftime("foo\0bar\0%H\0%M\0%S"))
+    assert_equal("foo" * 1000, T2000.strftime("foo" * 1000))
+
+    assert_equal("Sat", Time.at(946684800).strftime("%a"))
+  end
 end
Index: test/ruby/test_hash.rb
===================================================================
--- test/ruby/test_hash.rb	(revision 15398)
+++ test/ruby/test_hash.rb	(revision 15399)
@@ -794,7 +794,7 @@
   end
 
   def test_flatten
-    assert_equal([1, 2], {[1] => [2]}.flatten)
+    assert_equal([[1], [2]], {[1] => [2]}.flatten)
   end
 
   def test_callcc

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

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