Apply PIE to nghttpx
[platform/upstream/nghttp2.git] / third-party / mruby / mrbgems / mruby-symbol-ext / test / symbol.rb
1 # coding: utf-8
2 ##
3 # Symbol(Ext) Test
4
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
10   end
11 end
12
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 "あ".size == 1  # enable MRB_UTF8_STRING?
18       assert_equal 8, :"こんにちは世界!".__send__(n)
19       assert_equal 4, :"aあ\0b".__send__(n)
20     else
21       assert_equal 22, :"こんにちは世界!".__send__(n)
22       assert_equal 6, :"aあ\0b".__send__(n)
23     end
24   end
25 end
26
27 assert("Symbol#capitalize") do
28   assert_equal :Hello, :hello.capitalize
29   assert_equal :Hello, :HELLO.capitalize
30   assert_equal :Hello, :Hello.capitalize
31 end
32
33 assert("Symbol#downcase") do
34   assert_equal :hello, :hEllO.downcase
35   assert_equal :hello, :hello.downcase
36 end
37
38 assert("Symbol#upcase") do
39   assert_equal :HELLO, :hEllO.upcase
40   assert_equal :HELLO, :HELLO.upcase
41 end
42
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")
48 end
49
50 assert("Symbol#empty?") do
51   assert_true :''.empty?
52 end
53
54 assert('Symbol#intern') do
55   assert_equal :test, :test.intern
56 end