diff options
| author | Daniel Bovensiepen <[email protected]> | 2012-11-01 16:12:57 +0800 |
|---|---|---|
| committer | Daniel Bovensiepen <[email protected]> | 2012-11-01 16:12:57 +0800 |
| commit | cdb72a05a294eb8521dd40c011160228496312cb (patch) | |
| tree | 283586ad23f2dc6dfd1fd1aaa354f18c23d8c0d6 /test | |
| parent | 88dfaf19aa0808f78d13133d61ea433d043923f9 (diff) | |
| parent | 57910ca5353e1feba1fb069a876b84a52f33d39f (diff) | |
| download | mruby-cdb72a05a294eb8521dd40c011160228496312cb.tar.gz mruby-cdb72a05a294eb8521dd40c011160228496312cb.zip | |
Merge remote-tracking branch 'upstream/master' into mrbgems
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/array.rb | 19 | ||||
| -rw-r--r-- | test/t/exception.rb | 20 | ||||
| -rw-r--r-- | test/t/kernel.rb | 10 | ||||
| -rw-r--r-- | test/t/localjumperror.rb | 7 | ||||
| -rw-r--r-- | test/t/runtimeerror.rb | 10 |
5 files changed, 52 insertions, 14 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 diff --git a/test/t/exception.rb b/test/t/exception.rb index 76c165e95..aa707c1b1 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -30,7 +30,7 @@ end assert('Exception#to_s', '15.2.22.5.3') do e = Exception.exception('a') - + e.to_s == 'a' end @@ -269,6 +269,24 @@ assert('Exception 14') do a == :ok end +assert('Exception 15') do + a = begin + :ok + rescue + :ng + end + a == :ok +end + +assert('Exception 16') do + begin + raise "foo" + false + rescue => e + e.message == "foo" + end +end + assert('Exception#inspect without message') do Exception.new.inspect end diff --git a/test/t/kernel.rb b/test/t/kernel.rb index fb0aee310..5caa3d7ac 100644 --- a/test/t/kernel.rb +++ b/test/t/kernel.rb @@ -204,6 +204,16 @@ assert('Kernel#extend', '15.3.1.3.13') do a.respond_to?(:test_method) == true && b.respond_to?(:test_method) == false end +assert('Kernel#extend works on toplevel', '15.3.1.3.13') do + module Test4ExtendModule + def test_method; end + end + # This would crash... + extend(Test4ExtendModule) + + respond_to?(:test_method) == true +end + assert('Kernel#global_variables', '15.3.1.3.14') do global_variables.class == Array end diff --git a/test/t/localjumperror.rb b/test/t/localjumperror.rb index 9d1df9594..ebcec0670 100644 --- a/test/t/localjumperror.rb +++ b/test/t/localjumperror.rb @@ -2,7 +2,12 @@ # LocalJumpError ISO Test assert('LocalJumoError', '15.2.25') do - LocalJumpError.class == Class + begin + # this will cause an exception due to the wrong location + retry + rescue => e1 + end + LocalJumpError.class == Class and e1.class == LocalJumpError end # TODO 15.2.25.2.1 LocalJumpError#exit_value diff --git a/test/t/runtimeerror.rb b/test/t/runtimeerror.rb index 9157293cd..3e0636186 100644 --- a/test/t/runtimeerror.rb +++ b/test/t/runtimeerror.rb @@ -2,13 +2,5 @@ # RuntimeError ISO Test assert('RuntimeError', '15.2.28') do - e2 = nil - begin - # this will cause an exception due to the wrong location - retry - rescue => e1 - e2 = e1 - end - - RuntimeError.class == Class and e2.class == RuntimeError + RuntimeError.class == Class end |
