PageRenderTime 30ms CodeModel.GetById 1ms app.highlight 26ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Ruby | 130 lines | 89 code | 32 blank | 9 comment | 50 complexity | c9f0df7bddd52db4d2025943b8d7db19 MD5 | raw file
  1#!/usr/bin/env ruby
  2#
  3# Put description here
  4#
  5# 
  6# 
  7# 
  8#
  9
 10require 'swig_assert'
 11
 12require 'overload_simple'
 13
 14include Overload_simple
 15
 16if foo(3) != "foo:int"
 17  raise RuntimeError, "foo(int)"
 18end
 19
 20if foo(3.0) != "foo:double"
 21  raise RuntimeError, "foo(double)"
 22end
 23
 24if foo("hello") != "foo:char *"
 25  raise RuntimeError, "foo(char *)"
 26end
 27
 28f = Foo.new
 29b = Bar.new
 30
 31if foo(f) != "foo:Foo *"
 32  raise RuntimeError, "foo(Foo *)"
 33end
 34
 35if foo(b) != "foo:Bar *"
 36  raise RuntimeError, "foo(Bar *)"
 37end
 38
 39v = malloc_void(32)
 40
 41if foo(v) != "foo:void *"
 42  raise RuntimeError, "foo(void *)"
 43end
 44
 45s = Spam.new
 46
 47if s.foo(3) != "foo:int"
 48  raise RuntimeError, "Spam::foo(int)"
 49end
 50
 51if s.foo(3.0) != "foo:double"
 52  raise RuntimeError, "Spam::foo(double)"
 53end
 54
 55if s.foo("hello") != "foo:char *"
 56  raise RuntimeError, "Spam::foo(char *)"
 57end
 58
 59if s.foo(f) != "foo:Foo *"
 60  raise RuntimeError, "Spam::foo(Foo *)"
 61end
 62
 63if s.foo(b) != "foo:Bar *"
 64  raise RuntimeError, "Spam::foo(Bar *)"
 65end
 66
 67if s.foo(v) != "foo:void *"
 68  raise RuntimeError, "Spam::foo(void *)"
 69end
 70
 71if Spam.bar(3) != "bar:int"
 72  raise RuntimeError, "Spam::bar(int)"
 73end
 74
 75if Spam.bar(3.0) != "bar:double"
 76  raise RuntimeError, "Spam::bar(double)"
 77end
 78
 79if Spam.bar("hello") != "bar:char *"
 80  raise RuntimeError, "Spam::bar(char *)"
 81end
 82
 83if Spam.bar(f) != "bar:Foo *"
 84  raise RuntimeError, "Spam::bar(Foo *)"
 85end
 86
 87if Spam.bar(b) != "bar:Bar *"
 88  raise RuntimeError, "Spam::bar(Bar *)"
 89end
 90
 91if Spam.bar(v) != "bar:void *"
 92  raise RuntimeError, "Spam::bar(void *)"
 93end
 94
 95# Test constructors
 96
 97s = Spam.new
 98if s.type != "none"
 99  raise RuntimeError, "Spam()"
100end
101
102s = Spam.new(3)
103if s.type != "int"
104  raise RuntimeError, "Spam(int)"
105end
106    
107s = Spam.new(3.4)
108if s.type != "double"
109  raise RuntimeError, "Spam(double)"
110end
111
112s = Spam.new("hello")
113if s.type != "char *"
114  raise RuntimeError, "Spam(char *)"
115end
116
117s = Spam.new(f)
118if s.type != "Foo *"
119  raise RuntimeError, "Spam(Foo *)"
120end
121
122s = Spam.new(b)
123if s.type != "Bar *"
124  raise RuntimeError, "Spam(Bar *)"
125end
126
127s = Spam.new(v)
128if s.type != "void *"
129  raise RuntimeError, "Spam(void *)"
130end