~ubuntu-branches/ubuntu/hoary/swig1.3/hoary

« back to all changes in this revision

Viewing changes to Examples/test-suite/ruby/director_wombat_runme.rb

  • Committer: Bazaar Package Importer
  • Author(s): Thom May
  • Date: 2004-08-02 15:57:10 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040802155710-bm292q1d6x6tw7gc
Tags: 1.3.21-5ubuntu1
Fix linking for ruby, python, perl and tcl bindings

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'director_wombat'
 
2
 
 
3
include Director_wombat
 
4
 
 
5
# Test base class functionality
 
6
barObj = Bar.new
 
7
 
 
8
# Bar#meth should return a Foo_integers instance
 
9
fooIntsObj = barObj.meth
 
10
raise RuntimeError unless fooIntsObj.instance_of?(Foo_integers)
 
11
 
 
12
# Foo_integers#meth(n) should return n
 
13
raise RuntimeError if fooIntsObj.meth(42) != 42
 
14
 
 
15
#
 
16
# Now subclass Foo_integers, but override its virtual method
 
17
# meth(n) so that it returns the number plus one.
 
18
#
 
19
class MyFooInts < Foo_integers
 
20
  def meth(n)
 
21
    n + 1
 
22
  end
 
23
end
 
24
 
 
25
#
 
26
# Subclass Bar and override its virtual method meth()
 
27
# so that it returns a new MyFooInts instance instead of
 
28
# a Foo_integers instance.
 
29
#
 
30
class MyBar < Bar
 
31
  def meth
 
32
    MyFooInts.new
 
33
  end
 
34
end
 
35
 
 
36
#
 
37
# Now repeat previous tests:
 
38
#
 
39
# Create a MyBar instance...
 
40
#
 
41
barObj = MyBar.new
 
42
 
 
43
# MyBar#meth should return a MyFooInts instance
 
44
fooIntsObj = barObj.meth
 
45
raise RuntimeError unless fooIntsObj.instance_of?(MyFooInts)
 
46
 
 
47
# MyFooInts#meth(n) should return n+1
 
48
raise RuntimeError if fooIntsObj.meth(42) != 43
 
49