import source from 1.3.40
[external/swig.git] / Examples / test-suite / ruby / abstract_inherit_runme.rb
1 #!/usr/bin/env ruby
2 #
3 # Put description here
4 #
5
6
7
8 #
9
10 require 'swig_assert'
11
12 require 'abstract_inherit'
13
14 include Abstract_inherit
15
16 #
17 # Shouldn't be able to instantiate any of these classes
18 # since none of them implements the pure virtual function
19 # declared in the base class (Foo).
20 #
21
22 exceptionRaised = false
23 begin
24   Foo.new
25 rescue NameError
26   exceptionRaised = true
27 rescue TypeError
28   # In Ruby 1.8 the exception raised is:
29   # TypeError: allocator undefined for Abstract_inherit::Foo
30         exceptionRaised = true
31 ensure
32   swig_assert( "exceptionRaised", binding )
33 end
34
35 exceptionRaised = false
36 begin
37   Bar.new
38 rescue NameError
39   exceptionRaised = true
40 rescue TypeError
41   # In Ruby 1.8 the exception raised is:
42   # TypeError: allocator undefined for Abstract_inherit::Bar
43         exceptionRaised = true
44 ensure
45   swig_assert( "exceptionRaised", binding )
46 end
47
48 exceptionRaised = false
49 begin
50   Spam.new
51 rescue NameError
52   exceptionRaised = true
53 rescue TypeError
54   # In Ruby 1.8 the exception raised is:
55   # TypeError: allocator undefined for Abstract_inherit::Spam
56         exceptionRaised = true
57 ensure
58   swig_assert( "exceptionRaised", binding )
59 end
60
61