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

ruby-changes:32899

From: nagachika <ko1@a...>
Date: Sun, 16 Feb 2014 00:20:54 +0900 (JST)
Subject: [ruby-changes:32899] nagachika:r44978 (ruby_2_0_0): merge revision(s) r42242:

nagachika	2014-02-16 00:20:50 +0900 (Sun, 16 Feb 2014)

  New Revision: 44978

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44978

  Log:
    merge revision(s) r42242:
    
    * test/ruby/test_hash.rb: use @cls.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/test/ruby/test_hash.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 44977)
+++ ruby_2_0_0/version.h	(revision 44978)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-02-16"
-#define RUBY_PATCHLEVEL 412
+#define RUBY_PATCHLEVEL 413
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_0_0/test/ruby/test_hash.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_hash.rb	(revision 44977)
+++ ruby_2_0_0/test/ruby/test_hash.rb	(revision 44978)
@@ -6,8 +6,8 @@ require_relative 'envutil' https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L6
 class TestHash < Test::Unit::TestCase
 
   def test_hash
-    x = {1=>2, 2=>4, 3=>6}
-    y = {1=>2, 2=>4, 3=>6} # y = {1, 2, 2, 4, 3, 6} # 1.9 doesn't support
+    x = @cls[1=>2, 2=>4, 3=>6]
+    y = @cls[1=>2, 2=>4, 3=>6] # y = {1, 2, 2, 4, 3, 6} # 1.9 doesn't support
 
     assert_equal(2, x[1])
 
@@ -103,8 +103,8 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L103
   end
 
   def test_dup_will_rehash
-    set1 = { }
-    set2 = { set1 => true}
+    set1 = @cls[]
+    set2 = @cls[set1 => true]
 
     set1[set1] = true
 
@@ -311,9 +311,9 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L311
   end
 
   def test_keep_if
-    h = {1=>2,3=>4,5=>6}
+    h = @cls[1=>2,3=>4,5=>6]
     assert_equal({3=>4,5=>6}, h.keep_if {|k, v| k + v >= 7 })
-    h = {1=>2,3=>4,5=>6}
+    h = @cls[1=>2,3=>4,5=>6]
     assert_equal({1=>2,3=>4,5=>6}, h.keep_if{true})
   end
 
@@ -337,9 +337,9 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L337
   end
 
   def test_dup_equality
-    h = {'k' => 'v'}
+    h = @cls['k' => 'v']
     assert_equal(h, h.dup)
-    h1 = {h => 1}
+    h1 = @cls[h => 1]
     assert_equal(h1, h1.dup)
     h[1] = 2
     assert_equal(h1, h1.dup)
@@ -739,22 +739,22 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L739
   end
 
   def test_create
-    assert_equal({1=>2, 3=>4}, Hash[[[1,2],[3,4]]])
+    assert_equal({1=>2, 3=>4}, @cls[[[1,2],[3,4]]])
     assert_raise(ArgumentError) { Hash[0, 1, 2] }
-    assert_warning(/wrong element type Fixnum at 1 /) {Hash[[[1, 2], 3]]}
+    assert_warning(/wrong element type Fixnum at 1 /) {@cls[[[1, 2], 3]]}
     bug5406 = '[ruby-core:39945]'
-    assert_raise(ArgumentError, bug5406) { Hash[[[1, 2], [3, 4, 5]]] }
-    assert_equal({1=>2, 3=>4}, Hash[1,2,3,4])
+    assert_raise(ArgumentError, bug5406) { @cls[[[1, 2], [3, 4, 5]]] }
+    assert_equal({1=>2, 3=>4}, @cls[1,2,3,4])
     o = Object.new
     def o.to_hash() {1=>2} end
-    assert_equal({1=>2}, Hash[o], "[ruby-dev:34555]")
+    assert_equal({1=>2}, @cls[o], "[ruby-dev:34555]")
   end
 
   def test_rehash2
-    h = {1 => 2, 3 => 4}
+    h = @cls[1 => 2, 3 => 4]
     assert_equal(h.dup, h.rehash)
     assert_raise(RuntimeError) { h.each { h.rehash } }
-    assert_equal({}, {}.rehash)
+    assert_equal({}, @cls[].rehash)
   end
 
   def test_fetch2
@@ -762,35 +762,35 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L762
   end
 
   def test_default_proc
