PageRenderTime 47ms CodeModel.GetById 1ms app.highlight 42ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/octave/overload_simple_runme.m

#
Objective C | 125 lines | 93 code | 32 blank | 0 comment | 25 complexity | 31f3b04c341abd9a6622d27e9f544795 MD5 | raw file
  1overload_simple
  2
  3# unless explicitly casted via {{u}int{8,16,32,64},double,single},
  4# octave will take numeric literals as doubles.
  5
  6if (!strcmp(foo(3),"foo:int"))
  7    error("foo(int)")
  8endif
  9
 10if (!strcmp(foo(3.1),"foo:double"))
 11    error("foo(double)")
 12endif
 13
 14if (!strcmp(foo("hello"),"foo:char *"))
 15    error("foo(char *)")
 16endif
 17
 18f = Foo();
 19b = Bar();
 20
 21if (!strcmp(foo(f),"foo:Foo *"))
 22    error("foo(Foo *)")
 23endif
 24
 25if (!strcmp(foo(b),"foo:Bar *"))
 26    error("foo(Bar *)")
 27endif
 28
 29v = malloc_void(32);
 30
 31if (!strcmp(foo(v),"foo:void *"))
 32    error("foo(void *)")
 33endif
 34
 35s = Spam();
 36
 37if (!strcmp(s.foo(3),"foo:int"))
 38    error("Spam::foo(int)")
 39endif
 40
 41if (!strcmp(s.foo(3.1),"foo:double"))
 42    error("Spam::foo(double)")
 43endif
 44
 45if (!strcmp(s.foo("hello"),"foo:char *"))
 46    error("Spam::foo(char *)")
 47endif
 48
 49if (!strcmp(s.foo(f),"foo:Foo *"))
 50    error("Spam::foo(Foo *)")
 51endif
 52
 53if (!strcmp(s.foo(b),"foo:Bar *"))
 54    error("Spam::foo(Bar *)")
 55endif
 56
 57if (!strcmp(s.foo(v),"foo:void *"))
 58    error("Spam::foo(void *)")
 59endif
 60
 61if (!strcmp(Spam_bar(3),"bar:int"))
 62    error("Spam::bar(int)")
 63endif
 64
 65if (!strcmp(Spam_bar(3.1),"bar:double"))
 66    error("Spam::bar(double)")
 67endif
 68
 69if (!strcmp(Spam_bar("hello"),"bar:char *"))
 70    error("Spam::bar(char *)")
 71endif
 72
 73if (!strcmp(Spam_bar(f),"bar:Foo *"))
 74    error("Spam::bar(Foo *)")
 75endif
 76
 77if (!strcmp(Spam_bar(b),"bar:Bar *"))
 78    error("Spam::bar(Bar *)")
 79endif
 80
 81if (!strcmp(Spam_bar(v),"bar:void *"))
 82    error("Spam::bar(void *)")
 83endif
 84
 85# Test constructors
 86
 87s = Spam();
 88if (!strcmp(s.type,"none"))
 89    error("Spam()")
 90endif
 91
 92s = Spam(3);
 93if (!strcmp(s.type,"int"))
 94    error("Spam(int)")
 95endif
 96    
 97s = Spam(3.4);
 98if (!strcmp(s.type,"double"))
 99    error("Spam(double)")
100endif
101
102s = Spam("hello");
103if (!strcmp(s.type,"char *"))
104    error("Spam(char *)")
105endif
106
107s = Spam(f);
108if (!strcmp(s.type,"Foo *"))
109    error("Spam(Foo *)")
110endif
111
112s = Spam(b);
113if (!strcmp(s.type,"Bar *"))
114    error("Spam(Bar *)")
115endif
116
117s = Spam(v);
118if (!strcmp(s.type,"void *"))
119    error("Spam(void *)")
120endif
121
122free_void(v);
123
124a = ClassA();
125b = a.method1(1);