diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-05-28 15:46:10 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-05-28 15:46:10 -0700 |
| commit | 2d73abd84405b5096d367bd6654907ae5d9905dc (patch) | |
| tree | b0e0ecd589ae7bb58ac4805bf3c4e802fff85a5e /test/t/array.rb | |
| parent | ec3944d9c05fc5553469375661dbdaba42a57303 (diff) | |
| parent | b19575e5ac1e15c83797a0d8974bc4cc02b83fe6 (diff) | |
| download | mruby-2d73abd84405b5096d367bd6654907ae5d9905dc.tar.gz mruby-2d73abd84405b5096d367bd6654907ae5d9905dc.zip | |
Merge pull request #202 from bovi/add-docu
Add Test Cases (Literals, Enumerable, Exceptions, misc)
Diffstat (limited to 'test/t/array.rb')
| -rw-r--r-- | test/t/array.rb | 42 |
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 - - |
