"Fossies" - the Fresh Open Source Software Archive

Member "swig-4.1.1/Examples/test-suite/ruby/abstract_inherit_runme.rb" (30 Nov 2022, 1137 Bytes) of package /linux/misc/swig-4.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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