-    h = Hash.new {|hh, k| hh + k + "baz" }
+    h = @cls.new {|hh, k| hh + k + "baz" }
     assert_equal("foobarbaz", h.default_proc.call("foo", "bar"))
     assert_nil(h.default_proc = nil)
     assert_nil(h.default_proc)
     h.default_proc = ->(h, k){ true }
     assert(h[:nope])
-    h = {}
+    h = @cls[]
     assert_nil(h.default_proc)
   end
 
   def test_shift2
-    h = Hash.new {|hh, k| :foo }
+    h = @cls.new {|hh, k| :foo }
     h[1] = 2
     assert_equal([1, 2], h.shift)
     assert_equal(:foo, h.shift)
     assert_equal(:foo, h.shift)
 
-    h = Hash.new(:foo)
+    h = @cls.new(:foo)
     h[1] = 2
     assert_equal([1, 2], h.shift)
     assert_equal(:foo, h.shift)
     assert_equal(:foo, h.shift)
 
-    h = {1=>2}
+    h =@cls[1=>2]
     h.each { assert_equal([1, 2], h.shift) }
   end
 
   def test_shift_none
-    h = Hash.new {|hh, k| "foo"}
+    h = @cls.new {|hh, k| "foo"}
     def h.default(k = nil)
       super.upcase
     end
@@ -798,33 +798,33 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L798
   end
 
   def test_reject_bang2
-    assert_equal({1=>2}, {1=>2,3=>4}.reject! {|k, v| k + v == 7 })
-    assert_nil({1=>2,3=>4}.reject! {|k, v| k == 5 })
-    assert_nil({}.reject! { })
+    assert_equal({1=>2}, @cls[1=>2,3=>4].reject! {|k, v| k + v == 7 })
+    assert_nil(@cls[1=>2,3=>4].reject! {|k, v| k == 5 })
+    assert_nil(@cls[].reject! { })
   end
 
   def test_select
-    assert_equal({3=>4,5=>6}, {1=>2,3=>4,5=>6}.select {|k, v| k + v >= 7 })
+    assert_equal({3=>4,5=>6}, @cls[1=>2,3=>4,5=>6].select {|k, v| k + v >= 7 })
   end
 
   def test_select!
-    h = {1=>2,3=>4,5=>6}
+    h = @cls[1=>2,3=>4,5=>6]
     assert_equal(h, h.select! {|k, v| k + v >= 7 })
     assert_equal({3=>4,5=>6}, h)
-    h = {1=>2,3=>4,5=>6}
+    h = @cls[1=>2,3=>4,5=>6]
     assert_equal(nil, h.select!{true})
   end
 
   def test_clear2
-    assert_equal({}, {1=>2,3=>4,5=>6}.clear)
-    h = {1=>2,3=>4,5=>6}
+    assert_equal({}, @cls[1=>2,3=>4,5=>6].clear)
+    h = @cls[1=>2,3=>4,5=>6]
     h.each { h.clear }
     assert_equal({}, h)
   end
 
   def test_replace2
-    h1 = Hash.new { :foo }
-    h2 = {}
+    h1 = @cls.new { :foo }
+    h2 = @cls.new
     h2.replace h1
     assert_equal(:foo, h2[0])
 
@@ -837,71 +837,74 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L837
   end
 
   def test_size2
-    assert_equal(0, {}.size)
+    assert_equal(0, @cls[].size)
   end
 
   def test_equal2
-    assert({} != 0)
+    assert_not_equal(0, @cls[])
     o = Object.new
-    def o.to_hash; {}; end
+    o.instance_variable_set(:@cls, @cls)
+    def o.to_hash; @cls[]; end
     def o.==(x); true; end
     assert({} == o)
     def o.==(x); false; end
     assert({} != o)
 
-    h1 = {1=>2}; h2 = {3=>4}
+    h1 = @cls[1=>2]; h2 = @cls[3=>4]
     assert(h1 != h2)
-    h1 = {1=>2}; h2 = {1=>4}
+    h1 = @cls[1=>2]; h2 = @cls[1=>4]
     assert(h1 != h2)
   end
 
   def test_eql
-    assert_not_send([{}, :eql?, 0])
+    assert_not_send([@cls[], :eql?, 0])
     o = Object.new
-    def o.to_hash; {}; end
+    o.instance_variable_set(:@cls, @cls)
+    def o.to_hash; @cls[]; end
     def o.eql?(x); true; end
-    assert_send([{}, :eql?, o])
+    assert_send([@cls[], :eql?, o])
     def o.eql?(x); false; end
-    assert_not_send([{}, :eql?, o])
+    assert_not_send([@cls[], :eql?, o])
   end
 
   def test_hash2
