From 31e9705022d585d818a5c869f0f91e4d6b7c252e Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Tue, 29 May 2012 01:20:46 +0800 Subject: Add Test cases for Literals, Enumeration, Exceptions and clean line endings --- test/t/array.rb | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'test/t/array.rb') diff --git a/test/t/array.rb b/test/t/array.rb index 3b9dfedfb..dba1b035d 100644 --- a/test/t/array.rb +++ b/test/t/array.rb @@ -22,11 +22,47 @@ assert('Array#<<', '15.2.12.5.3') do end assert('Array#[]', '15.2.12.5.4') do - [1,2,3].[](1) == 2 + e2 = nil + e3 = nil + a = Array.new + begin + # this will cause an exception due to the wrong arguments + a.[]() + rescue => e1 + e2 = e1 + end + begin + # this will cause an exception due to the wrong arguments + a.[](1,2,3) + rescue => e1 + e3 = e1 + end + + [1,2,3].[](1) == 2 and + e2.class == ArgumentError and + e3.class == ArgumentError end assert('Array#[]=', '15.2.12.5.5') do - [1,2,3].[]=(1,4) == [1, 4, 3] + e2 = nil + e3 = nil + a = Array.new + begin + # this will cause an exception due to the wrong arguments + a.[]=() + rescue => e1 + e2 = e1 + end + begin + # this will cause an exception due to the wrong arguments + a.[]=(1,2,3,4) + rescue => e1 + e3 = e1 + end + + [1,2,3].[]=(1,4) == [1, 4, 3] and + e2.class == ArgumentError and + e3.class == ArgumentError end assert('Array#clear', '15.2.12.5.6') do @@ -193,5 +229,3 @@ assert('Array#unshift', '15.2.12.5.30') do end # Not ISO specified - - -- cgit v1.2.3