Mercurial > octave-nkf
comparison test/jit.tst @ 20654:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 9cf91ecdc6f7 |
children |
comparison
equal
deleted
inserted
replaced
20653:9cef0a1207e4 | 20654:b65888ec820e |
---|---|
17 ## <http://www.gnu.org/licenses/>. | 17 ## <http://www.gnu.org/licenses/>. |
18 | 18 |
19 ## Author: Max Brister <max@2bass.com> | 19 ## Author: Max Brister <max@2bass.com> |
20 | 20 |
21 ## Turn on JIT and set defaults before running tests | 21 ## Turn on JIT and set defaults before running tests |
22 %!testif HAVE_LLVM | 22 %!testif HAVE_JIT |
23 %! global __old_jit_enable__; | 23 %! global __old_jit_enable__; |
24 %! global __old_jit_startcnt__; | 24 %! global __old_jit_startcnt__; |
25 %! __old_jit_enable__ = jit_enable (true); | 25 %! __old_jit_enable__ = jit_enable (true); |
26 %! __old_jit_startcnt__ = jit_startcnt (1000); | 26 %! __old_jit_startcnt__ = jit_startcnt (1000); |
27 | 27 |
28 ## Test some simple cases that compile. | 28 ## Test some simple cases that compile. |
29 %!testif HAVE_LLVM | 29 %!testif HAVE_JIT |
30 %! jit_failcnt (0) | 30 %! jit_failcnt (0) |
31 %! for i=1:1e6 | 31 %! for i=1:1e6 |
32 %! if (i < 5) | 32 %! if (i < 5) |
33 %! break; | 33 %! break; |
34 %! else | 34 %! else |
36 %! endif | 36 %! endif |
37 %! endfor | 37 %! endfor |
38 %! assert (i, 1); | 38 %! assert (i, 1); |
39 %! assert (jit_failcnt, 0); | 39 %! assert (jit_failcnt, 0); |
40 | 40 |
41 %!testif HAVE_LLVM | 41 %!testif HAVE_JIT |
42 %! jit_failcnt (0) | 42 %! jit_failcnt (0) |
43 %! while (1) | 43 %! while (1) |
44 %! if (1) | 44 %! if (1) |
45 %! break; | 45 %! break; |
46 %! else | 46 %! else |
47 %! break; | 47 %! break; |
48 %! endif | 48 %! endif |
49 %! endwhile | 49 %! endwhile |
50 %! assert (jit_failcnt, 0); | 50 %! assert (jit_failcnt, 0); |
51 | 51 |
52 %!testif HAVE_LLVM | 52 %!testif HAVE_JIT |
53 %! jit_failcnt (0) | 53 %! jit_failcnt (0) |
54 %! do | 54 %! do |
55 %! break; | 55 %! break; |
56 %! until (0) | 56 %! until (0) |
57 %! assert (jit_failcnt, 0); | 57 %! assert (jit_failcnt, 0); |
58 | 58 |
59 %!testif HAVE_LLVM | 59 %!testif HAVE_JIT |
60 %! jit_failcnt (0) | 60 %! jit_failcnt (0) |
61 %! do | 61 %! do |
62 %! if (1) | 62 %! if (1) |
63 %! break; | 63 %! break; |
64 %! end; | 64 %! end; |
65 %! until (0) | 65 %! until (0) |
66 %! assert (jit_failcnt, 0); | 66 %! assert (jit_failcnt, 0); |
67 | 67 |
68 %!testif HAVE_LLVM | 68 %!testif HAVE_JIT |
69 %! jit_failcnt (0) | 69 %! jit_failcnt (0) |
70 %! i=1; | 70 %! i=1; |
71 %! do | 71 %! do |
72 %! continue; | 72 %! continue; |
73 %! i=i+1; | 73 %! i=i+1; |
74 %! until (1) | 74 %! until (1) |
75 %! assert (i, 1); | 75 %! assert (i, 1); |
76 %! assert (jit_failcnt, 0); | 76 %! assert (jit_failcnt, 0); |
77 | 77 |
78 %!testif HAVE_LLVM | 78 %!testif HAVE_JIT |
79 %! jit_failcnt (0) | 79 %! jit_failcnt (0) |
80 %! for i=1:1e6 | 80 %! for i=1:1e6 |
81 %! if (i == 100) | 81 %! if (i == 100) |
82 %! break; | 82 %! break; |
83 %! endif | 83 %! endif |
84 %! endfor | 84 %! endfor |
85 %! assert (i, 100); | 85 %! assert (i, 100); |
86 %! assert (jit_failcnt, 0); | 86 %! assert (jit_failcnt, 0); |
87 | 87 |
88 ## Also test parfor keyword | 88 ## Also test parfor keyword |
89 %!testif HAVE_LLVM | 89 %!testif HAVE_JIT |
90 %! jit_failcnt (0) | 90 %! jit_failcnt (0) |
91 %! parfor i=1:1e6 | 91 %! parfor i=1:1e6 |
92 %! if (i == 100) | 92 %! if (i == 100) |
93 %! break; | 93 %! break; |
94 %! endif | 94 %! endif |
95 %! endparfor | 95 %! endparfor |
96 %! assert (i, 100); | 96 %! assert (i, 100); |
97 %! assert (jit_failcnt, 0); | 97 %! assert (jit_failcnt, 0); |
98 ## Test some switch statements | 98 ## Test some switch statements |
99 %!testif HAVE_LLVM | 99 %!testif HAVE_JIT |
100 %! jit_failcnt (0) | 100 %! jit_failcnt (0) |
101 %! do | 101 %! do |
102 %! switch (1) | 102 %! switch (1) |
103 %! end; | 103 %! end; |
104 %! until(1) | 104 %! until(1) |
105 %! assert (jit_failcnt, 0); | 105 %! assert (jit_failcnt, 0); |
106 | 106 |
107 %!testif HAVE_LLVM | 107 %!testif HAVE_JIT |
108 %! jit_failcnt (0) | 108 %! jit_failcnt (0) |
109 %! do | 109 %! do |
110 %! switch (1) | 110 %! switch (1) |
111 %! case 1 | 111 %! case 1 |
112 %! break; | 112 %! break; |
113 %! end; | 113 %! end; |
114 %! until(1) | 114 %! until(1) |
115 %! assert (jit_failcnt, 0); | 115 %! assert (jit_failcnt, 0); |
116 | 116 |
117 %!testif HAVE_LLVM | 117 %!testif HAVE_JIT |
118 %! jit_failcnt (0) | 118 %! jit_failcnt (0) |
119 %! do | 119 %! do |
120 %! switch (1) | 120 %! switch (1) |
121 %! otherwise | 121 %! otherwise |
122 %! break; | 122 %! break; |
123 %! end; | 123 %! end; |
124 %! until(1) | 124 %! until(1) |
125 %! assert (jit_failcnt, 0); | 125 %! assert (jit_failcnt, 0); |
126 | 126 |
127 %!testif HAVE_LLVM | 127 %!testif HAVE_JIT |
128 %! jit_failcnt (0) | 128 %! jit_failcnt (0) |
129 %! do | 129 %! do |
130 %! switch (1) | 130 %! switch (1) |
131 %! case 1 | 131 %! case 1 |
132 %! break; | 132 %! break; |
134 %! break; | 134 %! break; |
135 %! end; | 135 %! end; |
136 %! until(1) | 136 %! until(1) |
137 %! assert (jit_failcnt, 0); | 137 %! assert (jit_failcnt, 0); |
138 | 138 |
139 %!testif HAVE_LLVM | 139 %!testif HAVE_JIT |
140 %! jit_failcnt (0) | 140 %! jit_failcnt (0) |
141 %! i=0; | 141 %! i=0; |
142 %! a=0; | 142 %! a=0; |
143 %! b=0; | 143 %! b=0; |
144 %! do | 144 %! do |
160 %! assert (a, 6); | 160 %! assert (a, 6); |
161 %! assert (b, 1); | 161 %! assert (b, 1); |
162 %! assert (jit_failcnt, 0); | 162 %! assert (jit_failcnt, 0); |
163 | 163 |
164 ## Some more complex calculations | 164 ## Some more complex calculations |
165 %!testif HAVE_LLVM | 165 %!testif HAVE_JIT |
166 %! jit_failcnt (0) | 166 %! jit_failcnt (0) |
167 %! inc = 1e-5; | 167 %! inc = 1e-5; |
168 %! result = 0; | 168 %! result = 0; |
169 %! for ii = 0:inc:1 | 169 %! for ii = 0:inc:1 |
170 %! result = result + inc * (1/3 * ii * ii); | 170 %! result = result + inc * (1/3 * ii * ii); |
171 %! endfor | 171 %! endfor |
172 %! assert (abs (result - 1/9) < 1e-5); | 172 %! assert (abs (result - 1/9) < 1e-5); |
173 %! assert (jit_failcnt, 0); | 173 %! assert (jit_failcnt, 0); |
174 | 174 |
175 %!testif HAVE_LLVM | 175 %!testif HAVE_JIT |
176 %! jit_failcnt (0) | 176 %! jit_failcnt (0) |
177 %! inc = 1e-5; | 177 %! inc = 1e-5; |
178 %! result = 0; | 178 %! result = 0; |
179 %! for ii = 0:inc:1 | 179 %! for ii = 0:inc:1 |
180 %! ## the ^ operator's result is complex | 180 %! ## the ^ operator's result is complex |
181 %! result = result + inc * (1/3 * ii ^ 2); | 181 %! result = result + inc * (1/3 * ii ^ 2); |
182 %! endfor | 182 %! endfor |
183 %! assert (abs (result - 1/9) < 1e-5); | 183 %! assert (abs (result - 1/9) < 1e-5); |
184 %! assert (jit_failcnt, 0); | 184 %! assert (jit_failcnt, 0); |
185 | 185 |
186 %!testif HAVE_LLVM | 186 %!testif HAVE_JIT |
187 %! jit_failcnt (0) | 187 %! jit_failcnt (0) |
188 %! temp = 1+1i; | 188 %! temp = 1+1i; |
189 %! nan = NaN; | 189 %! nan = NaN; |
190 %! while (1) | 190 %! while (1) |
191 %! temp = temp - 1i; | 191 %! temp = temp - 1i; |
193 %! break; | 193 %! break; |
194 %! endwhile | 194 %! endwhile |
195 %! assert (imag (temp), 0); | 195 %! assert (imag (temp), 0); |
196 %! assert (jit_failcnt, 0); | 196 %! assert (jit_failcnt, 0); |
197 | 197 |
198 %!testif HAVE_LLVM | 198 %!testif HAVE_JIT |
199 %! jit_failcnt (0) | 199 %! jit_failcnt (0) |
200 %! temp = 1+1i; | 200 %! temp = 1+1i; |
201 %! nan = NaN+1i; | 201 %! nan = NaN+1i; |
202 %! while (1) | 202 %! while (1) |
203 %! nan = nan - 1i; | 203 %! nan = nan - 1i; |
206 %! break; | 206 %! break; |
207 %! endwhile | 207 %! endwhile |
208 %! assert (imag (temp), 0); | 208 %! assert (imag (temp), 0); |
209 %! assert (jit_failcnt, 0); | 209 %! assert (jit_failcnt, 0); |
210 | 210 |
211 %!testif HAVE_LLVM | 211 %!testif HAVE_JIT |
212 %! jit_failcnt (0) | 212 %! jit_failcnt (0) |
213 %! temp = 1+1i; | 213 %! temp = 1+1i; |
214 %! while (1) | 214 %! while (1) |
215 %! temp = temp * 5; | 215 %! temp = temp * 5; |
216 %! break; | 216 %! break; |
217 %! endwhile | 217 %! endwhile |
218 %! assert (temp, 5+5i); | 218 %! assert (temp, 5+5i); |
219 %! assert (jit_failcnt, 0); | 219 %! assert (jit_failcnt, 0); |
220 | 220 |
221 %!testif HAVE_LLVM | 221 %!testif HAVE_JIT |
222 %! jit_failcnt (0) | 222 %! jit_failcnt (0) |
223 %! nr = 1001; | 223 %! nr = 1001; |
224 %! mat = zeros (1, nr); | 224 %! mat = zeros (1, nr); |
225 %! for i = 1:nr | 225 %! for i = 1:nr |
226 %! mat(i) = i; | 226 %! mat(i) = i; |
227 %! endfor | 227 %! endfor |
228 %! assert (mat == 1:nr); | 228 %! assert (mat == 1:nr); |
229 %! assert (jit_failcnt, 0); | 229 %! assert (jit_failcnt, 0); |
230 | 230 |
231 %!testif HAVE_LLVM | 231 %!testif HAVE_JIT |
232 %! jit_failcnt (0) | 232 %! jit_failcnt (0) |
233 %! nr = 1001; | 233 %! nr = 1001; |
234 %! mat = 1:nr; | 234 %! mat = 1:nr; |
235 %! mat(end) = 0; # force mat to a matrix | 235 %! mat(end) = 0; # force mat to a matrix |
236 %! total = 0; | 236 %! total = 0; |
238 %! total = mat(i) + total; | 238 %! total = mat(i) + total; |
239 %! endfor | 239 %! endfor |
240 %! assert (sum (mat) == total); | 240 %! assert (sum (mat) == total); |
241 %! assert (jit_failcnt, 0); | 241 %! assert (jit_failcnt, 0); |
242 | 242 |
243 %!testif HAVE_LLVM | 243 %!testif HAVE_JIT |
244 %! jit_failcnt (0) | 244 %! jit_failcnt (0) |
245 %! nr = 1001; | 245 %! nr = 1001; |
246 %! mat = [3 1 5]; | 246 %! mat = [3 1 5]; |
247 %! try | 247 %! try |
248 %! for i = 1:nr | 248 %! for i = 1:nr |
288 %! if (counter > 0 && counter < K) | 288 %! if (counter > 0 && counter < K) |
289 %! z(end-counter+1:end) = 0; | 289 %! z(end-counter+1:end) = 0; |
290 %! endif | 290 %! endif |
291 %!endfunction | 291 %!endfunction |
292 | 292 |
293 %!testif HAVE_LLVM | 293 %!testif HAVE_JIT |
294 %! jit_failcnt (0) | 294 %! jit_failcnt (0) |
295 %! test_set = gen_test (10000); | 295 %! test_set = gen_test (10000); |
296 %! assert (all (vectorized (test_set, 3) == loopy (test_set, 3))); | 296 %! assert (all (vectorized (test_set, 3) == loopy (test_set, 3))); |
297 %! assert (jit_failcnt, 0); | 297 %! assert (jit_failcnt, 0); |
298 | 298 |
299 %!testif HAVE_LLVM | 299 %!testif HAVE_JIT |
300 %! jit_failcnt (0) | 300 %! jit_failcnt (0) |
301 %! niter = 1001; | 301 %! niter = 1001; |
302 %! i = 0; | 302 %! i = 0; |
303 %! while (i < niter) | 303 %! while (i < niter) |
304 %! i = i + 1; | 304 %! i = i + 1; |
305 %! endwhile | 305 %! endwhile |
306 %! assert (i == niter); | 306 %! assert (i == niter); |
307 %! assert (jit_failcnt, 0); | 307 %! assert (jit_failcnt, 0); |
308 | 308 |
309 %!testif HAVE_LLVM | 309 %!testif HAVE_JIT |
310 %! jit_failcnt (0) | 310 %! jit_failcnt (0) |
311 %! niter = 1001; | 311 %! niter = 1001; |
312 %! result = 0; | 312 %! result = 0; |
313 %! m = [5 10]; | 313 %! m = [5 10]; |
314 %! for i=1:niter | 314 %! for i=1:niter |
315 %! result = result + m(end); | 315 %! result = result + m(end); |
316 %! endfor | 316 %! endfor |
317 %! assert (result == m(end) * niter); | 317 %! assert (result == m(end) * niter); |
318 %! assert (jit_failcnt, 0); | 318 %! assert (jit_failcnt, 0); |
319 | 319 |
320 %!testif HAVE_LLVM | 320 %!testif HAVE_JIT |
321 %! jit_failcnt (0) | 321 %! jit_failcnt (0) |
322 %! ndim = 100; | 322 %! ndim = 100; |
323 %! result = 0; | 323 %! result = 0; |
324 %! m = zeros (ndim); | 324 %! m = zeros (ndim); |
325 %! m(:) = 1:ndim^2; | 325 %! m(:) = 1:ndim^2; |
331 %! i = i + 1; | 331 %! i = i + 1; |
332 %! endwhile | 332 %! endwhile |
333 %! assert (result == sum (sum (m))); | 333 %! assert (result == sum (sum (m))); |
334 %! assert (jit_failcnt, 0); | 334 %! assert (jit_failcnt, 0); |
335 | 335 |
336 %!testif HAVE_LLVM | 336 %!testif HAVE_JIT |
337 %! jit_failcnt (0) | 337 %! jit_failcnt (0) |
338 %! ndim = 100; | 338 %! ndim = 100; |
339 %! m = zeros (ndim); | 339 %! m = zeros (ndim); |
340 %! i = 1; | 340 %! i = 1; |
341 %! while (i <= ndim) | 341 %! while (i <= ndim) |
347 %! m2 = zeros (ndim); | 347 %! m2 = zeros (ndim); |
348 %! m2(:) = 1:(ndim^2); | 348 %! m2(:) = 1:(ndim^2); |
349 %! assert (all (m == m2)); | 349 %! assert (all (m == m2)); |
350 %! assert (jit_failcnt, 0); | 350 %! assert (jit_failcnt, 0); |
351 | 351 |
352 %!testif HAVE_LLVM | 352 %!testif HAVE_JIT |
353 %! jit_failcnt (0) | 353 %! jit_failcnt (0) |
354 %! ndim = 2; | 354 %! ndim = 2; |
355 %! m = zeros (ndim, ndim, ndim, ndim); | 355 %! m = zeros (ndim, ndim, ndim, ndim); |
356 %! result = 0; | 356 %! result = 0; |
357 %! i0 = 1; | 357 %! i0 = 1; |
383 %! unwind_protect_cleanup | 383 %! unwind_protect_cleanup |
384 %! warning (state, "Octave:divide-by-zero"); | 384 %! warning (state, "Octave:divide-by-zero"); |
385 %! end_unwind_protect | 385 %! end_unwind_protect |
386 %!endfunction | 386 %!endfunction |
387 | 387 |
388 %!testif HAVE_LLVM | 388 %!testif HAVE_JIT |
389 %! jit_failcnt (0) | 389 %! jit_failcnt (0) |
390 %! lasterr (""); | 390 %! lasterr (""); |
391 %! try | 391 %! try |
392 %! test_divide (); | 392 %! test_divide (); |
393 %! end_try_catch | 393 %! end_try_catch |
394 %! assert (strcmp (lasterr (), "division by zero")); | 394 %! assert (strcmp (lasterr (), "division by zero")); |
395 %! assert (jit_failcnt, 0); | 395 %! assert (jit_failcnt, 0); |
396 | 396 |
397 %!testif HAVE_LLVM | 397 %!testif HAVE_JIT |
398 %! jit_failcnt (0) | 398 %! jit_failcnt (0) |
399 %! while (1) | 399 %! while (1) |
400 %! a = 0; | 400 %! a = 0; |
401 %! result = a / 1; | 401 %! result = a / 1; |
402 %! break; | 402 %! break; |
403 %! endwhile | 403 %! endwhile |
404 %! assert (result, 0); | 404 %! assert (result, 0); |
405 %! assert (jit_failcnt, 0); | 405 %! assert (jit_failcnt, 0); |
406 | 406 |
407 %!testif HAVE_LLVM | 407 %!testif HAVE_JIT |
408 %! jit_failcnt (0) | 408 %! jit_failcnt (0) |
409 %! m = zeros (2, 1001); | 409 %! m = zeros (2, 1001); |
410 %! for i=1:1001 | 410 %! for i=1:1001 |
411 %! m(end, i) = i; | 411 %! m(end, i) = i; |
412 %! m(end - 1, end - i + 1) = i; | 412 %! m(end - 1, end - i + 1) = i; |
415 %! m2(1, :) = fliplr (1:1001); | 415 %! m2(1, :) = fliplr (1:1001); |
416 %! m2(2, :) = 1:1001; | 416 %! m2(2, :) = 1:1001; |
417 %! assert (m, m2); | 417 %! assert (m, m2); |
418 %! assert (jit_failcnt, 0); | 418 %! assert (jit_failcnt, 0); |
419 | 419 |
420 %!testif HAVE_LLVM | 420 %!testif HAVE_JIT |
421 %! jit_failcnt (0) | 421 %! jit_failcnt (0) |
422 %! m = [1 2 3]; | 422 %! m = [1 2 3]; |
423 %! for i=1:1001 | 423 %! for i=1:1001 |
424 %! m = sin (m); | 424 %! m = sin (m); |
425 %! break; | 425 %! break; |
426 %! endfor | 426 %! endfor |
427 %! assert (m == sin ([1 2 3])); | 427 %! assert (m == sin ([1 2 3])); |
428 %! assert (jit_failcnt, 0); | 428 %! assert (jit_failcnt, 0); |
429 | 429 |
430 %!testif HAVE_LLVM | 430 %!testif HAVE_JIT |
431 %! jit_failcnt (0) | 431 %! jit_failcnt (0) |
432 %! i = 0; | 432 %! i = 0; |
433 %! while i < 10 | 433 %! while i < 10 |
434 %! i += 1; | 434 %! i += 1; |
435 %! endwhile | 435 %! endwhile |
436 %! assert (i == 10); | 436 %! assert (i == 10); |
437 %! assert (jit_failcnt, 0); | 437 %! assert (jit_failcnt, 0); |
438 | 438 |
439 %!testif HAVE_LLVM | 439 %!testif HAVE_JIT |
440 %! jit_failcnt (0) | 440 %! jit_failcnt (0) |
441 %! i = 0; | 441 %! i = 0; |
442 %! while i < 10 | 442 %! while i < 10 |
443 %! a = ++i; | 443 %! a = ++i; |
444 %! endwhile | 444 %! endwhile |
445 %! assert (i == 10); | 445 %! assert (i == 10); |
446 %! assert (a == 10); | 446 %! assert (a == 10); |
447 %! assert (jit_failcnt, 0); | 447 %! assert (jit_failcnt, 0); |
448 | 448 |
449 %!testif HAVE_LLVM | 449 %!testif HAVE_JIT |
450 %! jit_failcnt (0) | 450 %! jit_failcnt (0) |
451 %! i = 0; | 451 %! i = 0; |
452 %! while i < 10 | 452 %! while i < 10 |
453 %! a = i++; | 453 %! a = i++; |
454 %! endwhile | 454 %! endwhile |
455 %! assert (i == 10); | 455 %! assert (i == 10); |
456 %! assert (a == 9); | 456 %! assert (a == 9); |
457 %! assert (jit_failcnt, 0); | 457 %! assert (jit_failcnt, 0); |
458 | 458 |
459 %!testif HAVE_LLVM | 459 %!testif HAVE_JIT |
460 %! jit_failcnt (0) | 460 %! jit_failcnt (0) |
461 %! num = 2; | 461 %! num = 2; |
462 %! a = zeros (1, num); | 462 %! a = zeros (1, num); |
463 %! i = 1; | 463 %! i = 1; |
464 %! while i <= num | 464 %! while i <= num |
478 %! else | 478 %! else |
479 %! si++; | 479 %! si++; |
480 %! endif; | 480 %! endif; |
481 %! endwhile | 481 %! endwhile |
482 | 482 |
483 %!testif HAVE_LLVM | 483 %!testif HAVE_JIT |
484 %! jit_failcnt (0) | 484 %! jit_failcnt (0) |
485 %! lasterr (""); | 485 %! lasterr (""); |
486 %! try | 486 %! try |
487 %! test_compute_idom (); | 487 %! test_compute_idom (); |
488 %! end_try_catch | 488 %! end_try_catch |
494 %! x = a; | 494 %! x = a; |
495 %! break; | 495 %! break; |
496 %! endwhile | 496 %! endwhile |
497 %!endfunction | 497 %!endfunction |
498 | 498 |
499 %!testif HAVE_LLVM | 499 %!testif HAVE_JIT |
500 %! jit_failcnt (0) | 500 %! jit_failcnt (0) |
501 %! assert (test_overload (1), 1); | 501 %! assert (test_overload (1), 1); |
502 %! assert (test_overload ([1 2]), [1 2]); | 502 %! assert (test_overload ([1 2]), [1 2]); |
503 %! assert (jit_failcnt, 0); | 503 %! assert (jit_failcnt, 0); |
504 | 504 |
516 %! endif | 516 %! endif |
517 %! endfor | 517 %! endfor |
518 %! endwhile | 518 %! endwhile |
519 %!endfunction | 519 %!endfunction |
520 | 520 |
521 %!testif HAVE_LLVM | 521 %!testif HAVE_JIT |
522 %! jit_failcnt (0) | 522 %! jit_failcnt (0) |
523 %! assert (bubble (), [1 2 3]); | 523 %! assert (bubble (), [1 2 3]); |
524 %! assert (jit_failcnt, 0); | 524 %! assert (jit_failcnt, 0); |
525 | 525 |
526 %!testif HAVE_LLVM | 526 %!testif HAVE_JIT |
527 %! jit_failcnt (0) | 527 %! jit_failcnt (0) |
528 %! a = 0; | 528 %! a = 0; |
529 %! b = 1; | 529 %! b = 1; |
530 %! for i=1:1e3 | 530 %! for i=1:1e3 |
531 %! for j=1:2 | 531 %! for j=1:2 |
536 %! assert (b, 1); | 536 %! assert (b, 1); |
537 %! assert (jit_failcnt, 0); | 537 %! assert (jit_failcnt, 0); |
538 | 538 |
539 %!xtest | 539 %!xtest |
540 %! ## FIXME: No support for functions with complex input prototypes | 540 %! ## FIXME: No support for functions with complex input prototypes |
541 %! ## testif HAVE_LLVM | 541 %! ## testif HAVE_JIT |
542 %! jit_failcnt (0) | 542 %! jit_failcnt (0) |
543 %! a = [1+1i 1+2i]; | 543 %! a = [1+1i 1+2i]; |
544 %! b = 0; | 544 %! b = 0; |
545 %! while (1) | 545 %! while (1) |
546 %! b = a(1); | 546 %! b = a(1); |
553 %! for i=1:1e7 | 553 %! for i=1:1e7 |
554 %! XXX; | 554 %! XXX; |
555 %! endfor | 555 %! endfor |
556 %!endfunction | 556 %!endfunction |
557 | 557 |
558 %!testif HAVE_LLVM | 558 %!testif HAVE_JIT |
559 %! jit_failcnt (0) | 559 %! jit_failcnt (0) |
560 %! lasterr (""); | 560 %! lasterr (""); |
561 %! try | 561 %! try |
562 %! test_undef (); | 562 %! test_undef (); |
563 %! end_try_catch | 563 %! end_try_catch |
567 %!shared id | 567 %!shared id |
568 %! id = @(x) x; | 568 %! id = @(x) x; |
569 | 569 |
570 %!xtest | 570 %!xtest |
571 %! ## FIXME: No support for functions with complex input prototypes | 571 %! ## FIXME: No support for functions with complex input prototypes |
572 %! ## testif HAVE_LLVM | 572 %! ## testif HAVE_JIT |
573 %! jit_failcnt (0) | 573 %! jit_failcnt (0) |
574 %! assert (id (1), 1); | 574 %! assert (id (1), 1); |
575 %! assert (id (1+1i), 1+1i); | 575 %! assert (id (1+1i), 1+1i); |
576 %! assert (id (1, 2), 1); | 576 %! assert (id (1, 2), 1); |
577 %! assert (jit_failcnt, 0); | 577 %! assert (jit_failcnt, 0); |
578 | 578 |
579 %!testif HAVE_LLVM | 579 %!testif HAVE_JIT |
580 %! jit_failcnt (0) | 580 %! jit_failcnt (0) |
581 %! lasterr (""); | 581 %! lasterr (""); |
582 %! try | 582 %! try |
583 %! id (); | 583 %! id (); |
584 %! end_try_catch | 584 %! end_try_catch |
585 %! assert (strncmp (lasterr (), "'x' undefined near", 18)); | 585 %! assert (strncmp (lasterr (), "'x' undefined near", 18)); |
586 %! assert (jit_failcnt, 0); | 586 %! assert (jit_failcnt, 0); |
587 | 587 |
588 ## Restore JIT settings | 588 ## Restore JIT settings |
589 %!testif HAVE_LLVM | 589 %!testif HAVE_JIT |
590 %! global __old_jit_enable__; | 590 %! global __old_jit_enable__; |
591 %! global __old_jit_startcnt__; | 591 %! global __old_jit_startcnt__; |
592 %! jit_enable (__old_jit_enable__); | 592 %! jit_enable (__old_jit_enable__); |
593 %! jit_startcnt (__old_jit_startcnt__); | 593 %! jit_startcnt (__old_jit_startcnt__); |
594 %! clear -g __old_jit_enable__ __old_jit_startcnt__; | 594 %! clear -g __old_jit_enable__ __old_jit_startcnt__; |