summaryrefslogtreecommitdiffhomepage
path: root/test/t/string.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/t/string.rb')
-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")