moar progress

This commit is contained in:
Adam Mohammed
2023-03-21 12:52:31 -04:00
parent 818436f4b4
commit 99308a541d
6 changed files with 67 additions and 67 deletions

View File

@@ -47,47 +47,47 @@ class AboutHashes < Neo::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
hash = { :one => "uno", :two => "dos" }
assert_equal __, hash.keys.size
assert_equal __, hash.keys.include?(:one)
assert_equal __, hash.keys.include?(:two)
assert_equal __, hash.keys.class
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
end
def test_hash_values
hash = { :one => "uno", :two => "dos" }
assert_equal __, hash.values.size
assert_equal __, hash.values.include?("uno")
assert_equal __, hash.values.include?("dos")
assert_equal __, hash.values.class
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
end
def test_combining_hashes
hash = { "jim" => 53, "amy" => 20, "dan" => 23 }
new_hash = hash.merge({ "jim" => 54, "jenny" => 26 })
assert_equal __, hash != new_hash
assert_equal true, hash != new_hash
expected = { "jim" => __, "amy" => 20, "dan" => 23, "jenny" => __ }
assert_equal __, expected == new_hash
expected = { "jim" => 54, "amy" => 20, "dan" => 23, "jenny" => 26 }
assert_equal true, expected == new_hash
end
def test_default_value
hash1 = Hash.new
hash1[:one] = 1
assert_equal __, hash1[:one]
assert_equal __, hash1[:two]
assert_equal 1, hash1[:one]
assert_equal nil, hash1[:two]
hash2 = Hash.new("dos")
hash2[:one] = 1
assert_equal __, hash2[:one]
assert_equal __, hash2[:two]
assert_equal 1, hash2[:one]
assert_equal "dos", hash2[:two]
end
def test_default_value_is_the_same_object
@@ -96,11 +96,11 @@ class AboutHashes < Neo::Koan
hash[:one] << "uno"
hash[:two] << "dos"
assert_equal __, hash[:one]
assert_equal __, hash[:two]
assert_equal __, hash[:three]
assert_equal ["uno", "dos"], hash[:one]
assert_equal ["uno", "dos"], hash[:two]
assert_equal ["uno", "dos"], hash[:three]
assert_equal __, hash[:one].object_id == hash[:two].object_id
assert_equal true, hash[:one].object_id == hash[:two].object_id
end
def test_default_value_with_block
@@ -109,8 +109,8 @@ class AboutHashes < Neo::Koan
hash[:one] << "uno"
hash[:two] << "dos"
assert_equal __, hash[:one]
assert_equal __, hash[:two]
assert_equal __, hash[:three]
assert_equal ["uno"], hash[:one]
assert_equal ["dos"], hash[:two]
assert_equal [], hash[:three]
end
end