From: Potapov Sergey Date: Mon, 7 Feb 2011 22:50:39 +0000 (+0200) Subject: Added test for Hash default value. Developers often forget about using it. X-Git-Url: https://git.eng.unimelb.edu.au/public?p=ruby_koans.git;a=commitdiff_plain;h=caceba4d233447f9aea0f1e8356bcc63de336d60 Added test for Hash default value. Developers often forget about using it. --- diff --git a/koans/about_hashes.rb b/koans/about_hashes.rb index 3e4e62c..2324b04 100644 --- a/koans/about_hashes.rb +++ b/koans/about_hashes.rb @@ -63,4 +63,18 @@ class AboutHashes < EdgeCase::Koan expected = { "jim" => __, "amy" => 20, "dan" => 23, "jenny" => __ } assert_equal __, expected == new_hash end + + def test_default_value + hash1 = Hash.new + hash1[:one] = 1 + + assert_equal __, hash1[:one] + assert_equal __, hash1[:two] + + hash2 = Hash.new("dos") + hash2[:one] = 1 + + assert_equal __, hash2[:one] + assert_equal __, hash2[:two] + end end