summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-symbol-ext/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-02-04 21:11:06 +0900
committerGitHub <[email protected]>2019-02-04 21:11:06 +0900
commitdb2545cb3c61f55702be2abe8836b5190effa9c5 (patch)
tree4b3cfd9dbed6bfb7eac0e92b524d5dd02cd284ab /mrbgems/mruby-symbol-ext/test
parent5fd9f68b2735d6c104c9945e374ff28309af7a39 (diff)
parent69fd1a592560d321061790c94f93532db93dccb9 (diff)
downloadmruby-db2545cb3c61f55702be2abe8836b5190effa9c5.tar.gz
mruby-db2545cb3c61f55702be2abe8836b5190effa9c5.zip
Merge pull request #4260 from shuujii/fix-symbol-size-with-mrb_utf8_string
Fix `Symbol#size` for multi-byte characters with `MRB_UTF8_STRING`
Diffstat (limited to 'mrbgems/mruby-symbol-ext/test')
-rw-r--r--mrbgems/mruby-symbol-ext/test/symbol.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/mrbgems/mruby-symbol-ext/test/symbol.rb b/mrbgems/mruby-symbol-ext/test/symbol.rb
index 63c1bd826..2c7a62b0c 100644
--- a/mrbgems/mruby-symbol-ext/test/symbol.rb
+++ b/mrbgems/mruby-symbol-ext/test/symbol.rb
@@ -7,9 +7,18 @@ assert('Symbol.all_symbols') do
assert_equal foo, symbols
end
-assert("Symbol#length") do
- assert_equal 5, :hello.size
- assert_equal 5, :mruby.length
+%w[size length].each do |n|
+ assert("Symbol##{n}") do
+ assert_equal 5, :hello.__send__(n)
+ assert_equal 4, :"aA\0b".__send__(n)
+ if "あ".size == 1 # enable MRB_UTF8_STRING?
+ assert_equal 8, :"こんにちは世界!".__send__(n)
+ assert_equal 4, :"aあ\0b".__send__(n)
+ else
+ assert_equal 22, :"こんにちは世界!".__send__(n)
+ assert_equal 6, :"aあ\0b".__send__(n)
+ end
+ end
end
assert("Symbol#capitalize") do