Added symbol & string identity tests.

This commit is contained in:
Jim Weirich
2010-09-27 11:36:38 -04:00
parent fe2ee86172
commit ece35b2539
4 changed files with 20 additions and 4 deletions

View File

@@ -182,4 +182,12 @@ EOS
words = ["Now", "is", "the", "time"]
assert_equal __, words.join(" ")
end
def test_strings_are_not_unique_objects
a = "a string"
b = "a string"
assert_equal __, a == b
assert_equal __, a.object_id == b.object_id
end
end

View File

@@ -19,8 +19,8 @@ class AboutSymbols < EdgeCase::Koan
symbol1 = :a_symbol
symbol2 = :a_symbol
assert symbol1.equal?(__)
assert_equal __, symbol2.object_id
assert_equal __, symbol1 == symbol2
assert_equal __, symbol1.object_id == symbol2.object_id
end
def test_method_names_become_symbols

View File

@@ -182,4 +182,12 @@ EOS
words = ["Now", "is", "the", "time"]
assert_equal __("Now is the time"), words.join(" ")
end
def test_strings_are_not_unique_objects
a = "a string"
b = "a string"
assert_equal __(true), a == b
assert_equal __(false), a.object_id == b.object_id
end
end

View File

@@ -19,8 +19,8 @@ class AboutSymbols < EdgeCase::Koan
symbol1 = :a_symbol
symbol2 = :a_symbol
assert symbol1.equal?(__(symbol2))
assert_equal __(symbol1.object_id), symbol2.object_id
assert_equal __(true), symbol1 == symbol2
assert_equal __(true), symbol1.object_id == symbol2.object_id
end
def test_method_names_become_symbols