aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorAndrew Radev <andrey.radev@gmail.com>2011-05-27 14:04:39 +0300
committerAndrew Radev <andrey.radev@gmail.com>2011-05-27 14:04:39 +0300
commitc9cc36bde9f779c917171e7c378285b57f748414 (patch)
tree7cafd42a31275b177367545aa2a378ae9283dffb /activesupport/test
parentd1c74706c35b0b17b22c4b2541353d1b9ac6bfa5 (diff)
downloadrails-c9cc36bde9f779c917171e7c378285b57f748414.tar.gz
rails-c9cc36bde9f779c917171e7c378285b57f748414.tar.bz2
rails-c9cc36bde9f779c917171e7c378285b57f748414.zip
Fixes minor ruby 1.8 inconsistency
ActiveSupport::OrderedHash did not behave identically to Hash when given a block with a splat.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/ordered_hash_test.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb
index f3dcd7b068..bf851dbcbc 100644
--- a/activesupport/test/ordered_hash_test.rb
+++ b/activesupport/test/ordered_hash_test.rb
@@ -114,6 +114,9 @@ class OrderedHashTest < Test::Unit::TestCase
end
assert_equal @values, values
assert_equal @keys, keys
+
+ expected_class = RUBY_VERSION < '1.9' ? Enumerable::Enumerator : Enumerator
+ assert_kind_of expected_class, @ordered_hash.each_pair
end
def test_find_all
@@ -257,6 +260,26 @@ class OrderedHashTest < Test::Unit::TestCase
assert_equal @values, values
end
+ def test_each_when_yielding_to_block_with_splat
+ hash_values = []
+ ordered_hash_values = []
+
+ @hash.each { |*v| hash_values << v }
+ @ordered_hash.each { |*v| ordered_hash_values << v }
+
+ assert_equal hash_values.sort, ordered_hash_values.sort
+ end
+
+ def test_each_pair_when_yielding_to_block_with_splat
+ hash_values = []
+ ordered_hash_values = []
+
+ @hash.each_pair { |*v| hash_values << v }
+ @ordered_hash.each_pair { |*v| ordered_hash_values << v }
+
+ assert_equal hash_values.sort, ordered_hash_values.sort
+ end
+
def test_order_after_yaml_serialization
@deserialized_ordered_hash = YAML.load(YAML.dump(@ordered_hash))