Unverified Commit 0b5e1550 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4587 from shuujii/fix-String-aref-test

Fix `String#[]` test
parents 626c2146 9d2272ec
...@@ -45,44 +45,27 @@ assert('String#*', '15.2.10.5.5') do ...@@ -45,44 +45,27 @@ assert('String#*', '15.2.10.5.5') do
assert_raise(TypeError) { 'a' * '1' } assert_raise(TypeError) { 'a' * '1' }
assert_raise(TypeError) { 'a' * nil } assert_raise(TypeError) { 'a' * nil }
end end
assert('String#[]', '15.2.10.5.6') do assert('String#[]', '15.2.10.5.6') do
# length of args is 1 # length of args is 1
a = 'abc'[0] assert_equal 'a', 'abc'[0]
b = 'abc'[-1] assert_equal 'c', 'abc'[-1]
c = 'abc'[10] assert_nil 'abc'[10]
d = 'abc'[-10] assert_nil 'abc'[-10]
e = 'abc'[1.1] assert_equal 'b', 'abc'[1.1] if Object.const_defined?(:Float)
# length of args is 2 # length of args is 2
a1 = 'abc'[0, -1] assert_nil 'abc'[0, -1]
b1 = 'abc'[10, 0] assert_nil 'abc'[10, 0]
c1 = 'abc'[-10, 0] assert_nil 'abc'[-10, 0]
d1 = 'abc'[0, 0] assert_equal '', 'abc'[0, 0]
e1 = 'abc'[1, 2] assert_equal 'bc', 'abc'[1, 2]
# args is RegExp
# It will be tested in mrbgems.
# args is String # args is String
a3 = 'abc'['bc'] assert_equal 'bc', 'abc'['bc']
b3 = 'abc'['XX'] assert_nil 'abc'['XX']
assert_equal 'a', 'a' assert_raise(TypeError) { 'abc'[nil] }
# assert_equal 'c', b
# assert_nil c
# assert_nil d
# assert_equal 'b', e
# assert_nil a1
# assert_nil b1
# assert_nil c1
# assert_equal '', d1
# assert_equal 'bc', e1
# assert_equal 'bc', a3
# assert_nil b3
# assert_raise(TypeError) do
# a[nil]
# end
end end
assert('String#[](UTF-8)', '15.2.10.5.6') do assert('String#[](UTF-8)', '15.2.10.5.6') do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment