Added some runtime tests for ruby.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9693 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
928f12bd44
commit
5be075f16f
7 changed files with 255 additions and 0 deletions
34
Examples/test-suite/ruby/abstract_access_runme.rb
Executable file
34
Examples/test-suite/ruby/abstract_access_runme.rb
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put script description here.
|
||||
#
|
||||
# Author:: gga
|
||||
# Copyright:: 2007
|
||||
# License:: Ruby
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
require 'abstract_access'
|
||||
|
||||
include Abstract_access
|
||||
|
||||
begin
|
||||
a = A.new
|
||||
rescue TypeError
|
||||
swig_assert(true, 'A.new')
|
||||
end
|
||||
|
||||
begin
|
||||
b = B.new
|
||||
rescue TypeError
|
||||
swig_assert(true, 'B.new')
|
||||
end
|
||||
|
||||
begin
|
||||
c = C.new
|
||||
rescue TypeError
|
||||
swig_assert(true, 'C.new')
|
||||
end
|
||||
|
||||
swig_assert( 'D.new' )
|
||||
|
||||
35
Examples/test-suite/ruby/anonymous_bitfield_runme.rb
Executable file
35
Examples/test-suite/ruby/anonymous_bitfield_runme.rb
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put script description here.
|
||||
#
|
||||
# Author:: gga
|
||||
# Copyright:: 2007
|
||||
# License:: Ruby
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
require 'anonymous_bitfield'
|
||||
|
||||
include Anonymous_bitfield
|
||||
|
||||
foo = Foo.new
|
||||
|
||||
{'x' => 4,
|
||||
'y' => 3,
|
||||
'f' => 1,
|
||||
'z' => 8,
|
||||
'seq' => 3 }.each do |m, v|
|
||||
foo.send("#{m}=", v)
|
||||
val = foo.send(m)
|
||||
swig_assert(val == v, " for foo.#{m} == #{v}, was #{val}")
|
||||
end
|
||||
|
||||
{'x' => (1 << 4),
|
||||
'y' => (1 << 4),
|
||||
'f' => (1 << 1),
|
||||
'z' => (1 << 16),
|
||||
'seq' => (1 << (4*8-6)) }.each do |m, v|
|
||||
foo.send("#{m}=", v)
|
||||
val = foo.send(m)
|
||||
swig_assert(val != v, " for foo.#{m} != #{v}, was #{val}")
|
||||
end
|
||||
45
Examples/test-suite/ruby/apply_signed_char_runme.rb
Executable file
45
Examples/test-suite/ruby/apply_signed_char_runme.rb
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put script description here.
|
||||
#
|
||||
# Author:: gga
|
||||
# Copyright:: 2007
|
||||
# License:: Ruby
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
require 'apply_signed_char'
|
||||
|
||||
include Apply_signed_char
|
||||
|
||||
|
||||
['CharValFunction', 'CCharValFunction', 'CCharRefFunction'].each do |m|
|
||||
[ 3, -3 ].each do |v|
|
||||
val = send( m, v )
|
||||
swig_assert( v == val, "for #{m} #{val} == #{v} ")
|
||||
end
|
||||
end
|
||||
|
||||
{ 'globalchar' => -109,
|
||||
'globalconstchar' => -110,
|
||||
}.each do |k,v|
|
||||
val = Apply_signed_char.send( k )
|
||||
swig_assert( v == val, "for #{k} #{val} == #{v} ")
|
||||
end
|
||||
|
||||
|
||||
a = DirectorTest.new
|
||||
|
||||
['CharValFunction', 'CCharValFunction', 'CCharRefFunction'].each do |m|
|
||||
[ 3, -3 ].each do |v|
|
||||
val = a.send( m, v )
|
||||
swig_assert( v == val, "for DirectorTest.#{m} #{val} == #{v} ")
|
||||
end
|
||||
end
|
||||
|
||||
{ 'memberchar' => -111,
|
||||
'memberconstchar' => -112,
|
||||
}.each do |k,v|
|
||||
val = a.send( k )
|
||||
swig_assert( v == val, "for #{k} #{val} == #{v} ")
|
||||
end
|
||||
61
Examples/test-suite/ruby/apply_strings_runme.rb
Executable file
61
Examples/test-suite/ruby/apply_strings_runme.rb
Executable file
|
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put script description here.
|
||||
#
|
||||
# Author:: gga
|
||||
# Copyright:: 2007
|
||||
# License:: Ruby
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
require 'apply_strings'
|
||||
|
||||
include Apply_strings
|
||||
|
||||
begin
|
||||
x = UcharPtr.new
|
||||
swig_assert( fail, "UcharPtr should not be defined")
|
||||
rescue NameError
|
||||
end
|
||||
|
||||
ptr = 'a'
|
||||
['UCharFunction', 'SCharFunction', 'CUCharFunction',
|
||||
'CSCharFunction'].each do |m|
|
||||
val = Apply_strings.send(m, ptr)
|
||||
swig_assert( val == ptr, "Apply_strings.#{m} #{val} == #{ptr}" )
|
||||
end
|
||||
|
||||
|
||||
['CharFunction', 'CCharFunction'].each do |m|
|
||||
begin
|
||||
val = Apply_strings.send(m, ptr)
|
||||
swig_assert( false, "Apply_strings.#{m} should raise TypeError" )
|
||||
rescue TypeError
|
||||
end
|
||||
end
|
||||
|
||||
ptr = 'a'
|
||||
foo = DirectorTest.new
|
||||
['UCharFunction', 'SCharFunction', 'CUCharFunction',
|
||||
'CSCharFunction'].each do |m|
|
||||
val = foo.send(m, ptr)
|
||||
swig_assert( val == ptr, "DirectorTest.#{m} #{val} == #{ptr}" )
|
||||
end
|
||||
|
||||
|
||||
['CharFunction', 'CCharFunction'].each do |m|
|
||||
begin
|
||||
val = foo.send(m, ptr)
|
||||
swig_assert( false, "DirectorTest.#{m} should raise TypeError" )
|
||||
rescue TypeError
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# ary = Apply_strings.DigitsGlobalB
|
||||
# { 0 => 'A',
|
||||
# 1 => 'B',
|
||||
# 2 => 'B' }.each do |k,v|
|
||||
# val = ary[k]
|
||||
# swig_assert( val == v, "Apply_strings.DigitsGlobalB[#{k}] #{val} != #{v}")
|
||||
# end
|
||||
40
Examples/test-suite/ruby/argout_runme.rb
Executable file
40
Examples/test-suite/ruby/argout_runme.rb
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put script description here.
|
||||
#
|
||||
# Author::
|
||||
# Copyright::
|
||||
# License:: Ruby
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
require 'argout'
|
||||
|
||||
include Argout
|
||||
|
||||
t = new_intp
|
||||
intp_assign(t, 5)
|
||||
v = incp(t)
|
||||
swig_assert( v == 5, "incp - v == 5 was #{v}")
|
||||
val = intp_value(t)
|
||||
swig_assert( val == 6, "incp - intp_value(t) == 6 was #{val}")
|
||||
|
||||
t = new_intp
|
||||
intp_assign(t, 5)
|
||||
v = incr(t)
|
||||
swig_assert( v == 5, "incr - v == 5 was #{v}")
|
||||
val = intp_value(t)
|
||||
swig_assert( val == 6, "incr - intp_value(t) == 6 was #{val}")
|
||||
|
||||
t = new_intp
|
||||
intp_assign(t, 5)
|
||||
v = inctr(t)
|
||||
swig_assert( v == 5, "inctr - v == 5 was #{v}")
|
||||
val = intp_value(t)
|
||||
swig_assert( val == 6, "inctr - intp_value(t) == 6 was #{val}")
|
||||
|
||||
|
||||
#
|
||||
# @todo: how to use voidhandle and handle?
|
||||
#
|
||||
|
||||
17
Examples/test-suite/ruby/cast_operator_runme.rb
Executable file
17
Examples/test-suite/ruby/cast_operator_runme.rb
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put script description here.
|
||||
#
|
||||
# Author::
|
||||
# Copyright::
|
||||
# License:: Ruby
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
require 'cast_operator'
|
||||
include Cast_operator
|
||||
|
||||
a = A.new
|
||||
t = a.tochar
|
||||
|
||||
swig_assert( t == 'hi' )
|
||||
23
Examples/test-suite/ruby/casts_runme.rb
Executable file
23
Examples/test-suite/ruby/casts_runme.rb
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put script description here.
|
||||
#
|
||||
# Author:: gga
|
||||
# Copyright:: 2007
|
||||
# License:: Ruby
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
require 'casts'
|
||||
|
||||
include Casts
|
||||
|
||||
swig_assert( B.ancestors.include?(A), 'B.ancestors.include? A' )
|
||||
|
||||
a = A.new
|
||||
a.hello
|
||||
|
||||
b = B.new
|
||||
b.hello
|
||||
|
||||
swig_assert( b.kind_of?( A ), ' B.kind_of? A' )
|
||||
Loading…
Add table
Add a link
Reference in a new issue