"Fossies" - the Fresh Open Source Software Archive

Member "swig-4.1.1/Examples/test-suite/ruby/abstract_signature_runme.rb" (30 Nov 2022, 1229 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 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