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:
Gonzalo Garramuno 2007-04-28 15:52:50 +00:00
commit 5be075f16f
7 changed files with 255 additions and 0 deletions

View 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' )

View 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

View 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

View 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

View 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?
#

View 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' )

View 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' )