5 if Symbol.respond_to?(:all_symbols)
6 assert('Symbol.all_symbols') do
7 foo = [:__symbol_test_1, :__symbol_test_2, :__symbol_test_3].sort
8 symbols = Symbol.all_symbols.select{|sym|sym.to_s.include? '__symbol_test'}.sort
9 assert_equal foo, symbols
13 %w[size length].each do |n|
14 assert("Symbol##{n}") do
15 assert_equal 5, :hello.__send__(n)
16 assert_equal 4, :"aA\0b".__send__(n)
17 if __ENCODING__ == "UTF-8"
18 assert_equal 8, :"こんにちは世界!".__send__(n)
19 assert_equal 4, :"aあ\0b".__send__(n)
21 assert_equal 22, :"こんにちは世界!".__send__(n)
22 assert_equal 6, :"aあ\0b".__send__(n)
27 assert("Symbol#capitalize") do
28 assert_equal :Hello, :hello.capitalize
29 assert_equal :Hello, :HELLO.capitalize
30 assert_equal :Hello, :Hello.capitalize
33 assert("Symbol#downcase") do
34 assert_equal :hello, :hEllO.downcase
35 assert_equal :hello, :hello.downcase
38 assert("Symbol#upcase") do
39 assert_equal :HELLO, :hEllO.upcase
40 assert_equal :HELLO, :HELLO.upcase
43 assert("Symbol#casecmp") do
44 assert_equal 0, :HELLO.casecmp(:hEllO)
45 assert_equal 1, :HELLO.casecmp(:hEllN)
46 assert_equal(-1, :HELLO.casecmp(:hEllP))
47 assert_nil :HELLO.casecmp("hEllO")
50 assert("Symbol#empty?") do
51 assert_true :''.empty?
54 assert('Symbol#intern') do
55 assert_equal :test, :test.intern