PageRenderTime 21ms CodeModel.GetById 2ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/ruby/director_exception_runme.rb

#
Ruby | 70 lines | 43 code | 19 blank | 8 comment | 0 complexity | 26091190ec9a60e58c0c210a415ec66f MD5 | raw file
 1#!/usr/bin/env ruby
 2#
 3# Put description here
 4#
 5# 
 6# 
 7# 
 8#
 9
10require 'swig_assert'
11
12require 'director_exception'
13
14include Director_exception
15
16class MyFoo < Foo
17  def ping
18    raise NotImplementedError, "MyFoo::ping() EXCEPTION"
19  end
20end
21
22class MyFoo2 < Foo
23  def ping
24    nil # error: should return a string
25  end
26end
27
28class MyFoo3 < Foo
29  def ping
30    5 # error: should return a string
31  end
32end
33
34ok = false
35
36a = MyFoo.new
37b = launder(a)
38
39begin
40  b.pong
41rescue NotImplementedError
42  ok = true
43end
44
45raise RuntimeError unless ok
46
47ok = false
48
49a = MyFoo2.new
50b = launder(a)
51
52begin
53  b.pong
54rescue TypeError
55  ok = true
56end
57
58
59a = MyFoo3.new
60b = launder(a)
61
62begin
63  b.pong
64rescue TypeError
65  ok = true
66end
67
68
69raise RuntimeError unless ok
70