diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-09-30 06:10:36 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-09-30 06:10:36 -0700 |
| commit | 72bcf7ee01cdbf513300b08eb771abdb6aae6fb0 (patch) | |
| tree | c50a8c37e128f91ca1d23bcfb6d182bfa7b8f55a /test/t | |
| parent | be8f3909f7db027441283fe26cb03ae807d9ced3 (diff) | |
| parent | 5c2afd239c527be5d4117dfaea14902450937ac3 (diff) | |
| download | mruby-72bcf7ee01cdbf513300b08eb771abdb6aae6fb0.tar.gz mruby-72bcf7ee01cdbf513300b08eb771abdb6aae6fb0.zip | |
Merge pull request #483 from akuroda/array_test
add test cases for Array
Diffstat (limited to 'test/t')
| -rw-r--r-- | test/t/array.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/t/array.rb b/test/t/array.rb index cb99cea6a..560faf8e7 100644 --- a/test/t/array.rb +++ b/test/t/array.rb @@ -14,7 +14,17 @@ assert('Array.[]', '15.2.12.4.1') do end assert('Array#*', '15.2.12.5.1') do - [1].*(3) == [1, 1, 1] + e2 = nil + begin + # this will cause an exception due to the wrong argument + [1].*(-1) + rescue => e1 + e2 = e1 + end + a = [1].*(3) + b = [1].*(0) + a == [1, 1, 1] and b == [] and + e2.class == ArgumentError end assert('Array#+', '15.2.12.5.2') do @@ -256,8 +266,10 @@ end assert('Array#unshift', '15.2.12.5.30') do a = [2,3] b = a.unshift(1) + c = [2,3] + d = c.unshift(0, 1) - a == [1,2,3] and b == [1,2,3] + a == [1,2,3] and b == [1,2,3] and c == [0,1,2,3] and d == [0,1,2,3] end assert('Array#to_s', '15.2.12.5.31') do @@ -279,8 +291,9 @@ end assert('Array#<=>', '15.2.12.5.36') do r1 = [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1 r2 = [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1 + r3 = [ "a", "b", "c" ] <=> [ "a", "b", "c" ] #=> 0 - r1 == -1 and r2 == +1 + r1 == -1 and r2 == +1 and r3 == 0 end # Not ISO specified |
