1 require File.expand_path(File.dirname(__FILE__) + '/edgecase')
3 class AboutSymbols < EdgeCase::Koan
4 def test_symbols_are_symbols
6 assert_equal __, symbol.is_a?(Symbol)
9 def test_symbols_are_not_strings
11 assert_equal __, symbol.is_a?(String)
12 assert_equal __, symbol.eql?("ruby")
15 def test_symbols_have_unique_identity
18 symbol3 = :something_else
24 def test_identical_symbols_are_represented_by_a_single_internal_object
28 assert symbol1.equal?(__)
29 assert_equal __, symbol2.object_id
32 def test_method_names_become_symbols
33 all_symbols = Symbol.all_symbols
35 assert_equal __, all_symbols.include?(:test_method_names_are_symbols)
38 RubyConstant = "This string is assigned to a constant."
39 def test_constants_become_symbols
40 all_symbols = Symbol.all_symbols
42 assert_equal true, all_symbols.include?(__)
45 def test_symbols_can_be_made_from_strings
46 string = "catsAndDogs"
47 assert_equal __, string.to_sym
50 def test_symbols_with_spaces_can_be_built
51 symbol = :"cats and dogs"
53 assert_equal symbol, __.to_sym
56 def test_interpolated_symbols_become_strings
58 string = "It is raining #{symbol} and dogs."
60 assert_equal __, string
63 def test_symbols_cannot_be_concatenated