Mercurial > octave
annotate test/compile/bytecode_if.m @ 32151:72dcb1cef2c9
maint: Strip trailing whitespace from source files.
Modified files: NEWS.8.md, file-editor-tab.cc, call-stack.cc,
compile.cc, perms.cc, stack-frame.cc, ov-base.cc, ov-fcn-handle.cc,
ov-fcn-handle.h, ov-fcn.cc, ov-oncleanup.h, ov-range.cc, ov-range.h,
ov-ref.cc, ov-ref.h, ov-scalar.h, ov-struct.cc, ov-vm.h,
pt-bytecode-vm-internal.h, pt-bytecode-vm.cc, pt-bytecode-vm.h,
pt-bytecode-walk.cc, pt-eval.cc, isuniform.m, inputParser.m, xlim.m,
ylim.m, zlim.m, movfun.m, std.m, var.m, isstrprop.m, bench.m,
bench.py, bytecode.tst, bytecode_anon_handles.m, bytecode_cell.m,
bytecode_dountil.m, bytecode_end.m, bytecode_errors.m,
bytecode_eval_1.m, bytecode_for.m, bytecode_global_1.m, bytecode_if.m,
bytecode_leaks.m, bytecode_matrix.m, bytecode_multi_assign.m,
bytecode_persistant.m, bytecode_range.m, bytecode_trycatch.m,
bytecode_unwind.m, bytecode_while.m, bytecode_disp.m,
bytecode_disp.tst, parser.tst.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 19 Jun 2023 23:21:41 -0400 |
parents | 6e6e99e8a4de |
children | 8e4f14837db2 |
rev | line source |
---|---|
32149 | 1 function bytecode_if() |
2 ctr = 0; | |
3 a = 1; | |
4 b = 0; | |
5 | |
6 if a | |
7 __printf_assert__ ("%d ", ctr++); | |
8 end | |
9 | |
10 if a | |
11 __printf_assert__ ("%d ", ctr++); | |
12 else | |
13 __printf_assert__ ("booo "); | |
14 end | |
15 | |
16 if a | |
17 __printf_assert__ ("%d ", ctr++); | |
18 elseif a | |
19 __printf_assert__ ("booo "); | |
20 else | |
21 __printf_assert__ ("booo "); | |
22 end | |
23 | |
24 if b | |
25 __printf_assert__ ("booo ", ctr++); | |
26 end | |
27 | |
28 if b | |
29 __printf_assert__ ("booo "); | |
30 else | |
31 __printf_assert__ ("%d ", ctr++); | |
32 end | |
33 | |
34 if b | |
35 __printf_assert__ ("booo "); | |
36 elseif b | |
37 __printf_assert__ ("booo "); | |
38 else | |
39 __printf_assert__ ("%d ", ctr++); | |
32151
72dcb1cef2c9
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
32149
diff
changeset
|
40 end |
32149 | 41 |
42 if b | |
43 __printf_assert__ ("booo "); | |
44 elseif a | |
45 __printf_assert__ ("%d ", ctr++); | |
46 else | |
47 __printf_assert__ ("booo "); | |
48 end | |
49 | |
50 if a | |
51 if a | |
52 if a | |
53 if a | |
54 if a | |
55 if b | |
56 __printf_assert__ ("booo "); | |
57 else | |
58 if a | |
59 if a | |
60 if b | |
61 __printf_assert__ ("booo "); | |
62 elseif a | |
63 if b | |
64 __printf_assert__ ("booo "); | |
65 else | |
66 __printf_assert__ ("%d ", ctr++); | |
67 end | |
68 else | |
69 __printf_assert__ ("booo "); | |
70 end | |
71 end | |
72 end | |
73 end | |
74 end | |
75 else | |
76 __printf_assert__ ("booo "); | |
77 end | |
78 end | |
79 end | |
80 end | |
81 | |
82 if 3 > 2 | |
83 __printf_assert__ ("%d ", ctr++); | |
84 end | |
85 | |
86 if [] | |
87 __printf_assert__ ("booo "); | |
88 end | |
89 | |
90 if ~b | |
91 __printf_assert__ ("%d ", ctr++); | |
92 end | |
93 | |
94 if b | |
95 end | |
96 | |
97 % "Braindead" short circuit | |
98 % | |
99 % We also check that there is a proper short circuit | |
100 if truthy (1) & truthy (2) | |
101 __printf_assert__ ("yay1 "); | |
102 end | |
103 | |
104 if falsy (3) & truthy (4) | |
105 __printf_assert__ ("booo "); | |
106 end | |
107 | |
108 if falsy (5) & falsy (6) | |
109 __printf_assert__ ("booo "); | |
110 end | |
111 | |
112 if truthy (7) & falsy (8) | |
113 __printf_assert__ ("booo "); | |
114 end | |
115 | |
116 if truthy (1)| truthy (2) | |
117 __printf_assert__ ("yay1 "); | |
118 end | |
119 | |
120 if falsy (3) | truthy (4) | |
121 __printf_assert__ ("yay2 "); | |
122 end | |
123 | |
124 if falsy (5) | falsy (6) | |
125 __printf_assert__ ("booo "); | |
126 end | |
127 | |
128 if truthy (7) | falsy (8) | |
129 __printf_assert__ ("yay3 "); | |
130 end | |
131 end | |
132 | |
133 function a = truthy (b) | |
134 __printf_assert__ ("%d ", b); | |
135 a = 1; | |
136 end | |
137 | |
138 function a = falsy (b) | |
139 __printf_assert__ ("%d ", b); | |
140 a = 0; | |
141 end | |
32151
72dcb1cef2c9
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
32149
diff
changeset
|
142 |