summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-09-20 08:02:14 +0900
committerGitHub <[email protected]>2019-09-20 08:02:14 +0900
commit21c0c78d2e48f32e757fc44381c3bbc9706cec98 (patch)
tree4a3407a71aca45350dd0e93481cc018a9bac8c23 /test
parent77f00d500675b54348f517ec7f8419785385eeec (diff)
parente61095426bbb0de2ab0a941f9ed3a3acdb7833e8 (diff)
downloadmruby-21c0c78d2e48f32e757fc44381c3bbc9706cec98.tar.gz
mruby-21c0c78d2e48f32e757fc44381c3bbc9706cec98.zip
Merge pull request #4722 from shuujii/simplify-arguments-check-in-String-index
Simplify arguments check in `String#index`
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")