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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'track_objects'
 
2
 
 
3
def test_same_ruby_object(foo1, foo2)
 
4
        if not foo1.equal?(foo2)
 
5
          raise "Ruby objects should be the same."
 
6
        end
 
7
end
 
8
 
 
9
def test_same_cpp_object(foo1, foo2)
 
10
        if not foo1.cpp_equal(foo2)
 
11
                raise "C++ objects should be the same"
 
12
        end
 
13
end
 
14
 
 
15
bar = Track_objects::Bar.new
 
16
foo1 = Track_objects::Foo.new()
 
17
bar.set_unowned_foo(foo1)
 
18
  
 
19
# test_simple_identity
 
20
foo2 = Track_objects::Foo.new()
 
21
foo3 = foo2
 
22
 
 
23
test_same_ruby_object(foo2, foo3)
 
24
test_same_cpp_object(foo2, foo3)
 
25
 
 
26
#       test_unowned_foo_identity
 
27
foo4 = bar.get_unowned_foo()
 
28
 
 
29
test_same_ruby_object(foo1, foo4)
 
30
test_same_cpp_object(foo1, foo4)
 
31
 
 
32
# test_owned_foo_identity
 
33
foo5 = bar.get_owned_foo()
 
34
foo6 = bar.get_owned_foo()
 
35
 
 
36
test_same_ruby_object(foo5, foo6)
 
37
test_same_cpp_object(foo5, foo6)
 
38
        
 
39
# test_new_foo_identity
 
40
foo7 = Track_objects::Bar.get_new_foo()
 
41
foo8 = Track_objects::Bar.get_new_foo()
 
42
 
 
43
if foo7.equal?(foo8)
 
44
  raise "Ruby objects should be different."
 
45
end
 
46
 
 
47
if foo7.cpp_equal(foo8)
 
48
  raise "C++ objects should be different."
 
49
end
 
50
                
 
51
# test_set_owned_identity
 
52
foo9 = Track_objects::Foo.new
 
53
bar.set_owned_foo(foo9)
 
54
foo10 = bar.get_owned_foo()
 
55
                
 
56
test_same_ruby_object(foo9, foo10)
 
57
test_same_cpp_object(foo9, foo10)
 
58
 
 
59
# test_set_owned_identity2
 
60
begin
 
61
        foo11 = Track_objects::Foo.new
 
62
        bar.set_owned_foo(foo11)
 
63
        foo11 = nil
 
64
end
 
65
         
 
66
GC.start
 
67
 
 
68
foo12 = bar.get_owned_foo()
 
69
 
 
70
if not (foo12.say_hello == "Hello")
 
71
        raise "Invalid C++ object returned."
 
72
end
 
73
 
 
74
# test_set_owned_identity3
 
75
foo13 = bar.get_owned_foo_by_argument()
 
76
foo14 = bar.get_owned_foo_by_argument()
 
77
 
 
78
test_same_ruby_object(foo13, foo14)
 
79
test_same_cpp_object(foo13, foo14)
 
80