PageRenderTime 27ms CodeModel.GetById 1ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/ruby/apply_strings_runme.rb

#
Ruby | 61 lines | 35 code | 11 blank | 15 comment | 2 complexity | 67f4bd9b2540309141aef2d70f0ac3a0 MD5 | raw file
 1#!/usr/bin/env ruby
 2#
 3# Put script description here.
 4#
 5# 
 6# 
 7# 
 8#
 9
10require 'swig_assert'
11require 'apply_strings'
12
13include Apply_strings
14
15begin
16  x = UcharPtr.new
17  swig_assert( fail, "UcharPtr should not be defined")
18rescue NameError
19end
20
21ptr = 'a'
22['UCharFunction', 'SCharFunction', 'CUCharFunction',
23 'CSCharFunction'].each do |m|
24  val = Apply_strings.send(m, ptr)
25  swig_assert( "val == ptr", binding )
26end
27
28
29['CharFunction', 'CCharFunction'].each do |m|
30  begin
31    val = Apply_strings.send(m, ptr)
32    swig_assert( false, nil, "Apply_strings.#{m} should raise TypeError" )
33  rescue TypeError
34  end
35end
36
37ptr = 'a'
38foo = DirectorTest.new
39['UCharFunction', 'SCharFunction', 'CUCharFunction',
40 'CSCharFunction'].each do |m|
41  val = foo.send(m, ptr)
42  swig_assert( "val == ptr", binding, "DirectorTest.#{m}" )
43end
44
45
46['CharFunction', 'CCharFunction'].each do |m|
47  begin
48    val = foo.send(m, ptr)
49    swig_assert( false, nil, "DirectorTest.#{m} should raise TypeError" )
50  rescue TypeError
51  end
52end
53
54
55# ary = Apply_strings.DigitsGlobalB
56# { 0 => 'A',
57#   1 => 'B',
58#   2 => 'B' }.each do |k,v|
59#   val = ary[k]
60#   swig_assert( val == v, "Apply_strings.DigitsGlobalB[#{k}] #{val} != #{v}")
61# end