File: runme.rb

package info (click to toggle)
renderdoc 1.27%2Bdfsg-1
  • links: PTS, VCS
  • area: non-free
  • in suites: sid
  • size: 107,796 kB
  • sloc: cpp: 763,519; ansic: 326,847; python: 26,946; xml: 23,189; java: 11,382; cs: 7,181; makefile: 6,707; yacc: 5,682; ruby: 4,648; perl: 3,461; sh: 2,381; php: 2,119; lisp: 1,835; javascript: 1,525; tcl: 1,068; ml: 747
file content (90 lines) | stat: -rw-r--r-- 1,676 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# file: runme.rb
# Test various properties of classes defined in separate modules

puts "Testing the %import directive"

require 'base'
require 'foo'
require 'bar'
require 'spam'

# Create some objects

puts "Creating some objects"

a = Base::Base.new
b = Foo::Foo.new
c = Bar::Bar.new
d = Spam::Spam.new

# Try calling some methods
puts "Testing some methods"
puts "Should see 'Base::A' ---> #{a.A}"
puts "Should see 'Base::B' ---> #{a.B}"

puts  "Should see 'Foo::A' ---> #{b.A}"
puts  "Should see 'Foo::B' ---> #{b.B}"

puts  "Should see 'Bar::A' ---> #{c.A}"
puts  "Should see 'Bar::B' ---> #{c.B}"

puts  "Should see 'Spam::A' ---> #{d.A}"
puts  "Should see 'Spam::B' ---> #{d.B}"

# Try some casts

puts "\nTesting some casts\n"

x = a.toBase
puts "Should see 'Base::A' ---> #{x.A}"
puts "Should see 'Base::B' ---> #{x.B}"

x = b.toBase
puts "Should see 'Foo::A' ---> #{x.A}"
puts "Should see 'Base::B' ---> #{x.B}"

x = c.toBase
puts "Should see 'Bar::A' ---> #{x.A}"
puts "Should see 'Base::B' ---> #{x.B}"

x = d.toBase
puts "Should see 'Spam::A' ---> #{x.A}"
puts "Should see 'Base::B' ---> #{x.B}"

x = d.toBar
puts "Should see 'Bar::B' ---> #{x.B}"

puts "\nTesting some dynamic casts\n"
x = d.toBase

puts " Spam -> Base -> Foo : "
y = Foo::Foo.fromBase(x)
if y != nil
  puts "bad swig"
else
  puts "good swig"
end

puts " Spam -> Base -> Bar : "
y = Bar::Bar.fromBase(x)
if y != nil
  puts "good swig"
else
  puts "bad swig"
end
      
puts " Spam -> Base -> Spam : "
y = Spam::Spam.fromBase(x)
if y != nil
  puts "good swig"
else
  puts "bad swig"
end

puts " Foo -> Spam : "
y = Spam::Spam.fromBase(b)
if y != nil
  puts "bad swig"
else
  puts "good swig"
end