aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/ordered_hash_test.rb
diff options
context:
space:
mode:
authorBrian Abreu <brian@nutsonline.com>2009-06-24 10:51:20 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-02 12:01:05 -0700
commitd03689971758b905fa0087bc93cf474a9d0585f5 (patch)
tree44fe5107872eb2527e9bc40cdf7e52106cbacf1d /activesupport/test/ordered_hash_test.rb
parente61afed6f8d2ef6a580ba00a5beaaaf0bf2ddb9a (diff)
downloadrails-d03689971758b905fa0087bc93cf474a9d0585f5.tar.gz
rails-d03689971758b905fa0087bc93cf474a9d0585f5.tar.bz2
rails-d03689971758b905fa0087bc93cf474a9d0585f5.zip
Fixed ActiveSupport::OrderedHash::[] work identically to ::Hash::[] in ruby 1.8.7 [#2832 state:resolved]
Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
Diffstat (limited to 'activesupport/test/ordered_hash_test.rb')
-rw-r--r--activesupport/test/ordered_hash_test.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb
index 647938dd87..15bd57181f 100644
--- a/activesupport/test/ordered_hash_test.rb
+++ b/activesupport/test/ordered_hash_test.rb
@@ -163,9 +163,32 @@ class OrderedHashTest < Test::Unit::TestCase
assert @ordered_hash.inspect.include?(@hash.inspect)
end
- def test_alternate_initialization
+ def test_alternate_initialization_with_splat
alternate = ActiveSupport::OrderedHash[1,2,3,4]
assert_kind_of ActiveSupport::OrderedHash, alternate
assert_equal [1, 3], alternate.keys
end
+
+ def test_alternate_initialization_with_array
+ alternate = ActiveSupport::OrderedHash[ [
+ [1, 2],
+ [3, 4],
+ "bad key value pair",
+ [ 'missing value' ]
+ ]]
+
+ assert_kind_of ActiveSupport::OrderedHash, alternate
+ assert_equal [1, 3, 'missing value'], alternate.keys
+ assert_equal [2, 4, nil ], alternate.values
+ end
+
+ def test_alternate_initialization_raises_exception_on_odd_length_args
+ begin
+ alternate = ActiveSupport::OrderedHash[1,2,3,4,5]
+ flunk "Hash::[] should have raised an exception on initialization " +
+ "with an odd number of parameters"
+ rescue
+ assert_equal "odd number of arguments for Hash", $!.message
+ end
+ end
end