diff options
| author | KOBAYASHI Shuji <[email protected]> | 2019-09-27 17:13:57 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2019-09-27 17:13:57 +0900 |
| commit | 198683e914ebaceba7b989c6592f871ac8fe5aa0 (patch) | |
| tree | 4509b1abb749126a6927db8b30a253564974762a /test | |
| parent | 5cd6ed4511a0d8d5a19a0cd2beb4cdd97dc3eff5 (diff) | |
| download | mruby-198683e914ebaceba7b989c6592f871ac8fe5aa0.tar.gz mruby-198683e914ebaceba7b989c6592f871ac8fe5aa0.zip | |
Simplify arguments check in `String#rindex`
Also fix document about type of the first argument.
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/string.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/t/string.rb b/test/t/string.rb index 01f3da327..e1ff48312 100644 --- a/test/t/string.rb +++ b/test/t/string.rb @@ -554,9 +554,16 @@ end if UTF8STRING assert('String#rindex', '15.2.10.5.31') do assert_equal 0, 'abc'.rindex('a') + assert_equal 0, 'abc'.rindex('a', 3) + assert_nil 'abc'.rindex('a', -4) assert_nil 'abc'.rindex('d') + assert_equal 6, 'abcabc'.rindex('') + assert_equal 3, 'abcabc'.rindex('a') assert_equal 0, 'abcabc'.rindex('a', 1) assert_equal 3, 'abcabc'.rindex('a', 4) + assert_equal 0, 'abcabc'.rindex('a', -4) + assert_raise(ArgumentError) { "hello".rindex } + assert_raise(TypeError) { "hello".rindex(101) } end assert('String#rindex(UTF-8)', '15.2.10.5.31') do @@ -564,6 +571,7 @@ assert('String#rindex(UTF-8)', '15.2.10.5.31') do assert_nil str.rindex('さ') assert_equal 12, str.rindex('ち') assert_equal 3, str.rindex('ち', 10) + assert_equal 3, str.rindex('ち', -6) broken = "\xf0☀\xf1☁\xf2☂\xf3☃\xf0☀\xf1☁\xf2☂\xf3☃" assert_nil broken.rindex("\x81") # "\x81" is a part of "☁" ("\xe2\x98\x81") |
