Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright Contributors to the OpenVDB Project | ||
2 | // SPDX-License-Identifier: MPL-2.0 | ||
3 | |||
4 | #include <openvdb_ax/ast/AST.h> | ||
5 | #include <openvdb_ax/ast/Scanners.h> | ||
6 | #include <openvdb_ax/ast/PrintTree.h> | ||
7 | #include <openvdb_ax/Exceptions.h> | ||
8 | |||
9 | #include "../util.h" | ||
10 | |||
11 | #include <cppunit/extensions/HelperMacros.h> | ||
12 | |||
13 | #include <string> | ||
14 | |||
15 | using namespace openvdb::ax::ast; | ||
16 | using namespace openvdb::ax::ast::tokens; | ||
17 | |||
18 | namespace { | ||
19 | |||
20 | static const unittest_util::CodeTests tests = | ||
21 | { | ||
22 | { "for (int32 i = 0; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
23 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
24 | new Block(), | ||
25 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
26 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
27 | }, | ||
28 | { "for(int32 i = 0; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
29 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
30 | new Block(), | ||
31 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
32 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
33 | }, | ||
34 | { "for (int32 i = 0;i < 10;++i) ;", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
35 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
36 | new Block(), | ||
37 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
38 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
39 | }, | ||
40 | { "for (i; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
41 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
42 | new Block(), | ||
43 | new Local("i"), | ||
44 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
45 | }, | ||
46 | { "for (@i; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
47 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
48 | new Block(), | ||
49 | new Attribute("i", CoreType::FLOAT, true), | ||
50 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
51 | }, | ||
52 | { "for (!i; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
53 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
54 | new Block(), | ||
55 | new UnaryOperator(new Local("i"), OperatorToken::NOT), | ||
56 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
57 | }, | ||
58 | { "for (i = 0; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
59 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
60 | new Block(), | ||
61 | new AssignExpression(new Local("i"), new Value<int32_t>(0)), | ||
62 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
63 | }, | ||
64 | { "for (i+j; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
65 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
66 | new Block(), | ||
67 | new BinaryOperator(new Local("i"), new Local("j"), OperatorToken::PLUS), | ||
68 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
69 | }, | ||
70 | { "for (func(i); i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
71 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
72 | new Block(), | ||
73 | new FunctionCall("func", new Local("i")), | ||
74 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
75 | }, | ||
76 | { "for (1; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
77 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
78 | new Block(), | ||
79 | new Value<int32_t>(1), | ||
80 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
81 | }, | ||
82 | { "for (float$ext; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
83 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
84 | new Block(), | ||
85 | new ExternalVariable("ext", CoreType::FLOAT), | ||
86 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
87 | }, | ||
88 | { "for (i++; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
89 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
90 | new Block(), | ||
91 | new Crement(new Local("i"), Crement::Operation::Increment, true), | ||
92 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
93 | }, | ||
94 | { "for ({1,2.0,3.0f}; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
95 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
96 | new Block(), | ||
97 | new ArrayPack({new Value<int32_t>(1), new Value<double>(2.0), new Value<float>(3.0f)}), | ||
98 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
99 | }, | ||
100 | { "for (1,2.0,3.0f; (i < 10, i > 10); (++i, --i)) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
101 | new CommaOperator({ | ||
102 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
103 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::MORETHAN) | ||
104 | }), | ||
105 | new Block(), | ||
106 | new CommaOperator({ | ||
107 | new Value<int32_t>(1), new Value<double>(2.0), new Value<float>(3.0f) | ||
108 | }), | ||
109 | new CommaOperator({ | ||
110 | new Crement(new Local("i"), Crement::Operation::Increment, false), | ||
111 | new Crement(new Local("i"), Crement::Operation::Decrement, false), | ||
112 | }) | ||
113 | )) | ||
114 | }, | ||
115 | { "for (++i; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
116 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
117 | new Block(), | ||
118 | new Crement(new Local("i"), Crement::Operation::Increment, false), | ||
119 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
120 | }, | ||
121 | { "for (x[2]; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
122 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
123 | new Block(), | ||
124 | new ArrayUnpack(new Local("x"), new Value<int32_t>(2)), | ||
125 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
126 | }, | ||
127 | { "for ((x[2]); i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
128 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
129 | new Block(), | ||
130 | new ArrayUnpack(new Local("x"), new Value<int32_t>(2)), | ||
131 | new Crement(new Local("i"), Crement::Operation::Increment, false))) | ||
132 | }, | ||
133 | { "for (; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
134 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
135 | new Block(), | ||
136 | nullptr, | ||
137 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
138 | }, | ||
139 | { "for (int32 i = 0; i < 10; ++i, ++j) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
140 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
141 | new Block(), | ||
142 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
143 | new CommaOperator({ | ||
144 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false), | ||
145 | new Crement(new Local("j"), Crement::Operation::Increment, /*post*/false) | ||
146 | }))) | ||
147 | }, | ||
148 | { "for (i = 0; i < 10; ++i, ++j) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
149 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
150 | new Block(), | ||
151 | new AssignExpression(new Local("i"), new Value<int32_t>(0)), | ||
152 | new CommaOperator({ | ||
153 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false), | ||
154 | new Crement(new Local("j"), Crement::Operation::Increment, /*post*/false) | ||
155 | }))) | ||
156 | }, | ||
157 | { "for (int32 i = 0; i; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
158 | new Local("i"), | ||
159 | new Block(), | ||
160 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
161 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
162 | }, | ||
163 | { "for (int32 i = 0; func(i); ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
164 | new FunctionCall("func", new Local("i")), | ||
165 | new Block(), | ||
166 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
167 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
168 | }, | ||
169 | { "for (int32 i = 0; int32 j = func(i); ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
170 | new DeclareLocal(CoreType::INT32, new Local("j"),new FunctionCall("func", new Local("i"))), | ||
171 | new Block(), | ||
172 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
173 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
174 | }, | ||
175 | { "for (; i < 10;) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
176 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
177 | new Block())) | ||
178 | }, | ||
179 | { "for (;;) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
180 | new Value<bool>(true), | ||
181 | new Block())) | ||
182 | }, | ||
183 | { "for (;;) { 1,2,3 };", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
184 | new Value<bool>(true), | ||
185 | new Block(new ArrayPack({ | ||
186 | new Value<int32_t>(1), | ||
187 | new Value<int32_t>(2), | ||
188 | new Value<int32_t>(3) | ||
189 | })))) | ||
190 | }, | ||
191 | { "for (;;) { 1,2,3; }", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
192 | new Value<bool>(true), | ||
193 | new Block(new CommaOperator({ | ||
194 | new Value<int32_t>(1), | ||
195 | new Value<int32_t>(2), | ||
196 | new Value<int32_t>(3) | ||
197 | })))) | ||
198 | }, | ||
199 | { "for (int32 i = 0, j = 0, k; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
200 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
201 | new Block(), | ||
202 | new StatementList({new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
203 | new DeclareLocal(CoreType::INT32, new Local("j"), new Value<int32_t>(0)), | ||
204 | new DeclareLocal( CoreType::INT32, new Local("k"))}), | ||
205 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
206 | }, | ||
207 | { "for (i = 0, j = 0; i < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
208 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
209 | new Block(), | ||
210 | new CommaOperator({ | ||
211 | new AssignExpression(new Local("i"), new Value<int32_t>(0)), | ||
212 | new AssignExpression(new Local("j"), new Value<int32_t>(0)) | ||
213 | }), | ||
214 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
215 | }, | ||
216 | { "for (int32 i = 0; i < 10, j < 10; ++i) {}", Node::Ptr(new Loop(tokens::LoopToken::FOR, | ||
217 | new CommaOperator({ | ||
218 | new BinaryOperator(new Local("i"), new Value<int32_t>(10), OperatorToken::LESSTHAN), | ||
219 | new BinaryOperator(new Local("j"), new Value<int32_t>(10), OperatorToken::LESSTHAN) | ||
220 | }), | ||
221 | new Block(), | ||
222 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
223 | new Crement(new Local("i"), Crement::Operation::Increment, /*post*/false))) | ||
224 | }, | ||
225 | { "while (int32 i = 0) {}", Node::Ptr(new Loop(tokens::LoopToken::WHILE, | ||
226 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
227 | new Block())) | ||
228 | }, | ||
229 | { "while (i = 0) {}", Node::Ptr(new Loop(tokens::LoopToken::WHILE, | ||
230 | new AssignExpression(new Local("i"), new Value<int32_t>(0)), | ||
231 | new Block())) | ||
232 | }, | ||
233 | { "while ((a,b,c)) {}", Node::Ptr(new Loop(tokens::LoopToken::WHILE, | ||
234 | new CommaOperator({ | ||
235 | new Local("a"), | ||
236 | new Local("b"), | ||
237 | new Local("c") | ||
238 | }), | ||
239 | new Block())) | ||
240 | }, | ||
241 | { "while (i < 0, j = 10) ;", Node::Ptr(new Loop(tokens::LoopToken::WHILE, | ||
242 | new CommaOperator({ | ||
243 | new BinaryOperator(new Local("i"), new Value<int32_t>(0), OperatorToken::LESSTHAN), | ||
244 | new AssignExpression(new Local("j"), new Value<int32_t>(10)) | ||
245 | }), | ||
246 | new Block())) | ||
247 | }, | ||
248 | { "while (i) { 1,2,3 };", Node::Ptr(new Loop(tokens::LoopToken::WHILE, | ||
249 | new Local("i"), | ||
250 | new Block(new ArrayPack({ | ||
251 | new Value<int32_t>(1), | ||
252 | new Value<int32_t>(2), | ||
253 | new Value<int32_t>(3) | ||
254 | })))) | ||
255 | }, | ||
256 | { "while (i) { 1,2,3; }", Node::Ptr(new Loop(tokens::LoopToken::WHILE, | ||
257 | new Local("i"), | ||
258 | new Block(new CommaOperator({ | ||
259 | new Value<int32_t>(1), | ||
260 | new Value<int32_t>(2), | ||
261 | new Value<int32_t>(3) | ||
262 | })))) | ||
263 | }, | ||
264 | { "do {} while (i < 0, j = 10)", Node::Ptr(new Loop(tokens::LoopToken::DO, | ||
265 | new CommaOperator({ | ||
266 | new BinaryOperator(new Local("i"), new Value<int32_t>(0), OperatorToken::LESSTHAN), | ||
267 | new AssignExpression(new Local("j"), new Value<int32_t>(10)) | ||
268 | }), | ||
269 | new Block())) | ||
270 | }, | ||
271 | { "do ; while (int32 i = 0)", Node::Ptr(new Loop(tokens::LoopToken::DO, | ||
272 | new DeclareLocal(CoreType::INT32, new Local("i"), new Value<int32_t>(0)), | ||
273 | new Block())) | ||
274 | }, | ||
275 | { "do ; while ((a,b,c))", Node::Ptr(new Loop(tokens::LoopToken::DO, | ||
276 | new CommaOperator({ | ||
277 | new Local("a"), | ||
278 | new Local("b"), | ||
279 | new Local("c") | ||
280 | }), | ||
281 | new Block())) | ||
282 | }, | ||
283 | { "do ; while (a,b,c)", Node::Ptr(new Loop(tokens::LoopToken::DO, | ||
284 | new CommaOperator({ | ||
285 | new Local("a"), | ||
286 | new Local("b"), | ||
287 | new Local("c") | ||
288 | }), | ||
289 | new Block())) | ||
290 | }, | ||
291 | { "do { 1,2,3 }; while (i) ", Node::Ptr(new Loop(tokens::LoopToken::DO, | ||
292 | new Local("i"), | ||
293 | new Block(new ArrayPack({ | ||
294 | new Value<int32_t>(1), | ||
295 | new Value<int32_t>(2), | ||
296 | new Value<int32_t>(3) | ||
297 | })))) | ||
298 | }, | ||
299 | { "do { 1,2,3; } while (i) ", Node::Ptr(new Loop(tokens::LoopToken::DO, | ||
300 | new Local("i"), | ||
301 | new Block(new CommaOperator({ | ||
302 | new Value<int32_t>(1), | ||
303 | new Value<int32_t>(2), | ||
304 | new Value<int32_t>(3) | ||
305 | })))) | ||
306 | } | ||
307 | }; | ||
308 | |||
309 | } | ||
310 | |||
311 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | class TestLoopNode : public CppUnit::TestCase |
312 | { | ||
313 | public: | ||
314 | |||
315 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
4 | CPPUNIT_TEST_SUITE(TestLoopNode); |
316 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
6 | CPPUNIT_TEST(testSyntax); |
317 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
6 | CPPUNIT_TEST(testASTNode); |
318 |
4/8✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
|
4 | CPPUNIT_TEST_SUITE_END(); |
319 | |||
320 |
20/40✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 42 times.
✓ Branch 8 taken 1 times.
✓ Branch 10 taken 42 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 42 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 42 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 42 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 42 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 42 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 42 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 42 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 42 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 42 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 42 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 42 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 42 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 42 times.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✓ Branch 51 taken 42 times.
✓ Branch 53 taken 42 times.
✗ Branch 54 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
|
129 | void testSyntax() { TEST_SYNTAX_PASSES(tests); } |
321 | void testASTNode(); | ||
322 | }; | ||
323 | |||
324 | CPPUNIT_TEST_SUITE_REGISTRATION(TestLoopNode); | ||
325 | |||
326 | 1 | void TestLoopNode::testASTNode() | |
327 | { | ||
328 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 1 times.
|
43 | for (const auto& test : tests) { |
329 |
1/2✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
|
42 | const std::string& code = test.first; |
330 | const Node* expected = test.second.get(); | ||
331 |
1/2✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
|
42 | const Tree::ConstPtr tree = parse(code.c_str()); |
332 |
11/22✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 42 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 42 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 42 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 42 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 42 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 42 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 42 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 42 times.
✗ Branch 29 not taken.
✓ Branch 41 taken 42 times.
✗ Branch 42 not taken.
|
126 | CPPUNIT_ASSERT_MESSAGE(ERROR_MSG("No AST returned", code), static_cast<bool>(tree)); |
333 | |||
334 | // get the first statement | ||
335 | const Node* result = tree->child(0)->child(0); | ||
336 |
6/12✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 42 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 42 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 42 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 42 times.
✗ Branch 17 not taken.
|
42 | CPPUNIT_ASSERT(result); |
337 |
12/24✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 42 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 42 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 42 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 42 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 42 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 42 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 42 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 42 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 42 times.
✗ Branch 32 not taken.
✓ Branch 45 taken 42 times.
✗ Branch 46 not taken.
|
126 | CPPUNIT_ASSERT_MESSAGE(ERROR_MSG("Invalid AST node", code), |
338 | Node::LoopNode == result->nodetype()); | ||
339 | |||
340 | std::vector<const Node*> resultList, expectedList; | ||
341 |
1/2✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
|
42 | linearize(*result, resultList); |
342 |
1/2✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
|
42 | linearize(*expected, expectedList); |
343 | |||
344 |
2/4✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
|
42 | if (!unittest_util::compareLinearTrees(expectedList, resultList)) { |
345 | ✗ | std::ostringstream os; | |
346 | ✗ | os << "\nExpected:\n"; | |
347 | ✗ | openvdb::ax::ast::print(*expected, true, os); | |
348 | ✗ | os << "Result:\n"; | |
349 | ✗ | openvdb::ax::ast::print(*result, true, os); | |
350 | ✗ | CPPUNIT_FAIL(ERROR_MSG("Mismatching Trees for Loop code", code) + os.str()); | |
351 | } | ||
352 | } | ||
353 | 1 | } | |
354 | |||
355 |