source: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-error/test/exception.rb@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-ruby;charset=UTF-8
File size: 1.4 KB
Line 
1assert 'mrb_protect' do
2 # no failure in protect returns [result, false]
3 assert_equal ['test', false] do
4 ExceptionTest.mrb_protect { 'test' }
5 end
6 # failure in protect returns [exception, true]
7 result = ExceptionTest.mrb_protect { raise 'test' }
8 assert_kind_of RuntimeError, result[0]
9 assert_true result[1]
10end
11
12assert 'mrb_ensure' do
13 a = false
14 assert_equal 'test' do
15 ExceptionTest.mrb_ensure Proc.new { 'test' }, Proc.new { a = true }
16 end
17 assert_true a
18
19 a = false
20 assert_raise RuntimeError do
21 ExceptionTest.mrb_ensure Proc.new { raise 'test' }, Proc.new { a = true }
22 end
23 assert_true a
24end
25
26assert 'mrb_rescue' do
27 assert_equal 'test' do
28 ExceptionTest.mrb_rescue Proc.new { 'test' }, Proc.new {}
29 end
30
31 class CustomExp < Exception
32 end
33
34 assert_raise CustomExp do
35 ExceptionTest.mrb_rescue Proc.new { raise CustomExp.new 'test' }, Proc.new { 'rescue' }
36 end
37
38 assert_equal 'rescue' do
39 ExceptionTest.mrb_rescue Proc.new { raise 'test' }, Proc.new { 'rescue' }
40 end
41end
42
43assert 'mrb_rescue_exceptions' do
44 assert_equal 'test' do
45 ExceptionTest.mrb_rescue_exceptions Proc.new { 'test' }, Proc.new {}
46 end
47
48 assert_raise RangeError do
49 ExceptionTest.mrb_rescue_exceptions Proc.new { raise RangeError.new 'test' }, Proc.new { 'rescue' }
50 end
51
52 assert_equal 'rescue' do
53 ExceptionTest.mrb_rescue_exceptions Proc.new { raise TypeError.new 'test' }, Proc.new { 'rescue' }
54 end
55end
Note: See TracBrowser for help on using the repository browser.