diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-20 16:46:42 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-21 00:03:07 +0900 |
| commit | c0ae8a96a1fb658b21428bee174602e9373eef3b (patch) | |
| tree | 0ec2379d2e025a6016090fa805665e864081aebd /mrbgems/mruby-string-ext/test | |
| parent | 58ba38fe1e11828190596b44e0789dd8a0607ff3 (diff) | |
| download | mruby-c0ae8a96a1fb658b21428bee174602e9373eef3b.tar.gz mruby-c0ae8a96a1fb658b21428bee174602e9373eef3b.zip | |
Add `String#tr_s` and `String#tr_s!`; ref #4086
Diffstat (limited to 'mrbgems/mruby-string-ext/test')
| -rw-r--r-- | mrbgems/mruby-string-ext/test/string.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb index 6b8a89c4d..d50a2b3b4 100644 --- a/mrbgems/mruby-string-ext/test/string.rb +++ b/mrbgems/mruby-string-ext/test/string.rb @@ -160,6 +160,19 @@ assert('String#tr!') do assert_equal "ab12222hijklmnopqR", s end +assert('String#tr_s') do + assert_equal "hero", "hello".tr_s('l', 'r') + assert_equal "h*o", "hello".tr_s('el', '*') + assert_equal "hhxo", "hello".tr_s('el', 'hx') +end + +assert('String#tr_s!') do + s = "hello" + assert_equal "hero", s.tr_s!('l', 'r') + assert_equal "hero", s + assert_nil s.tr_s!('l', 'r') +end + assert('String#start_with?') do assert_true "hello".start_with?("heaven", "hell") assert_true !"hello".start_with?("heaven", "paradise") |
