/trunk/Examples/test-suite/ruby/abstract_inherit_ok_runme.rb
Ruby | 48 lines | 22 code | 8 blank | 18 comment | 1 complexity | eae33d13eeca020dfb3bbc2de2905b19 MD5 | raw file
1#!/usr/bin/env ruby 2# 3# Put description here 4# 5# 6# 7# 8# 9 10require 'swig_assert' 11 12require 'abstract_inherit_ok' 13 14include Abstract_inherit_ok 15 16# 17# Shouldn't be able to instantiate Foo, because it declares 18# a pure virtual function. 19# 20 21exceptionRaised = false 22begin 23 Foo.new 24rescue NameError 25 exceptionRaised = true 26rescue TypeError 27 # In Ruby 1.8 the exception raised is: 28 # TypeError: allocator undefined for Abstract_inherit_ok::Foo 29 exceptionRaised = true 30ensure 31 swig_assert( "exceptionRaised", binding ) 32end 33 34# 35# This one's OK since we cleared it with a %feature("notabstract") 36# declaration in the interface file. 37# 38 39exceptionRaised = false 40begin 41 spam = Spam.new 42 raise RuntimeError unless spam.blah == 0 43rescue NameError 44 exceptionRaised = true 45ensure 46 swig_assert( "!exceptionRaised", binding ) 47end 48