mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-15 07:23:19 -04:00
Evaluated each assert line without a replacement test specified.
This commit is contained in:
@@ -3,8 +3,8 @@ require File.expand_path(File.dirname(__FILE__) + '/edgecase')
|
||||
class AboutHashes < EdgeCase::Koan
|
||||
def test_creating_hashes
|
||||
empty_hash = Hash.new
|
||||
assert_equal Hash, empty_hash.class
|
||||
assert_equal({}, empty_hash)
|
||||
assert_equal __(Hash), empty_hash.class
|
||||
assert_equal({}, empty_hash) # __
|
||||
assert_equal __(0), empty_hash.size
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ class AboutHashes < EdgeCase::Koan
|
||||
hash[:one] = "eins"
|
||||
|
||||
expected = { :one => __("eins"), :two => "dos" }
|
||||
assert_equal expected, hash
|
||||
assert_equal __(true), expected == hash
|
||||
|
||||
# Bonus Question: Why was "expected" broken out into a variable
|
||||
# rather than used as a literal?
|
||||
@@ -35,7 +35,7 @@ class AboutHashes < EdgeCase::Koan
|
||||
hash1 = { :one => "uno", :two => "dos" }
|
||||
hash2 = { :two => "dos", :one => "uno" }
|
||||
|
||||
assert_equal hash1, hash2
|
||||
assert_equal __(true), hash1 == hash2
|
||||
end
|
||||
|
||||
def test_hash_keys
|
||||
@@ -43,7 +43,7 @@ class AboutHashes < EdgeCase::Koan
|
||||
assert_equal __(2), hash.keys.size
|
||||
assert_equal __(true), hash.keys.include?(:one)
|
||||
assert_equal __(true), hash.keys.include?(:two)
|
||||
assert_equal Array, hash.keys.class
|
||||
assert_equal __(Array), hash.keys.class
|
||||
end
|
||||
|
||||
def test_hash_values
|
||||
@@ -51,16 +51,16 @@ class AboutHashes < EdgeCase::Koan
|
||||
assert_equal __(2), hash.values.size
|
||||
assert_equal __(true), hash.values.include?("uno")
|
||||
assert_equal __(true), hash.values.include?("dos")
|
||||
assert_equal Array, hash.values.class
|
||||
assert_equal __(Array), hash.values.class
|
||||
end
|
||||
|
||||
def test_combining_hashes
|
||||
hash = { "jim" => 53, "amy" => 20, "dan" => 23 }
|
||||
new_hash = hash.merge({ "jim" => 54, "jenny" => 26 })
|
||||
|
||||
assert_not_equal hash, new_hash
|
||||
|
||||
assert_equal __(true), hash != new_hash
|
||||
|
||||
expected = { "jim" => __(54), "amy" => 20, "dan" => 23, "jenny" => __(26) }
|
||||
assert_equal expected, new_hash
|
||||
assert_equal __(true), expected == new_hash
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user