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

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

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