Make Array#[]= raise IndexError.

If second param is negative, Array#[] raise IndexError.
This commit is contained in:
yui-knk
2014-05-08 00:17:17 +09:00
parent 09b9c7762d
commit eafc4dd0af
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -66,6 +66,11 @@ assert('Array#[]=', '15.2.12.5.5') do
# this will cause an exception due to the wrong arguments
a.[]=(1,2,3,4)
end
assert_raise(IndexError) do
# this will cause an exception due to the wrong arguments
a = [1,2,3,4,5]
a[1, -1] = 10
end
assert_equal(4, [1,2,3].[]=(1,4))
assert_equal(3, [1,2,3].[]=(1,2,3))