summaryrefslogtreecommitdiffhomepage
path: root/test/t/array.rb
diff options
context:
space:
mode:
authorDaniel Bovensiepen <[email protected]>2012-05-29 01:20:46 +0800
committerDaniel Bovensiepen <[email protected]>2012-05-29 01:20:46 +0800
commit31e9705022d585d818a5c869f0f91e4d6b7c252e (patch)
tree1f9abea740912054841872ff585778cd6d4abaa5 /test/t/array.rb
parentec3944d9c05fc5553469375661dbdaba42a57303 (diff)
downloadmruby-31e9705022d585d818a5c869f0f91e4d6b7c252e.tar.gz
mruby-31e9705022d585d818a5c869f0f91e4d6b7c252e.zip
Add Test cases for Literals, Enumeration, Exceptions and clean line endings
Diffstat (limited to 'test/t/array.rb')
-rw-r--r--test/t/array.rb42
1 files changed, 38 insertions, 4 deletions
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
-
-