PageRenderTime 19ms CodeModel.GetById 1ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Objective C | 184 lines | 139 code | 45 blank | 0 comment | 78 complexity | 683f1f298ee69e1e8179351f1fa81664 MD5 | raw file
  1overload_template
  2f = foo();
  3
  4a = maximum(3,4);
  5b = maximum(3.4,5.2);
  6
  7# mix 1
  8if (mix1("hi") != 101)
  9  error("mix1(const char*)")
 10endif
 11
 12if (mix1(1.0, 1.0) != 102)
 13  error("mix1(double, const double &)")
 14endif
 15
 16if (mix1(1.0) != 103)
 17  error("mix1(double)")
 18endif
 19
 20# mix 2
 21if (mix2("hi") != 101)
 22  error("mix2(const char*)")
 23endif
 24
 25if (mix2(1.0, 1.0) != 102)
 26  error("mix2(double, const double &)")
 27endif
 28
 29if (mix2(1.0) != 103)
 30  error("mix2(double)")
 31endif
 32
 33# mix 3
 34if (mix3("hi") != 101)
 35  error("mix3(const char*)")
 36endif
 37
 38if (mix3(1.0, 1.0) != 102)
 39  error("mix3(double, const double &)")
 40endif
 41
 42if (mix3(1.0) != 103)
 43  error("mix3(double)")
 44endif
 45
 46# Combination 1
 47if (overtparams1(100) != 10)
 48  error("overtparams1(int)")
 49endif
 50
 51if (overtparams1(100.0, 100) != 20)
 52  error("overtparams1(double, int)")
 53endif
 54
 55# Combination 2
 56if (overtparams2(100.0, 100) != 40)
 57  error("overtparams2(double, int)")
 58endif
 59
 60# Combination 3
 61if (overloaded() != 60)
 62  error("overloaded()")
 63endif
 64
 65if (overloaded(100.0, 100) != 70)
 66  error("overloaded(double, int)")
 67endif
 68
 69# Combination 4
 70if (overloadedagain("hello") != 80)
 71  error("overloadedagain(const char *)")
 72endif
 73
 74if (overloadedagain() != 90)
 75  error("overloadedagain(double)")
 76endif
 77
 78# specializations
 79if (specialization(10) != 202)
 80  error("specialization(int)")
 81endif
 82
 83if (specialization(10.1) != 203)
 84  error("specialization(double)")
 85endif
 86
 87if (specialization(10, 10) != 204)
 88  error("specialization(int, int)")
 89endif
 90
 91if (specialization(10.0, 10.1) != 205)
 92  error("specialization(double, double)")
 93endif
 94
 95if (specialization("hi", "hi") != 201)
 96  error("specialization(const char *, const char *)")
 97endif
 98
 99
100# simple specialization
101xyz();
102xyz_int();
103xyz_double();
104
105# a bit of everything
106if (overload("hi") != 0)
107  error("overload()")
108endif
109
110if (overload(1) != 10)
111  error("overload(int t)")
112endif
113
114if (overload(1, 1) != 20)
115  error("overload(int t, const int &)")
116endif
117
118if (overload(1, "hello") != 30)
119  error("overload(int t, const char *)")
120endif
121
122k = Klass();
123if (overload(k) != 10)
124  error("overload(Klass t)")
125endif
126
127if (overload(k, k) != 20)
128  error("overload(Klass t, const Klass &)")
129endif
130
131if (overload(k, "hello") != 30)
132  error("overload(Klass t, const char *)")
133endif
134
135if (overload(10.1, "hi") != 40)
136  error("overload(double t, const char *)")
137endif
138
139if (overload() != 50)
140  error("overload(const char *)")
141endif
142
143
144# everything put in a namespace
145if (nsoverload("hi") != 1000)
146  error("nsoverload()")
147endif
148
149if (nsoverload(1) != 1010)
150  error("nsoverload(int t)")
151endif
152
153if (nsoverload(1, 1) != 1020)
154  error("nsoverload(int t, const int &)")
155endif
156
157if (nsoverload(1, "hello") != 1030)
158  error("nsoverload(int t, const char *)")
159endif
160
161if (nsoverload(k) != 1010)
162  error("nsoverload(Klass t)")
163endif
164
165if (nsoverload(k, k) != 1020)
166  error("nsoverload(Klass t, const Klass &)")
167endif
168
169if (nsoverload(k, "hello") != 1030)
170  error("nsoverload(Klass t, const char *)")
171endif
172
173if (nsoverload(10.1, "hi") != 1040)
174  error("nsoverload(double t, const char *)")
175endif
176
177if (nsoverload() != 1050)
178  error("nsoverload(const char *)")
179endif
180
181
182A_foo(1);
183b = B();
184b.foo(1);