annotate test/jit.tst @ 17744:d63878346099

maint: Update copyright notices for release.
author John W. Eaton <jwe@octave.org>
date Wed, 23 Oct 2013 22:09:27 -0400
parents a31b54b5f84a
children efa4572997ba 446c46af4b42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17337
diff changeset
1 ## Copyright (C) 2012-2013 Max Brister
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
2 ##
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
3 ## This file is part of Octave.
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
4 ##
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by the
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
7 ## Free Software Foundation; either version 3 of the License, or (at your
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
8 ## option) any later version.
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
9 ##
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
13 ## for more details.
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
14 ##
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
18
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
19 ## Author: Max Brister <max@2bass.com>
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
20
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
21 ## Turn on JIT and set defaults before running tests
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
22 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
23 %! global __old_jit_enable__;
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
24 %! global __old_jit_startcnt__;
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
25 %! __old_jit_enable__ = jit_enable (true);
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
26 %! __old_jit_startcnt__ = jit_startcnt (1000);
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
27
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
28 ## Test some simple cases that compile.
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
29
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
30 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
31 %! for i=1:1e6
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
32 %! if (i < 5)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
33 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
34 %! else
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
35 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
36 %! endif
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
37 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
38 %! assert (i, 1);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
39
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
40 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
41 %! while (1)
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
42 %! if (1)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
43 %! break;
17337
a31b54b5f84a Use only 1 space between '%!' and start of test/demo code.
Rik <rik@octave.org>
parents: 17311
diff changeset
44 %! else
a31b54b5f84a Use only 1 space between '%!' and start of test/demo code.
Rik <rik@octave.org>
parents: 17311
diff changeset
45 %! break;
a31b54b5f84a Use only 1 space between '%!' and start of test/demo code.
Rik <rik@octave.org>
parents: 17311
diff changeset
46 %! endif
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
47 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
48
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
49 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
50 %! for i=1:1e6
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
51 %! if (i == 100)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
52 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
53 %! endif
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
54 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
55 %! assert (i, 100);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
56
17311
56404cdcb723 Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents: 17309
diff changeset
57 ## Also test parfor keyword
56404cdcb723 Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents: 17309
diff changeset
58 %!testif HAVE_LLVM
56404cdcb723 Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents: 17309
diff changeset
59 %! parfor i=1:1e6
56404cdcb723 Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents: 17309
diff changeset
60 %! if (i == 100)
56404cdcb723 Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents: 17309
diff changeset
61 %! break;
56404cdcb723 Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents: 17309
diff changeset
62 %! endif
56404cdcb723 Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents: 17309
diff changeset
63 %! endparfor
56404cdcb723 Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents: 17309
diff changeset
64 %! assert (i, 100);
56404cdcb723 Correct parfor keyword documentation and add some %!tests.
Rik <rik@octave.org>
parents: 17309
diff changeset
65
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
66 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
67 %! inc = 1e-5;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
68 %! result = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
69 %! for ii = 0:inc:1
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
70 %! result = result + inc * (1/3 * ii * ii);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
71 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
72 %! assert (abs (result - 1/9) < 1e-5);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
73
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
74 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
75 %! inc = 1e-5;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
76 %! result = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
77 %! for ii = 0:inc:1
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
78 %! ## the ^ operator's result is complex
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
79 %! result = result + inc * (1/3 * ii ^ 2);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
80 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
81 %! assert (abs (result - 1/9) < 1e-5);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
82
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
83 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
84 %! temp = 1+1i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
85 %! nan = NaN;
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
86 %! while (1)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
87 %! temp = temp - 1i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
88 %! temp = temp * nan;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
89 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
90 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
91 %! assert (imag (temp), 0);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
92
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
93 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
94 %! temp = 1+1i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
95 %! nan = NaN+1i;
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
96 %! while (1)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
97 %! nan = nan - 1i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
98 %! temp = temp - 1i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
99 %! temp = temp * nan;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
100 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
101 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
102 %! assert (imag (temp), 0);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
103
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
104 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
105 %! temp = 1+1i;
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
106 %! while (1)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
107 %! temp = temp * 5;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
108 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
109 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
110 %! assert (temp, 5+5i);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
111
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
112 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
113 %! nr = 1001;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
114 %! mat = zeros (1, nr);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
115 %! for i = 1:nr
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
116 %! mat(i) = i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
117 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
118 %! assert (mat == 1:nr);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
119
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
120 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
121 %! nr = 1001;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
122 %! mat = 1:nr;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
123 %! mat(end) = 0; # force mat to a matrix
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
124 %! total = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
125 %! for i = 1:nr
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
126 %! total = mat(i) + total;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
127 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
128 %! assert (sum (mat) == total);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
129
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
130 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
131 %! nr = 1001;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
132 %! mat = [3 1 5];
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
133 %! try
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
134 %! for i = 1:nr
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
135 %! if (i > 500)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
136 %! result = mat(100);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
137 %! else
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
138 %! result = i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
139 %! endif
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
140 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
141 %! catch
17309
5a65b2cc9508 test: Add tests for 'end' form of 'endfor', 'endif', etc.
Rik <rik@octave.org>
parents: 17200
diff changeset
142 %! end_try_catch
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
143 %! assert (result == 500);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
144
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
145 %!function result = gen_test (n)
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
146 %! result = double (rand (1, n) > .01);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
147 %!endfunction
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
148
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
149 %!function z = vectorized (A, K)
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
150 %! temp = ones (1, K);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
151 %! z = conv (A, temp);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
152 %! z = z > K-1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
153 %! z = conv (z, temp);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
154 %! z = z(K:end-K+1);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
155 %! z = z >= 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
156 %!endfunction
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
157
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
158 %!function z = loopy (A, K)
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
159 %! z = A;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
160 %! n = numel (A);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
161 %! counter = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
162 %! for ii=1:n
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
163 %! if (z(ii))
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
164 %! counter = counter + 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
165 %! else
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
166 %! if (counter > 0 && counter < K)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
167 %! z(ii-counter:ii-1) = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
168 %! endif
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
169 %! counter = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
170 %! endif
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
171 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
172 %!
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
173 %! if (counter > 0 && counter < K)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
174 %! z(end-counter+1:end) = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
175 %! endif
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
176 %!endfunction
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
177
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
178 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
179 %! test_set = gen_test (10000);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
180 %! assert (all (vectorized (test_set, 3) == loopy (test_set, 3)));
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
181
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
182 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
183 %! niter = 1001;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
184 %! i = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
185 %! while (i < niter)
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
186 %! i = i + 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
187 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
188 %! assert (i == niter);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
189
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
190 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
191 %! niter = 1001;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
192 %! result = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
193 %! m = [5 10];
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
194 %! for i=1:niter
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
195 %! result = result + m(end);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
196 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
197 %! assert (result == m(end) * niter);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
198
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
199 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
200 %! ndim = 100;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
201 %! result = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
202 %! m = zeros (ndim);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
203 %! m(:) = 1:ndim^2;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
204 %! i = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
205 %! while (i <= ndim)
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
206 %! for j = 1:ndim
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
207 %! result = result + m(i, j);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
208 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
209 %! i = i + 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
210 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
211 %! assert (result == sum (sum (m)));
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
212
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
213 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
214 %! ndim = 100;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
215 %! m = zeros (ndim);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
216 %! i = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
217 %! while (i <= ndim)
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
218 %! for j = 1:ndim
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
219 %! m(i, j) = (j - 1) * ndim + i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
220 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
221 %! i = i + 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
222 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
223 %! m2 = zeros (ndim);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
224 %! m2(:) = 1:(ndim^2);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
225 %! assert (all (m == m2));
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
226
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
227 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
228 %! ndim = 2;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
229 %! m = zeros (ndim, ndim, ndim, ndim);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
230 %! result = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
231 %! i0 = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
232 %! while (i0 <= ndim)
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
233 %! for i1 = 1:ndim
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
234 %! for i2 = 1:ndim
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
235 %! for i3 = 1:ndim
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
236 %! m(i0, i1, i2, i3) = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
237 %! m(i0, i1, i2, i3, 1, 1, 1, 1, 1, 1) = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
238 %! result = result + m(i0, i1, i2, i3);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
239 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
240 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
241 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
242 %! i0 = i0 + 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
243 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
244 %! expected = ones (ndim, ndim, ndim, ndim);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
245 %! assert (all (m == expected));
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
246 %! assert (result == sum (expected (:)));
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
247
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
248 %!function test_divide ()
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
249 %! state = warning ("query", "Octave:divide-by-zero").state;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
250 %! unwind_protect
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
251 %! warning ("error", "Octave:divide-by-zero");
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
252 %! for i=1:1e5
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
253 %! a = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
254 %! a / 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
255 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
256 %! unwind_protect_cleanup
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
257 %! warning (state, "Octave:divide-by-zero");
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
258 %! end_unwind_protect
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
259 %!endfunction
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
260
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
261 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
262 %! lasterr ("");
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
263 %! try
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
264 %! test_divide ();
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
265 %! end_try_catch
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
266 %! assert (strcmp (lasterr (), "division by zero"));
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
267
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
268 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
269 %! while (1)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
270 %! a = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
271 %! result = a / 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
272 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
273 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
274 %! assert (result, 0);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
275
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
276 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
277 %! m = zeros (2, 1001);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
278 %! for i=1:1001
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
279 %! m(end, i) = i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
280 %! m(end - 1, end - i + 1) = i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
281 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
282 %! m2 = zeros (2, 1001);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
283 %! m2(1, :) = fliplr (1:1001);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
284 %! m2(2, :) = 1:1001;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
285 %! assert (m, m2);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
286
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
287 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
288 %! m = [1 2 3];
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
289 %! for i=1:1001
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
290 %! m = sin (m);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
291 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
292 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
293 %! assert (m == sin ([1 2 3]));
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
294
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
295 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
296 %! i = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
297 %! while i < 10
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
298 %! i += 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
299 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
300 %! assert (i == 10);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
301
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
302 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
303 %! i = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
304 %! while i < 10
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
305 %! a = ++i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
306 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
307 %! assert (i == 10);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
308 %! assert (a == 10);
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
309 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
310 %! i = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
311 %! while i < 10
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
312 %! a = i++;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
313 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
314 %! assert (i == 10);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
315 %! assert (a == 9);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
316
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
317 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
318 %! num = 2;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
319 %! a = zeros (1, num);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
320 %! i = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
321 %! while i <= num
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
322 %! a(i) = norm (eye (i));
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
323 %! ++i;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
324 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
325 %! assert (a, ones (1, num));
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
326
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
327 %!function test_compute_idom ()
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
328 %! while (li <= length (l1) && si <= length (s1))
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
329 %! if (l1 (li) < s1 (si))
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
330 %! if (li == si)
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
331 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
332 %! endif;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
333 %! li++;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
334 %! else
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
335 %! si++;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
336 %! endif;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
337 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
338
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
339 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
340 %! lasterr ("");
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
341 %! try
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
342 %! test_compute_idom ();
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
343 %! end_try_catch
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
344 %! assert (! isempty (lasterr ()));
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
345
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
346 %!function x = test_overload (a)
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
347 %! while (1)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
348 %! x = a;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
349 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
350 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
351 %!endfunction
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
352
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
353 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
354 %! assert (test_overload (1), 1);
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
355 %! assert (test_overload ([1 2]), [1 2]);
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
356
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
357 %!function a = bubble (a = [3 2 1])
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
358 %! swapped = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
359 %! n = length (a);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
360 %! while (swapped)
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
361 %! swapped = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
362 %! for i = 1:n-1
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
363 %! if (a(i) > a(i + 1))
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
364 %! swapped = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
365 %! temp = a(i);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
366 %! a(i) = a(i + 1);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
367 %! a(i + 1) = temp;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
368 %! endif
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
369 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
370 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
371 %!endfunction
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
372
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
373 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
374 %! assert (bubble (), [1 2 3]);
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
375
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
376 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
377 %! a = 0;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
378 %! b = 1;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
379 %! for i=1:1e3
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
380 %! for j=1:2
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
381 %! a = a + b;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
382 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
383 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
384 %! assert (a, 2000);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
385 %! assert (b, 1);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
386
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
387 %!testif HAVE_LLVM
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
388 %! a = [1+1i 1+2i];
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
389 %! b = 0;
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
390 %! while (1)
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
391 %! b = a(1);
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
392 %! break;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
393 %! endwhile
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
394 %! assert (b, a(1));
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
395
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
396 %!function test_undef ()
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
397 %! for i=1:1e7
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
398 %! XXX;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
399 %! endfor
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
400 %!endfunction
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
401
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
402 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
403 %! lasterr ("");
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
404 %! try
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
405 %! test_undef ();
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
406 %! end_try_catch
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
407 %! assert (strncmp (lasterr (), "'XXX' undefined near", 20));
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
408
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
409 %!shared id
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
410 %! id = @(x) x;
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
411
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
412 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
413 %! assert (id (1), 1);
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
414 %! assert (id (1+1i), 1+1i);
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
415 %! assert (id (1, 2), 1);
16931
bf4c95a3bba2 jit.tst: Add missing file from previous check-in (c2a57f9c6a2e).
Rik <rik@octave.org>
parents:
diff changeset
416
17200
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
417 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
418 %! lasterr ("");
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
419 %! try
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
420 %! id ();
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
421 %! end_try_catch
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
422 %! assert (strncmp (lasterr (), "'x' undefined near", 18));
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
423
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
424 ## Restore JIT settings
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
425 %!testif HAVE_LLVM
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
426 %! global __old_jit_enable__;
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
427 %! global __old_jit_startcnt__;
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
428 %! jit_enable (__old_jit_enable__);
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
429 %! jit_startcnt (__old_jit_startcnt__);
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
430 %! clear -g __old_jit_enable__ __old_jit_startcnt__;
fe7cb5bb4388 jit.tst: Add code to save/restore JIT state. Only test if HAVE_LLVM is true.
Rik <rik@octave.org>
parents: 16931
diff changeset
431