1 #!/usr/bin/env ruby 2 # 3 # Put description here 4 # 5 # 6 # 7 # 8 # 9 10 require 'swig_assert' 11 require 'abstract_signature' 12 13 include Abstract_signature 14 15 # 16 # Shouldn't be able to instantiate Abstract_foo, because it declares 17 # a pure virtual function. 18 # 19 20 exceptionRaised = false 21 begin 22 foo = Abstract_foo.new 23 begin 24 foo.meth(1) 25 rescue RuntimeError 26 # here we are using directors 27 exceptionRaised = true 28 end 29 rescue NameError 30 exceptionRaised = true 31 rescue TypeError 32 # In Ruby 1.8 the exception raised is: 33 # TypeError: allocator undefined for Abstract_signature::Abstract_foo 34 exceptionRaised = true 35 ensure 36 swig_assert( "exceptionRaised", binding) 37 end 38 39 # 40 # Shouldn't be able to instantiate an Abstract_bar either, because it doesn't 41 # implement the pure virtual function with the correct signature. 42 # 43 44 exceptionRaised = false 45 begin 46 bar = Abstract_bar.new 47 begin 48 bar.meth(1) 49 rescue RuntimeError 50 # here we are using directors 51 exceptionRaised = true 52 end 53 rescue NameError 54 exceptionRaised = true 55 rescue TypeError 56 # In Ruby 1.8 the exception raised is: 57 # TypeError: allocator undefined for Abstract_signature::Abstract_bar 58 exceptionRaised = true 59 ensure 60 swig_assert( "exceptionRaised", binding) 61 end 62