swig/Examples/test-suite/ruby/swig_assert.rb
Gonzalo Garramuno 806d9040c5 Updated CHANGES.current.
Fixed problems with insert() and unshift() functions in std::vector for ruby.
Updated Ruby documentation.
Improved swig_assert.rb.
Added "second" singleton to std_pair in ruby.
Modified two tests to follow the new STL stuff.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9721 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-04-30 09:45:10 +00:00

48 lines
867 B
Ruby
Executable file

#!/usr/bin/env ruby
#
# A simple function to create useful asserts
#
# Author:: gga
# Copyright:: 2007
# License:: Ruby
#
class SwigRubyError < RuntimeError
end
class SwigAssertError < StandardError
end
def swig_assert( condition, *args )
begin
ok = eval(condition.to_s)
rescue => e
raise SwigAssertError.new("Wrong assert: #{condition.to_s} - #{e}")
end
unless ok
raise SwigRubyError.new("FAILED CHECK: #{condition} was #{ok.inspect} #{args.join(' ')}")
end
if $VERBOSE
$stdout.puts "\tPASSED #{condition} #{args.join(' ')}"
end
return ok
rescue => e
trace = e.backtrace[1..-1]
$stderr.puts "#{trace[0,1]}: #{e}"
if trace.size > 1
$stderr.puts "\tfrom #{trace[1..-1].join("\n\t ")}"
end
exit(1)
end
def swig_assert_each_line( lines )
lines.split("\n").each do |line|
swig_assert(line)
end
end