summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorKOBAYASHI Shuji <[email protected]>2019-09-19 20:19:38 +0900
committerKOBAYASHI Shuji <[email protected]>2019-09-19 20:19:38 +0900
commite61095426bbb0de2ab0a941f9ed3a3acdb7833e8 (patch)
tree4a3407a71aca45350dd0e93481cc018a9bac8c23 /test
parent77f00d500675b54348f517ec7f8419785385eeec (diff)
downloadmruby-e61095426bbb0de2ab0a941f9ed3a3acdb7833e8.tar.gz
mruby-e61095426bbb0de2ab0a941f9ed3a3acdb7833e8.zip
Simplify arguments check in `String#index`
Also fix document about type of the first argument.
Diffstat (limited to 'test')
-rw-r--r--test/t/string.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/t/string.rb b/test/t/string.rb
index c820bfa92..01f3da327 100644
--- a/test/t/string.rb
+++ b/test/t/string.rb
@@ -451,12 +451,16 @@ assert('String#index', '15.2.10.5.22') do
assert_equal 3, 'abcabc'.index('a', 1)
assert_equal 5, "hello".index("", 5)
assert_equal nil, "hello".index("", 6)
+ assert_equal 3, "hello".index("l", -2)
+ assert_raise(ArgumentError) { "hello".index }
+ assert_raise(TypeError) { "hello".index(101) }
end
assert('String#index(UTF-8)', '15.2.10.5.22') do
assert_equal 0, '⓿➊➋➌➍➎'.index('⓿')
assert_nil '⓿➊➋➌➍➎'.index('➓')
assert_equal 6, '⓿➊➋➌➍➎⓿➊➋➌➍➎'.index('⓿', 1)
+ assert_equal 6, '⓿➊➋➌➍➎⓿➊➋➌➍➎'.index('⓿', -7)
assert_equal 6, "⓿➊➋➌➍➎".index("", 6)
assert_equal nil, "⓿➊➋➌➍➎".index("", 7)
assert_equal 0, '⓿➊➋➌➍➎'.index("\xe2")