-    assert_kind_of(Integer, {}.hash)
-    h = {1=>2}
+    assert_kind_of(Integer, @cls[].hash)
+    h = @cls[1=>2]
     h.shift
     assert_equal({}.hash, h.hash, '[ruby-core:38650]')
   end
 
   def test_update2
-    h1 = {1=>2, 3=>4}
+    h1 = @cls[1=>2, 3=>4]
     h2 = {1=>3, 5=>7}
     h1.update(h2) {|k, v1, v2| k + v1 + v2 }
     assert_equal({1=>6, 3=>4, 5=>7}, h1)
   end
 
   def test_merge
-    h1 = {1=>2, 3=>4}
+    h1 = @cls[1=>2, 3=>4]
     h2 = {1=>3, 5=>7}
     assert_equal({1=>3, 3=>4, 5=>7}, h1.merge(h2))
     assert_equal({1=>6, 3=>4, 5=>7}, h1.merge(h2) {|k, v1, v2| k + v1 + v2 })
   end
 
   def test_assoc
-    assert_equal([3,4], {1=>2, 3=>4, 5=>6}.assoc(3))
-    assert_nil({1=>2, 3=>4, 5=>6}.assoc(4))
+    assert_equal([3,4], @cls[1=>2, 3=>4, 5=>6].assoc(3))
+    assert_nil(@cls[1=>2, 3=>4, 5=>6].assoc(4))
+    assert_equal([1.0,1], @cls[1.0=>1].assoc(1))
   end
 
   def test_rassoc
-    assert_equal([3,4], {1=>2, 3=>4, 5=>6}.rassoc(4))
+    assert_equal([3,4], @cls[1=>2, 3=>4, 5=>6].rassoc(4))
     assert_nil({1=>2, 3=>4, 5=>6}.rassoc(3))
   end
 
   def test_flatten
-    assert_equal([[1], [2]], {[1] => [2]}.flatten)
+    assert_equal([[1], [2]], @cls[[1] => [2]].flatten)
   end
 
   def test_callcc
-    h = {1=>2}
+    h = @cls[1=>2]
     c = nil
     f = false
     h.each { callcc {|c2| c = c2 } }
@@ -911,7 +914,7 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L914
     end
     assert_raise(RuntimeError) { h.each { h.rehash } }
 
-    h = {1=>2}
+    h = @cls[1=>2]
     c = nil
     assert_raise(RuntimeError) do
       h.each { callcc {|c2| c = c2 } }
@@ -944,29 +947,29 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L947
   end
 
   def test_hash_hash
-    assert_equal({0=>2,11=>1}.hash, {11=>1,0=>2}.hash)
+    assert_equal({0=>2,11=>1}.hash, @cls[11=>1,0=>2].hash)
     o1 = ObjWithHash.new(0,1)
     o2 = ObjWithHash.new(11,1)
-    assert_equal({o1=>1,o2=>2}.hash, {o2=>2,o1=>1}.hash)
+    assert_equal({o1=>1,o2=>2}.hash, @cls[o2=>2,o1=>1].hash)
   end
 
   def test_hash_bignum_hash
     x = 2<<(32-3)-1
-    assert_equal({x=>1}.hash, {x=>1}.hash)
+    assert_equal({x=>1}.hash, @cls[x=>1].hash)
     x = 2<<(64-3)-1
-    assert_equal({x=>1}.hash, {x=>1}.hash)
+    assert_equal({x=>1}.hash, @cls[x=>1].hash)
 
     o = Object.new
     def o.hash; 2 << 100; end
-    assert_equal({o=>1}.hash, {o=>1}.hash)
+    assert_equal({o=>1}.hash, @cls[o=>1].hash)
   end
 
   def test_hash_poped
-    assert_nothing_raised { eval("a = 1; {a => a}; a") }
+    assert_nothing_raised { eval("a = 1; @cls[a => a]; a") }
   end
 
   def test_recursive_key
-    h = {}
+    h = @cls[]
     assert_nothing_raised { h[h] = :foo }
     h.rehash
     assert_equal(:foo, h[h])
@@ -974,7 +977,7 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_hash.rb#L977
 
   def test_inverse_hash
     feature4262 = '[ruby-core:34334]'
-    [{1=>2}, {123=>"abc"}].each do |h|
+    [@cls[1=>2], @cls[123=>"abc"]].each do |h|
       assert_not_equal(h.hash, h.invert.hash, feature4262)
     end
   end

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r42242


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

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