From eafc4dd0afe0db26be0f5abce425af717552fa48 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Thu, 8 May 2014 00:17:17 +0900 Subject: Make Array#[]= raise IndexError. If second param is negative, Array#[] raise IndexError. --- test/t/array.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/t/array.rb') diff --git a/test/t/array.rb b/test/t/array.rb index 48f2fe0c4..56daf0b01 100644 --- a/test/t/array.rb +++ b/test/t/array.rb @@ -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)) -- cgit v1.2.3