|
Lines 11-26
Link Here
|
| 11 |
package org.eclipse.jdt.core.tests.compiler.regression; |
11 |
package org.eclipse.jdt.core.tests.compiler.regression; |
| 12 |
|
12 |
|
| 13 |
import java.util.Map; |
13 |
import java.util.Map; |
| 14 |
|
|
|
| 15 |
import org.eclipse.jdt.internal.compiler.flow.FlowInfo; |
| 16 |
import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo; |
| 17 |
import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo.AssertionFailedException; |
| 18 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
14 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
| 19 |
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; |
|
|
| 20 |
|
| 21 |
import junit.framework.AssertionFailedError; |
| 22 |
import junit.framework.Test; |
15 |
import junit.framework.Test; |
| 23 |
|
16 |
|
|
|
17 |
/* See also NullReferenceImplTests for low level, implementation dependent |
| 18 |
* tests. */ |
| 24 |
public class NullReferenceTest extends AbstractRegressionTest { |
19 |
public class NullReferenceTest extends AbstractRegressionTest { |
| 25 |
|
20 |
|
| 26 |
public NullReferenceTest(String name) { |
21 |
public NullReferenceTest(String name) { |
|
Lines 1730-1744
Link Here
|
| 1730 |
} |
1725 |
} |
| 1731 |
|
1726 |
|
| 1732 |
// null analysis - if/else |
1727 |
// null analysis - if/else |
| 1733 |
// PMT: exactly the case we talked about; what happens is that the first |
|
|
| 1734 |
// if shade doubts upon o; what we could do is to avoid marking in case |
| 1735 |
// of error? not sure this is appropriate though, because of inner code |
| 1736 |
// into the if itself; I believe I somewhat did that on purpose: the latest |
| 1737 |
// wins; completed with o.toString()... |
| 1738 |
// basically, the choice is about what we should do in case of error: |
| 1739 |
// neglect the effect of the error, or propagate this effect; the second |
| 1740 |
// tends to produce less repeated errors (I believe) than the first... |
| 1741 |
// PREMATURE could refine adding a null-dependent reachable mark... not urgent |
| 1742 |
public void test0312_if_else() { |
1728 |
public void test0312_if_else() { |
| 1743 |
this.runNegativeTest( |
1729 |
this.runNegativeTest( |
| 1744 |
new String[] { |
1730 |
new String[] { |
|
Lines 1748-1755
Link Here
|
| 1748 |
" void foo() {\n" + |
1734 |
" void foo() {\n" + |
| 1749 |
" Object o = new Object();\n" + |
1735 |
" Object o = new Object();\n" + |
| 1750 |
" if (o == null) { /* */ }\n" + // complain |
1736 |
" if (o == null) { /* */ }\n" + // complain |
| 1751 |
" if (o != null) { /* */ }\n" + // quiet |
1737 |
" if (o != null) { /* */ }\n" + |
| 1752 |
" o.toString();\n" + // complain |
1738 |
" o.toString();\n" + |
| 1753 |
" }\n" + |
1739 |
" }\n" + |
| 1754 |
"}\n"}, |
1740 |
"}\n"}, |
| 1755 |
"----------\n" + |
1741 |
"----------\n" + |
|
Lines 2376-2381
Link Here
|
| 2376 |
""); |
2362 |
""); |
| 2377 |
} |
2363 |
} |
| 2378 |
|
2364 |
|
|
|
2365 |
// null analysis - if/else nested with unknown protection: unknown cannot protect |
| 2366 |
public void test0339_if_else_nested() { |
| 2367 |
this.runNegativeTest( |
| 2368 |
new String[] { |
| 2369 |
"X.java", |
| 2370 |
"public class X {\n" + |
| 2371 |
" void foo(Object o, boolean b) {\n" + |
| 2372 |
" if (o == null || b) {\n" + |
| 2373 |
" if (bar() == o) {\n" + |
| 2374 |
" o.toString();\n" + |
| 2375 |
" }\n" + |
| 2376 |
" }\n" + |
| 2377 |
" }\n" + |
| 2378 |
" Object bar() {\n" + |
| 2379 |
" return new Object();\n" + |
| 2380 |
" }\n" + |
| 2381 |
"}"}, |
| 2382 |
"----------\n" + |
| 2383 |
"1. ERROR in X.java (at line 5)\n" + |
| 2384 |
" o.toString();\n" + |
| 2385 |
" ^\n" + |
| 2386 |
"The variable o may be null\n" + |
| 2387 |
"----------\n"); |
| 2388 |
} |
| 2389 |
|
| 2390 |
// null analysis - if/else nested |
| 2391 |
public void test0340_if_else_nested() { |
| 2392 |
this.runNegativeTest( |
| 2393 |
new String[] { |
| 2394 |
"X.java", |
| 2395 |
"public class X {\n" + |
| 2396 |
" void foo(Object o) {\n" + |
| 2397 |
" if (o == null) {\n" + |
| 2398 |
" if (bar() == o) {\n" + |
| 2399 |
" o.toString();\n" + |
| 2400 |
" }\n" + |
| 2401 |
" }\n" + |
| 2402 |
" }\n" + |
| 2403 |
" Object bar() {\n" + |
| 2404 |
" return new Object();\n" + |
| 2405 |
" }\n" + |
| 2406 |
"}"}, |
| 2407 |
"----------\n" + |
| 2408 |
"1. ERROR in X.java (at line 5)\n" + |
| 2409 |
" o.toString();\n" + |
| 2410 |
" ^\n" + |
| 2411 |
"The variable o can only be null; it was either set to null or checked for null when last used\n" + |
| 2412 |
"----------\n"); |
| 2413 |
} |
| 2414 |
|
| 2415 |
// null analysis - if/else nested |
| 2416 |
public void test0341_if_else_nested() { |
| 2417 |
this.runNegativeTest( |
| 2418 |
new String[] { |
| 2419 |
"X.java", |
| 2420 |
"public class X {\n" + |
| 2421 |
" void foo(Object o1, Object o2, boolean b) {\n" + |
| 2422 |
" if (o1 == null || b) {\n" + |
| 2423 |
" if (o1 == o2) {\n" + |
| 2424 |
" o1.toString();\n" + |
| 2425 |
" }\n" + |
| 2426 |
" }\n" + |
| 2427 |
" }\n" + |
| 2428 |
"}"}, |
| 2429 |
"----------\n" + |
| 2430 |
"1. ERROR in X.java (at line 5)\n" + |
| 2431 |
" o1.toString();\n" + |
| 2432 |
" ^^\n" + |
| 2433 |
"The variable o1 may be null\n" + |
| 2434 |
"----------\n"); |
| 2435 |
} |
| 2436 |
|
| 2437 |
// null analysis - if/else nested |
| 2438 |
public void test0342_if_else_nested() { |
| 2439 |
this.runNegativeTest( |
| 2440 |
new String[] { |
| 2441 |
"X.java", |
| 2442 |
"public class X {\n" + |
| 2443 |
" void foo(Object o1, Object o2, boolean b) {\n" + |
| 2444 |
" if (o1 == null || b) {\n" + |
| 2445 |
" if (o2 == o1) {\n" + |
| 2446 |
" o1.toString();\n" + |
| 2447 |
" }\n" + |
| 2448 |
" }\n" + |
| 2449 |
" }\n" + |
| 2450 |
"}"}, |
| 2451 |
"----------\n" + |
| 2452 |
"1. ERROR in X.java (at line 5)\n" + |
| 2453 |
" o1.toString();\n" + |
| 2454 |
" ^^\n" + |
| 2455 |
"The variable o1 may be null\n" + |
| 2456 |
"----------\n"); |
| 2457 |
} |
| 2458 |
|
| 2379 |
// null analysis -- while |
2459 |
// null analysis -- while |
| 2380 |
public void test0401_while() { |
2460 |
public void test0401_while() { |
| 2381 |
this.runNegativeTest( |
2461 |
this.runNegativeTest( |
|
Lines 3511-3517
Link Here
|
| 3511 |
|
3591 |
|
| 3512 |
// null analysis - while |
3592 |
// null analysis - while |
| 3513 |
// TODO (maxime) https://bugs.eclipse.org/bugs/show_bug.cgi?id=133131 |
3593 |
// TODO (maxime) https://bugs.eclipse.org/bugs/show_bug.cgi?id=133131 |
| 3514 |
public void _test0451_while_nested() { |
3594 |
// fixed along 127570, do the reporting |
|
|
3595 |
public void test0451_while_nested() { |
| 3515 |
this.runNegativeTest( |
3596 |
this.runNegativeTest( |
| 3516 |
new String[] { |
3597 |
new String[] { |
| 3517 |
"X.java", |
3598 |
"X.java", |
|
Lines 3526-3532
Link Here
|
| 3526 |
" if (o != null) { /* */ }\n" + |
3607 |
" if (o != null) { /* */ }\n" + |
| 3527 |
" }\n" + |
3608 |
" }\n" + |
| 3528 |
"}"}, |
3609 |
"}"}, |
| 3529 |
"ERR"); |
3610 |
"----------\n" + |
|
|
3611 |
"1. ERROR in X.java (at line 9)\n" + |
| 3612 |
" if (o != null) { /* */ }\n" + |
| 3613 |
" ^\n" + |
| 3614 |
"The variable o cannot be null; it was either set to a non-null value or assumed to be non-null when last used\n" + |
| 3615 |
"----------\n"); |
| 3530 |
} |
3616 |
} |
| 3531 |
|
3617 |
|
| 3532 |
// TODO (maxime) https://bugs.eclipse.org/bugs/show_bug.cgi?id=123399 |
3618 |
// TODO (maxime) https://bugs.eclipse.org/bugs/show_bug.cgi?id=123399 |
|
Lines 5357-5365
Link Here
|
| 5357 |
} |
5443 |
} |
| 5358 |
|
5444 |
|
| 5359 |
// null analysis -- for |
5445 |
// null analysis -- for |
| 5360 |
// contrast this with #311 |
5446 |
// changed with https://bugs.eclipse.org/bugs/show_bug.cgi?id=127570 |
|
|
5447 |
// we are now able to see that x2 is reinitialized with x1, which is unknown |
| 5361 |
public void test0726_for() { |
5448 |
public void test0726_for() { |
| 5362 |
this.runNegativeTest( |
5449 |
this.runConformTest( |
| 5363 |
new String[] { |
5450 |
new String[] { |
| 5364 |
"X.java", |
5451 |
"X.java", |
| 5365 |
"public class X {\n" + |
5452 |
"public class X {\n" + |
|
Lines 5373-5384
Link Here
|
| 5373 |
" }\n" + |
5460 |
" }\n" + |
| 5374 |
" }\n" + |
5461 |
" }\n" + |
| 5375 |
"}\n"}, |
5462 |
"}\n"}, |
| 5376 |
"----------\n" + |
5463 |
""); |
| 5377 |
"1. ERROR in X.java (at line 8)\n" + |
|
|
| 5378 |
" x2.toString();\n" + |
| 5379 |
" ^^\n" + |
| 5380 |
"The variable x2 may be null\n" + |
| 5381 |
"----------\n"); |
| 5382 |
} |
5464 |
} |
| 5383 |
|
5465 |
|
| 5384 |
// null analysis -- for |
5466 |
// null analysis -- for |
|
Lines 5587-5592
Link Here
|
| 5587 |
} |
5669 |
} |
| 5588 |
} |
5670 |
} |
| 5589 |
|
5671 |
|
|
|
5672 |
// null analysis - for |
| 5673 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127570 |
| 5674 |
public void test0736_for_embedded_lazy_init() { |
| 5675 |
this.runConformTest( |
| 5676 |
new String[] { |
| 5677 |
"X.java", |
| 5678 |
"class X {\n" + |
| 5679 |
" public boolean foo() {\n" + |
| 5680 |
" Boolean b = null;\n" + |
| 5681 |
" for (int i = 0; i < 1; i++) {\n" + |
| 5682 |
" if (b == null) {\n" + |
| 5683 |
" b = Boolean.TRUE;\n" + |
| 5684 |
" }\n" + |
| 5685 |
" if (b.booleanValue()) {\n" + // quiet |
| 5686 |
" return b.booleanValue();\n" + |
| 5687 |
" }\n" + |
| 5688 |
" }\n" + |
| 5689 |
" return false;\n" + |
| 5690 |
" }\n" + |
| 5691 |
"}"}, |
| 5692 |
""); |
| 5693 |
} |
| 5694 |
|
| 5695 |
// null analysis - for with unknown protection: unknown cannot protect anything |
| 5696 |
// suggested by https://bugs.eclipse.org/bugs/show_bug.cgi?id=127570 |
| 5697 |
public void test0737_for_unknown_protection() { |
| 5698 |
this.runNegativeTest( |
| 5699 |
new String[] { |
| 5700 |
"X.java", |
| 5701 |
"class X {\n" + |
| 5702 |
" public boolean foo(Boolean p) {\n" + |
| 5703 |
" Boolean b = null;\n" + |
| 5704 |
" for (int i = 0; i < 1; i++) {\n" + |
| 5705 |
" if (b == p) {\n" + // tells us that p is null as well |
| 5706 |
" // empty\n" + |
| 5707 |
" }\n" + |
| 5708 |
" else {\n" + |
| 5709 |
" continue;\n" + |
| 5710 |
" }\n" + |
| 5711 |
" if (b.booleanValue()) {\n" + // complain b can only be null |
| 5712 |
" return b.booleanValue();\n" + |
| 5713 |
" }\n" + |
| 5714 |
" }\n" + |
| 5715 |
" return false;\n" + |
| 5716 |
" }\n" + |
| 5717 |
"}"}, |
| 5718 |
"----------\n" + |
| 5719 |
"1. ERROR in X.java (at line 11)\n" + |
| 5720 |
" if (b.booleanValue()) {\n" + |
| 5721 |
" ^\n" + |
| 5722 |
"The variable b can only be null; it was either set to null or checked for null when last used\n" + |
| 5723 |
"----------\n"); |
| 5724 |
} |
| 5725 |
|
| 5726 |
// null analysis - for with unknown protection |
| 5727 |
// suggested by https://bugs.eclipse.org/bugs/show_bug.cgi?id=127570 |
| 5728 |
// the issue is that we cannot do less than full aliasing analysis to |
| 5729 |
// catch this one |
| 5730 |
// TODO (maxime) reconsider when/if we bring full aliasing in |
| 5731 |
public void _test0738_for_unknown_protection() { |
| 5732 |
this.runConformTest( |
| 5733 |
new String[] { |
| 5734 |
"X.java", |
| 5735 |
"class X {\n" + |
| 5736 |
" public boolean foo(Boolean p) {\n" + |
| 5737 |
" Boolean b = null;\n" + |
| 5738 |
" for (int i = 0; i < 1; i++) {\n" + |
| 5739 |
" if (b == p) {\n" + |
| 5740 |
" // empty\n" + |
| 5741 |
" }\n" + |
| 5742 |
" else {\n" + |
| 5743 |
" b = p;\n" + |
| 5744 |
" }\n" + |
| 5745 |
" if (b.booleanValue()) {\n" + // quiet because b is an alias for p, unknown |
| 5746 |
" return b.booleanValue();\n" + |
| 5747 |
" }\n" + |
| 5748 |
" }\n" + |
| 5749 |
" return false;\n" + |
| 5750 |
" }\n" + |
| 5751 |
"}"}, |
| 5752 |
""); |
| 5753 |
} |
| 5754 |
|
| 5590 |
// null analysis -- switch |
5755 |
// null analysis -- switch |
| 5591 |
public void test0800_switch() { |
5756 |
public void test0800_switch() { |
| 5592 |
this.runConformTest( |
5757 |
this.runConformTest( |
|
Lines 7035-7040
Link Here
|
| 7035 |
"----------\n"); |
7200 |
"----------\n"); |
| 7036 |
} |
7201 |
} |
| 7037 |
|
7202 |
|
|
|
7203 |
// encoding validation |
| 7204 |
public void test1500() { |
| 7205 |
this.runConformTest( |
| 7206 |
new String[] { |
| 7207 |
"X.java", |
| 7208 |
"public class X {\n" + |
| 7209 |
" void foo(Object o, int i, boolean b, Object u) {\n" + |
| 7210 |
" o.toString();\n" + |
| 7211 |
" switch (i) {\n" + |
| 7212 |
" case 0:\n" + |
| 7213 |
" if (b) {\n" + |
| 7214 |
" o = u;\n" + |
| 7215 |
" } else {\n" + |
| 7216 |
" o = new Object();\n" + |
| 7217 |
" }\n" + |
| 7218 |
" break;\n" + |
| 7219 |
" }\n" + |
| 7220 |
" if (o == null) { /* empty */ }\n" + |
| 7221 |
" }\n" + |
| 7222 |
"}\n"}, |
| 7223 |
""); |
| 7224 |
} |
| 7225 |
|
| 7226 |
// encoding validation |
| 7227 |
public void test1501() { |
| 7228 |
this.runConformTest( |
| 7229 |
new String[] { |
| 7230 |
"X.java", |
| 7231 |
"public class X {\n" + |
| 7232 |
" void foo(Object o, int i, boolean b, Object u) {\n" + |
| 7233 |
" if (b) {\n" + |
| 7234 |
" o = new Object();\n" + |
| 7235 |
" }\n" + |
| 7236 |
" o.toString();\n" + |
| 7237 |
" switch (i) {\n" + |
| 7238 |
" case 0:\n" + |
| 7239 |
" if (b) {\n" + |
| 7240 |
" o = u;\n" + |
| 7241 |
" } else {\n" + |
| 7242 |
" o = new Object();\n" + |
| 7243 |
" }\n" + |
| 7244 |
" break;\n" + |
| 7245 |
" }\n" + |
| 7246 |
" if (o == null) { /* empty */ }\n" + |
| 7247 |
" }\n" + |
| 7248 |
"}\n"}, |
| 7249 |
""); |
| 7250 |
} |
| 7251 |
|
| 7252 |
// encoding validation |
| 7253 |
public void test1502() { |
| 7254 |
this.runConformTest( |
| 7255 |
new String[] { |
| 7256 |
"X.java", |
| 7257 |
"public class X {\n" + |
| 7258 |
" void foo(Object o, int i, boolean b, Object u) {\n" + |
| 7259 |
" if (b) {\n" + |
| 7260 |
" o = u;\n" + |
| 7261 |
" }\n" + |
| 7262 |
" o.toString();\n" + |
| 7263 |
" switch (i) {\n" + |
| 7264 |
" case 0:\n" + |
| 7265 |
" if (b) {\n" + |
| 7266 |
" o = u;\n" + |
| 7267 |
" } else {\n" + |
| 7268 |
" o = new Object();\n" + |
| 7269 |
" }\n" + |
| 7270 |
" break;\n" + |
| 7271 |
" }\n" + |
| 7272 |
" if (o == null) { /* empty */ }\n" + |
| 7273 |
" }\n" + |
| 7274 |
"}\n"}, |
| 7275 |
""); |
| 7276 |
} |
| 7277 |
|
| 7278 |
// encoding validation |
| 7279 |
public void test1503() { |
| 7280 |
this.runConformTest( |
| 7281 |
new String[] { |
| 7282 |
"X.java", |
| 7283 |
"public class X {\n" + |
| 7284 |
" void foo(Object o, int i, boolean b, Object u) {\n" + |
| 7285 |
" if (b) {\n" + |
| 7286 |
" o = u;\n" + |
| 7287 |
" } else {\n" + |
| 7288 |
" o = new Object();\n" + |
| 7289 |
" }\n" + |
| 7290 |
" o.toString();\n" + |
| 7291 |
" switch (i) {\n" + |
| 7292 |
" case 0:\n" + |
| 7293 |
" if (b) {\n" + |
| 7294 |
" o = u;\n" + |
| 7295 |
" } else {\n" + |
| 7296 |
" o = new Object();\n" + |
| 7297 |
" }\n" + |
| 7298 |
" break;\n" + |
| 7299 |
" }\n" + |
| 7300 |
" if (o == null) { /* empty */ }\n" + |
| 7301 |
" }\n" + |
| 7302 |
"}\n"}, |
| 7303 |
""); |
| 7304 |
} |
| 7305 |
|
| 7038 |
// flow info low-level validation |
7306 |
// flow info low-level validation |
| 7039 |
public void test2000_flow_info() { |
7307 |
public void test2000_flow_info() { |
| 7040 |
this.runNegativeTest( |
7308 |
this.runNegativeTest( |
|
Lines 7058-7064
Link Here
|
| 7058 |
" o60 = o0, o61 = o0, o62 = o0, o63 = o0, o64 = o0,\n" + |
7326 |
" o60 = o0, o61 = o0, o62 = o0, o63 = o0, o64 = o0,\n" + |
| 7059 |
" o65 = o0, o66 = o0, o67 = o0, o68 = o0, o69 = o0;\n" + |
7327 |
" o65 = o0, o66 = o0, o67 = o0, o68 = o0, o69 = o0;\n" + |
| 7060 |
" if (o65 == null) { /* */ }\n" + // complain |
7328 |
" if (o65 == null) { /* */ }\n" + // complain |
| 7061 |
" if (o65 != null) { /* */ }\n" + // quiet (already reported) |
7329 |
" if (o65 != null) { /* */ }\n" + |
| 7062 |
" }\n" + |
7330 |
" }\n" + |
| 7063 |
"}\n"}, |
7331 |
"}\n"}, |
| 7064 |
"----------\n" + |
7332 |
"----------\n" + |
|
Lines 7782-9978
Link Here
|
| 7782 |
"The variable o1 may be null\n" + |
8050 |
"The variable o1 may be null\n" + |
| 7783 |
"----------\n"); |
8051 |
"----------\n"); |
| 7784 |
} |
8052 |
} |
| 7785 |
|
|
|
| 7786 |
// Technical tests -- only available with patched sources |
| 7787 |
static final boolean |
| 7788 |
printTablesAsNames = false, |
| 7789 |
printTablesAsCodes = false, |
| 7790 |
printTruthMaps = false; |
| 7791 |
static final int |
| 7792 |
combinationTestsloopsNb = 1; // define to 10000s to measure performances |
| 7793 |
|
| 7794 |
|
| 7795 |
public void test2050_markAsComparedEqualToNonNull() { |
| 7796 |
long [][][] testData = { |
| 7797 |
{{0,0,0,0},{1,1,0,0}}, |
| 7798 |
{{0,0,0,1},{1,1,0,1}}, |
| 7799 |
{{0,0,1,0},{1,1,0,0}}, |
| 7800 |
{{0,0,1,1},{1,1,0,1}}, |
| 7801 |
{{0,1,0,0},{1,1,0,0}}, |
| 7802 |
{{0,1,0,1},{1,1,0,1}}, |
| 7803 |
{{0,1,1,0},{1,1,0,0}}, |
| 7804 |
{{0,1,1,1},{1,1,0,1}}, |
| 7805 |
{{1,0,0,0},{1,1,0,0}}, |
| 7806 |
{{1,0,0,1},{1,0,0,1}}, |
| 7807 |
{{1,0,1,0},{1,1,0,0}}, |
| 7808 |
{{1,0,1,1},{1,1,0,1}}, |
| 7809 |
{{1,1,0,0},{1,1,0,0}}, |
| 7810 |
{{1,1,0,1},{1,1,0,1}}, |
| 7811 |
{{1,1,1,0},{1,1,0,0}}, |
| 7812 |
{{1,1,1,1},{1,1,0,1}}, |
| 7813 |
}; |
| 7814 |
int failures = 0; |
| 7815 |
LocalVariableBinding local = new TestLocalVariableBinding(0); |
| 7816 |
for (int i = 0; i < testData.length; i++) { |
| 7817 |
UnconditionalFlowInfoTestHarness |
| 7818 |
result = UnconditionalFlowInfoTestHarness. |
| 7819 |
testUnconditionalFlowInfo(testData[i][0]); |
| 7820 |
result.markAsComparedEqualToNonNull(local); |
| 7821 |
if (!(result.testEquals(UnconditionalFlowInfoTestHarness. |
| 7822 |
testUnconditionalFlowInfo(testData[i][1])))) { |
| 7823 |
if (failures == 0) { |
| 7824 |
System.out.println("markAsComparedEqualToNonNull failures: "); |
| 7825 |
} |
| 7826 |
failures++; |
| 7827 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 7828 |
',' + result.testString() + |
| 7829 |
"}, // instead of: " + testStringValueOf(testData[i][1])); |
| 7830 |
} |
| 7831 |
} |
| 7832 |
local = new TestLocalVariableBinding(64); |
| 7833 |
for (int i = 0; i < testData.length; i++) { |
| 7834 |
UnconditionalFlowInfoTestHarness |
| 7835 |
result = UnconditionalFlowInfoTestHarness. |
| 7836 |
testUnconditionalFlowInfo(testData[i][0], 64), |
| 7837 |
expected = UnconditionalFlowInfoTestHarness. |
| 7838 |
testUnconditionalFlowInfo(testData[i][1], 64); |
| 7839 |
result.markAsComparedEqualToNonNull(local); |
| 7840 |
if (!(result.testEquals(expected))) { |
| 7841 |
if (failures == 0) { |
| 7842 |
System.out.println("markAsComparedEqualToNonNull failures: "); |
| 7843 |
} |
| 7844 |
failures++; |
| 7845 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 7846 |
',' + result.testString() + |
| 7847 |
"}, // (64) instead of: " + testStringValueOf(testData[i][1])); |
| 7848 |
} |
| 7849 |
if (testData[i][0][0] == 0 && |
| 7850 |
testData[i][0][1] == 0 && |
| 7851 |
testData[i][0][2] == 0 && |
| 7852 |
testData[i][0][3] == 0) { |
| 7853 |
result = UnconditionalFlowInfoTestHarness. |
| 7854 |
testUnconditionalFlowInfo(testData[i][1]); |
| 7855 |
result.markAsComparedEqualToNonNull(local); |
| 7856 |
if (!result.testEquals(expected, 64)) { |
| 7857 |
if (failures == 0) { |
| 7858 |
System.out.println("markAsComparedEqualToNonNull failures: "); |
| 7859 |
} |
| 7860 |
failures++; |
| 7861 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 7862 |
',' + result.testString() + |
| 7863 |
"}, // (zero 64) instead of: " + testStringValueOf(testData[i][1])); |
| 7864 |
} |
| 7865 |
} |
| 7866 |
} |
| 7867 |
local = new TestLocalVariableBinding(128); |
| 7868 |
for (int i = 0; i < testData.length; i++) { |
| 7869 |
if (testData[i][0][0] == 0 && |
| 7870 |
testData[i][0][1] == 0 && |
| 7871 |
testData[i][0][2] == 0 && |
| 7872 |
testData[i][0][3] == 0) { |
| 7873 |
UnconditionalFlowInfoTestHarness |
| 7874 |
result = UnconditionalFlowInfoTestHarness. |
| 7875 |
testUnconditionalFlowInfo(testData[i][1], 64), |
| 7876 |
expected = UnconditionalFlowInfoTestHarness. |
| 7877 |
testUnconditionalFlowInfo(testData[i][1], 128); |
| 7878 |
result.markAsComparedEqualToNonNull(local); |
| 7879 |
if (!result.testEquals(expected, 128)) { |
| 7880 |
if (failures == 0) { |
| 7881 |
System.out.println("markAsComparedEqualToNonNull failures: "); |
| 7882 |
} |
| 7883 |
failures++; |
| 7884 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 7885 |
',' + result.testString() + |
| 7886 |
"}, // (zero 128) instead of: " + testStringValueOf(testData[i][1])); |
| 7887 |
} |
| 7888 |
} |
| 7889 |
} |
| 7890 |
if (printTablesAsNames) { |
| 7891 |
System.out.println("RECAP TABLE FOR MARK COMPARED NON NULL"); |
| 7892 |
for (int i = 0; i < testData.length; i++) { |
| 7893 |
System.out.println(testSymbolicValueOf(testData[i][0]) + " -> " + |
| 7894 |
testSymbolicValueOf(testData[i][1])); |
| 7895 |
} |
| 7896 |
} |
| 7897 |
if (printTablesAsCodes) { |
| 7898 |
System.out.println("RECAP TABLE FOR MARK COMPARED NON NULL"); |
| 7899 |
for (int i = 0; i < testData.length; i++) { |
| 7900 |
System.out.println(testCodedValueOf(testData[i][0]) + " " + |
| 7901 |
testCodedValueOf(testData[i][1])); |
| 7902 |
} |
| 7903 |
} |
| 7904 |
assertTrue("nb of failures: " + failures, failures == 0); |
| 7905 |
} |
| 7906 |
|
| 7907 |
public void test2051_markAsComparedEqualToNull() { |
| 7908 |
long [][][] testData = { |
| 7909 |
{{0,0,0,0},{0,1,0,0}}, |
| 7910 |
{{0,0,0,1},{0,1,0,0}}, |
| 7911 |
{{0,0,1,0},{0,1,1,0}}, |
| 7912 |
{{0,0,1,1},{0,1,1,0}}, |
| 7913 |
{{0,1,0,0},{0,1,0,0}}, |
| 7914 |
{{0,1,0,1},{0,1,0,0}}, |
| 7915 |
{{0,1,1,0},{0,1,1,0}}, |
| 7916 |
{{0,1,1,1},{0,1,1,0}}, |
| 7917 |
{{1,0,0,0},{0,1,0,0}}, |
| 7918 |
{{1,0,0,1},{0,1,0,0}}, |
| 7919 |
{{1,0,1,0},{1,0,1,0}}, |
| 7920 |
{{1,0,1,1},{0,1,0,0}}, |
| 7921 |
{{1,1,0,0},{0,1,0,0}}, |
| 7922 |
{{1,1,0,1},{0,1,0,0}}, |
| 7923 |
{{1,1,1,0},{0,1,1,0}}, |
| 7924 |
{{1,1,1,1},{0,1,1,0}}, |
| 7925 |
}; |
| 7926 |
int failures = 0; |
| 7927 |
LocalVariableBinding local = new TestLocalVariableBinding(0); |
| 7928 |
for (int i = 0; i < testData.length; i++) { |
| 7929 |
UnconditionalFlowInfoTestHarness |
| 7930 |
result = UnconditionalFlowInfoTestHarness. |
| 7931 |
testUnconditionalFlowInfo(testData[i][0]); |
| 7932 |
result.markAsComparedEqualToNull(local); |
| 7933 |
if (!(result.testEquals(UnconditionalFlowInfoTestHarness. |
| 7934 |
testUnconditionalFlowInfo(testData[i][1])))) { |
| 7935 |
if (failures == 0) { |
| 7936 |
System.out.println("markAsComparedEqualToNull failures: "); |
| 7937 |
} |
| 7938 |
failures++; |
| 7939 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 7940 |
',' + result.testString() + |
| 7941 |
"}, // instead of: " + testStringValueOf(testData[i][1])); |
| 7942 |
} |
| 7943 |
} |
| 7944 |
local = new TestLocalVariableBinding(64); |
| 7945 |
for (int i = 0; i < testData.length; i++) { |
| 7946 |
UnconditionalFlowInfoTestHarness |
| 7947 |
result = UnconditionalFlowInfoTestHarness. |
| 7948 |
testUnconditionalFlowInfo(testData[i][0], 64), |
| 7949 |
expected = UnconditionalFlowInfoTestHarness. |
| 7950 |
testUnconditionalFlowInfo(testData[i][1], 64); |
| 7951 |
result.markAsComparedEqualToNull(local); |
| 7952 |
if (!(result.testEquals(expected))) { |
| 7953 |
if (failures == 0) { |
| 7954 |
System.out.println("markAsComparedEqualToNull failures: "); |
| 7955 |
} |
| 7956 |
failures++; |
| 7957 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 7958 |
',' + result.testString() + |
| 7959 |
"}, // (64) instead of: " + testStringValueOf(testData[i][1])); |
| 7960 |
} |
| 7961 |
if (testData[i][0][0] == 0 && |
| 7962 |
testData[i][0][1] == 0 && |
| 7963 |
testData[i][0][2] == 0 && |
| 7964 |
testData[i][0][3] == 0) { |
| 7965 |
result = UnconditionalFlowInfoTestHarness. |
| 7966 |
testUnconditionalFlowInfo(testData[i][1]); |
| 7967 |
result.markAsComparedEqualToNull(local); |
| 7968 |
if (!result.testEquals(expected, 64)) { |
| 7969 |
if (failures == 0) { |
| 7970 |
System.out.println("markAsComparedEqualToNull failures: "); |
| 7971 |
} |
| 7972 |
failures++; |
| 7973 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 7974 |
',' + result.testString() + |
| 7975 |
"}, // (zero 64) instead of: " + testStringValueOf(testData[i][1])); |
| 7976 |
} |
| 7977 |
} |
| 7978 |
} |
| 7979 |
local = new TestLocalVariableBinding(128); |
| 7980 |
for (int i = 0; i < testData.length; i++) { |
| 7981 |
if (testData[i][0][0] == 0 && |
| 7982 |
testData[i][0][1] == 0 && |
| 7983 |
testData[i][0][2] == 0 && |
| 7984 |
testData[i][0][3] == 0) { |
| 7985 |
UnconditionalFlowInfoTestHarness |
| 7986 |
result = UnconditionalFlowInfoTestHarness. |
| 7987 |
testUnconditionalFlowInfo(testData[i][1], 64), |
| 7988 |
expected = UnconditionalFlowInfoTestHarness. |
| 7989 |
testUnconditionalFlowInfo(testData[i][1], 128); |
| 7990 |
result.markAsComparedEqualToNull(local); |
| 7991 |
if (!result.testEquals(expected, 128)) { |
| 7992 |
if (failures == 0) { |
| 7993 |
System.out.println("markAsComparedEqualToNull failures: "); |
| 7994 |
} |
| 7995 |
failures++; |
| 7996 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 7997 |
',' + result.testString() + |
| 7998 |
"}, // (zero 128) instead of: " + testStringValueOf(testData[i][1])); |
| 7999 |
} |
| 8000 |
} |
| 8001 |
} |
| 8002 |
if (printTablesAsNames) { |
| 8003 |
System.out.println("RECAP TABLE FOR MARK COMPARED NULL"); |
| 8004 |
for (int i = 0; i < testData.length; i++) { |
| 8005 |
System.out.println(testSymbolicValueOf(testData[i][0]) + " -> " + |
| 8006 |
testSymbolicValueOf(testData[i][1])); |
| 8007 |
} |
| 8008 |
} |
| 8009 |
if (printTablesAsCodes) { |
| 8010 |
System.out.println("RECAP TABLE FOR MARK COMPARED NULL"); |
| 8011 |
for (int i = 0; i < testData.length; i++) { |
| 8012 |
System.out.println(testCodedValueOf(testData[i][0]) + " " + |
| 8013 |
testCodedValueOf(testData[i][1])); |
| 8014 |
} |
| 8015 |
} |
| 8016 |
assertTrue("nb of failures: " + failures, failures == 0); |
| 8017 |
} |
| 8018 |
|
| 8019 |
public void test2052_markAsDefinitelyNonNull() { |
| 8020 |
long [][][] testData = { |
| 8021 |
{{0,0,0,0},{1,0,0,1}}, |
| 8022 |
{{0,0,0,1},{1,0,0,1}}, |
| 8023 |
{{0,0,1,0},{1,0,0,1}}, |
| 8024 |
{{0,0,1,1},{1,0,0,1}}, |
| 8025 |
{{0,1,0,0},{1,0,0,1}}, |
| 8026 |
{{0,1,0,1},{1,0,0,1}}, |
| 8027 |
{{0,1,1,0},{1,0,0,1}}, |
| 8028 |
{{0,1,1,1},{1,0,0,1}}, |
| 8029 |
{{1,0,0,0},{1,0,0,1}}, |
| 8030 |
{{1,0,0,1},{1,0,0,1}}, |
| 8031 |
{{1,0,1,0},{1,0,0,1}}, |
| 8032 |
{{1,0,1,1},{1,0,0,1}}, |
| 8033 |
{{1,1,0,0},{1,0,0,1}}, |
| 8034 |
{{1,1,0,1},{1,0,0,1}}, |
| 8035 |
{{1,1,1,0},{1,0,0,1}}, |
| 8036 |
{{1,1,1,1},{1,0,0,1}}, |
| 8037 |
}; |
| 8038 |
int failures = 0; |
| 8039 |
LocalVariableBinding local = new TestLocalVariableBinding(0); |
| 8040 |
for (int i = 0; i < testData.length; i++) { |
| 8041 |
UnconditionalFlowInfoTestHarness |
| 8042 |
result = UnconditionalFlowInfoTestHarness. |
| 8043 |
testUnconditionalFlowInfo(testData[i][0]); |
| 8044 |
result.markAsDefinitelyNonNull(local); |
| 8045 |
if (!(result.testEquals(UnconditionalFlowInfoTestHarness. |
| 8046 |
testUnconditionalFlowInfo(testData[i][1])))) { |
| 8047 |
if (failures == 0) { |
| 8048 |
System.out.println("markAsDefinitelyNonNull failures: "); |
| 8049 |
} |
| 8050 |
failures++; |
| 8051 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8052 |
',' + result.testString() + |
| 8053 |
"}, // instead of: " + testStringValueOf(testData[i][1])); |
| 8054 |
} |
| 8055 |
} |
| 8056 |
local = new TestLocalVariableBinding(64); |
| 8057 |
for (int i = 0; i < testData.length; i++) { |
| 8058 |
UnconditionalFlowInfoTestHarness |
| 8059 |
result = UnconditionalFlowInfoTestHarness. |
| 8060 |
testUnconditionalFlowInfo(testData[i][0], 64); |
| 8061 |
result.markAsDefinitelyNonNull(local); |
| 8062 |
if (!(result.testEquals(UnconditionalFlowInfoTestHarness. |
| 8063 |
testUnconditionalFlowInfo(testData[i][1], 64)))) { |
| 8064 |
if (failures == 0) { |
| 8065 |
System.out.println("markAsDefinitelyNonNull failures: "); |
| 8066 |
} |
| 8067 |
failures++; |
| 8068 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8069 |
',' + result.testString() + |
| 8070 |
"}, // (64) instead of: " + testStringValueOf(testData[i][1])); |
| 8071 |
} |
| 8072 |
} |
| 8073 |
if (printTablesAsNames) { |
| 8074 |
System.out.println("RECAP TABLE FOR MARK DEFINITELY NON NULL"); |
| 8075 |
for (int i = 0; i < testData.length; i++) { |
| 8076 |
System.out.println(testSymbolicValueOf(testData[i][0]) + " -> " + |
| 8077 |
testSymbolicValueOf(testData[i][1])); |
| 8078 |
} |
| 8079 |
} |
| 8080 |
if (printTablesAsCodes) { |
| 8081 |
System.out.println("RECAP TABLE FOR MARK DEFINITELY NON NULL"); |
| 8082 |
for (int i = 0; i < testData.length; i++) { |
| 8083 |
System.out.println(testCodedValueOf(testData[i][0]) + " " + |
| 8084 |
testCodedValueOf(testData[i][1])); |
| 8085 |
} |
| 8086 |
} |
| 8087 |
assertTrue("nb of failures: " + failures, failures == 0); |
| 8088 |
} |
| 8089 |
|
| 8090 |
public void test2053_markAsDefinitelyNull() { |
| 8091 |
long [][][] testData = { |
| 8092 |
{{0,0,0,0},{1,0,1,0}}, |
| 8093 |
{{0,0,0,1},{1,0,1,0}}, |
| 8094 |
{{0,0,1,0},{1,0,1,0}}, |
| 8095 |
{{0,0,1,1},{1,0,1,0}}, |
| 8096 |
{{0,1,0,0},{1,0,1,0}}, |
| 8097 |
{{0,1,0,1},{1,0,1,0}}, |
| 8098 |
{{0,1,1,0},{1,0,1,0}}, |
| 8099 |
{{0,1,1,1},{1,0,1,0}}, |
| 8100 |
{{1,0,0,0},{1,0,1,0}}, |
| 8101 |
{{1,0,0,1},{1,0,1,0}}, |
| 8102 |
{{1,0,1,0},{1,0,1,0}}, |
| 8103 |
{{1,0,1,1},{1,0,1,0}}, |
| 8104 |
{{1,1,0,0},{1,0,1,0}}, |
| 8105 |
{{1,1,0,1},{1,0,1,0}}, |
| 8106 |
{{1,1,1,0},{1,0,1,0}}, |
| 8107 |
{{1,1,1,1},{1,0,1,0}}, |
| 8108 |
}; |
| 8109 |
int failures = 0; |
| 8110 |
LocalVariableBinding local = new TestLocalVariableBinding(0); |
| 8111 |
for (int i = 0; i < testData.length; i++) { |
| 8112 |
UnconditionalFlowInfoTestHarness |
| 8113 |
result = UnconditionalFlowInfoTestHarness. |
| 8114 |
testUnconditionalFlowInfo(testData[i][0]); |
| 8115 |
result.markAsDefinitelyNull(local); |
| 8116 |
if (!(result.testEquals(UnconditionalFlowInfoTestHarness. |
| 8117 |
testUnconditionalFlowInfo(testData[i][1])))) { |
| 8118 |
if (failures == 0) { |
| 8119 |
System.out.println("markAsDefinitelyNull failures: "); |
| 8120 |
} |
| 8121 |
failures++; |
| 8122 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8123 |
',' + result.testString() + |
| 8124 |
"}, // instead of: " + testStringValueOf(testData[i][1])); |
| 8125 |
} |
| 8126 |
} |
| 8127 |
local = new TestLocalVariableBinding(64); |
| 8128 |
for (int i = 0; i < testData.length; i++) { |
| 8129 |
UnconditionalFlowInfoTestHarness |
| 8130 |
result = UnconditionalFlowInfoTestHarness. |
| 8131 |
testUnconditionalFlowInfo(testData[i][0], 64); |
| 8132 |
result.markAsDefinitelyNull(local); |
| 8133 |
if (!(result.testEquals(UnconditionalFlowInfoTestHarness. |
| 8134 |
testUnconditionalFlowInfo(testData[i][1], 64)))) { |
| 8135 |
if (failures == 0) { |
| 8136 |
System.out.println("markAsDefinitelyNull failures: "); |
| 8137 |
} |
| 8138 |
failures++; |
| 8139 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8140 |
',' + result.testString() + |
| 8141 |
"}, // (64) instead of: " + testStringValueOf(testData[i][1])); |
| 8142 |
} |
| 8143 |
} |
| 8144 |
if (printTablesAsNames) { |
| 8145 |
System.out.println("RECAP TABLE FOR MARK DEFINITELY NULL"); |
| 8146 |
for (int i = 0; i < testData.length; i++) { |
| 8147 |
System.out.println(testSymbolicValueOf(testData[i][0]) + " -> " + |
| 8148 |
testSymbolicValueOf(testData[i][1])); |
| 8149 |
} |
| 8150 |
} |
| 8151 |
if (printTablesAsCodes) { |
| 8152 |
System.out.println("RECAP TABLE FOR MARK DEFINITELY NULL"); |
| 8153 |
for (int i = 0; i < testData.length; i++) { |
| 8154 |
System.out.println(testCodedValueOf(testData[i][0]) + " " + |
| 8155 |
testCodedValueOf(testData[i][1])); |
| 8156 |
} |
| 8157 |
} |
| 8158 |
assertTrue("nb of failures: " + failures, failures == 0); |
| 8159 |
} |
| 8160 |
|
| 8161 |
public void test2054_markAsDefinitelyUnknown() { |
| 8162 |
long [][][] testData = { |
| 8163 |
{{0,0,0,0},{1,0,1,1}}, |
| 8164 |
{{0,0,0,1},{1,0,1,1}}, |
| 8165 |
{{0,0,1,0},{1,0,1,1}}, |
| 8166 |
{{0,0,1,1},{1,0,1,1}}, |
| 8167 |
{{0,1,0,0},{1,0,1,1}}, |
| 8168 |
{{0,1,0,1},{1,0,1,1}}, |
| 8169 |
{{0,1,1,0},{1,0,1,1}}, |
| 8170 |
{{0,1,1,1},{1,0,1,1}}, |
| 8171 |
{{1,0,0,0},{1,0,1,1}}, |
| 8172 |
{{1,0,0,1},{1,0,1,1}}, |
| 8173 |
{{1,0,1,0},{1,0,1,1}}, |
| 8174 |
{{1,0,1,1},{1,0,1,1}}, |
| 8175 |
{{1,1,0,0},{1,0,1,1}}, |
| 8176 |
{{1,1,0,1},{1,0,1,1}}, |
| 8177 |
{{1,1,1,0},{1,0,1,1}}, |
| 8178 |
{{1,1,1,1},{1,0,1,1}}, |
| 8179 |
}; |
| 8180 |
int failures = 0; |
| 8181 |
LocalVariableBinding local = new TestLocalVariableBinding(0); |
| 8182 |
for (int i = 0; i < testData.length; i++) { |
| 8183 |
UnconditionalFlowInfoTestHarness |
| 8184 |
result = UnconditionalFlowInfoTestHarness. |
| 8185 |
testUnconditionalFlowInfo(testData[i][0]); |
| 8186 |
result.markAsDefinitelyUnknown(local); |
| 8187 |
if (!(result.testEquals(UnconditionalFlowInfoTestHarness. |
| 8188 |
testUnconditionalFlowInfo(testData[i][1])))) { |
| 8189 |
if (failures == 0) { |
| 8190 |
System.out.println("markAsDefinitelyUnknown failures: "); |
| 8191 |
} |
| 8192 |
failures++; |
| 8193 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8194 |
',' + result.testString() + |
| 8195 |
"}, // instead of: " + testStringValueOf(testData[i][1])); |
| 8196 |
} |
| 8197 |
} |
| 8198 |
local = new TestLocalVariableBinding(64); |
| 8199 |
for (int i = 0; i < testData.length; i++) { |
| 8200 |
UnconditionalFlowInfoTestHarness |
| 8201 |
result = UnconditionalFlowInfoTestHarness. |
| 8202 |
testUnconditionalFlowInfo(testData[i][0], 64); |
| 8203 |
result.markAsDefinitelyUnknown(local); |
| 8204 |
if (!(result.testEquals(UnconditionalFlowInfoTestHarness. |
| 8205 |
testUnconditionalFlowInfo(testData[i][1], 64)))) { |
| 8206 |
if (failures == 0) { |
| 8207 |
System.out.println("markAsDefinitelyUnknown failures: "); |
| 8208 |
} |
| 8209 |
failures++; |
| 8210 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8211 |
',' + result.testString() + |
| 8212 |
"}, // (64) instead of: " + testStringValueOf(testData[i][1])); |
| 8213 |
} |
| 8214 |
} |
| 8215 |
if (printTablesAsNames) { |
| 8216 |
System.out.println("RECAP TABLE FOR MARK DEFINITELY UNKNOWN"); |
| 8217 |
for (int i = 0; i < testData.length; i++) { |
| 8218 |
System.out.println(testSymbolicValueOf(testData[i][0]) + " -> " + |
| 8219 |
testSymbolicValueOf(testData[i][1])); |
| 8220 |
} |
| 8221 |
} |
| 8222 |
if (printTablesAsCodes) { |
| 8223 |
System.out.println("RECAP TABLE FOR MARK DEFINITELY UNKNOWN"); |
| 8224 |
for (int i = 0; i < testData.length; i++) { |
| 8225 |
System.out.println(testCodedValueOf(testData[i][0]) + " " + |
| 8226 |
testCodedValueOf(testData[i][1])); |
| 8227 |
} |
| 8228 |
} |
| 8229 |
assertTrue("nb of failures: " + failures, failures == 0); |
| 8230 |
} |
| 8231 |
|
| 8232 |
public void test2055_addInitializationsFrom() { |
| 8233 |
long [][][] testData = { |
| 8234 |
{{0,0,0,0},{0,0,0,0},{0,0,0,0}}, |
| 8235 |
{{0,0,0,0},{0,0,0,1},{0,0,0,1}}, |
| 8236 |
{{0,0,0,0},{0,0,1,0},{0,0,1,0}}, |
| 8237 |
{{0,0,0,0},{0,0,1,1},{0,0,1,1}}, |
| 8238 |
{{0,0,0,0},{0,1,0,0},{0,1,0,0}}, |
| 8239 |
{{0,0,0,0},{0,1,1,0},{0,1,1,0}}, |
| 8240 |
{{0,0,0,0},{1,0,0,1},{1,0,0,1}}, |
| 8241 |
{{0,0,0,0},{1,0,1,0},{1,0,1,0}}, |
| 8242 |
{{0,0,0,0},{1,0,1,1},{1,0,1,1}}, |
| 8243 |
{{0,0,0,0},{1,1,0,0},{1,1,0,0}}, |
| 8244 |
{{0,0,0,0},{1,1,0,1},{1,1,0,1}}, |
| 8245 |
{{0,0,0,1},{0,0,0,0},{0,0,0,1}}, |
| 8246 |
{{0,0,0,1},{0,0,0,1},{0,0,0,1}}, |
| 8247 |
{{0,0,0,1},{0,0,1,0},{0,0,1,1}}, |
| 8248 |
{{0,0,0,1},{0,0,1,1},{0,0,1,1}}, |
| 8249 |
{{0,0,0,1},{0,1,0,0},{0,1,0,0}}, |
| 8250 |
{{0,0,0,1},{0,1,1,0},{0,1,0,0}}, |
| 8251 |
{{0,0,0,1},{1,0,0,1},{1,0,0,1}}, |
| 8252 |
{{0,0,0,1},{1,0,1,0},{1,0,1,0}}, |
| 8253 |
{{0,0,0,1},{1,0,1,1},{1,0,1,1}}, |
| 8254 |
{{0,0,0,1},{1,1,0,0},{1,1,0,1}}, |
| 8255 |
{{0,0,0,1},{1,1,0,1},{1,1,0,1}}, |
| 8256 |
{{0,0,1,0},{0,0,0,0},{0,0,1,0}}, |
| 8257 |
{{0,0,1,0},{0,0,0,1},{0,0,1,1}}, |
| 8258 |
{{0,0,1,0},{0,0,1,0},{0,0,1,0}}, |
| 8259 |
{{0,0,1,0},{0,0,1,1},{0,0,1,1}}, |
| 8260 |
{{0,0,1,0},{0,1,0,0},{0,1,1,0}}, |
| 8261 |
{{0,0,1,0},{0,1,1,0},{0,1,1,0}}, |
| 8262 |
{{0,0,1,0},{1,0,0,1},{1,0,0,1}}, |
| 8263 |
{{0,0,1,0},{1,0,1,0},{1,0,1,0}}, |
| 8264 |
{{0,0,1,0},{1,0,1,1},{1,0,1,1}}, |
| 8265 |
{{0,0,1,0},{1,1,0,0},{1,1,0,0}}, |
| 8266 |
{{0,0,1,0},{1,1,0,1},{1,1,0,1}}, |
| 8267 |
{{0,0,1,1},{0,0,0,0},{0,0,1,1}}, |
| 8268 |
{{0,0,1,1},{0,0,0,1},{0,0,1,1}}, |
| 8269 |
{{0,0,1,1},{0,0,1,0},{0,0,1,1}}, |
| 8270 |
{{0,0,1,1},{0,0,1,1},{0,0,1,1}}, |
| 8271 |
{{0,0,1,1},{0,1,0,0},{0,1,1,0}}, |
| 8272 |
{{0,0,1,1},{0,1,1,0},{0,1,1,0}}, |
| 8273 |
{{0,0,1,1},{1,0,0,1},{1,0,0,1}}, |
| 8274 |
{{0,0,1,1},{1,0,1,0},{1,0,1,0}}, |
| 8275 |
{{0,0,1,1},{1,0,1,1},{1,0,1,1}}, |
| 8276 |
{{0,0,1,1},{1,1,0,0},{1,1,0,1}}, |
| 8277 |
{{0,0,1,1},{1,1,0,1},{1,1,0,1}}, |
| 8278 |
{{0,1,0,0},{0,0,0,0},{0,1,0,0}}, |
| 8279 |
{{0,1,0,0},{0,0,0,1},{0,0,0,1}}, |
| 8280 |
{{0,1,0,0},{0,0,1,0},{0,1,1,0}}, |
| 8281 |
{{0,1,0,0},{0,0,1,1},{0,0,1,1}}, |
| 8282 |
{{0,1,0,0},{0,1,0,0},{0,1,0,0}}, |
| 8283 |
{{0,1,0,0},{0,1,1,0},{0,1,1,0}}, |
| 8284 |
{{0,1,0,0},{1,0,0,1},{1,0,0,1}}, |
| 8285 |
{{0,1,0,0},{1,0,1,0},{1,0,1,0}}, |
| 8286 |
{{0,1,0,0},{1,0,1,1},{1,0,1,1}}, |
| 8287 |
{{0,1,0,0},{1,1,0,0},{1,1,0,0}}, |
| 8288 |
{{0,1,0,0},{1,1,0,1},{1,1,0,1}}, |
| 8289 |
{{0,1,1,0},{0,0,0,0},{0,1,1,0}}, |
| 8290 |
{{0,1,1,0},{0,0,0,1},{0,0,1,1}}, |
| 8291 |
{{0,1,1,0},{0,0,1,0},{0,1,1,0}}, |
| 8292 |
{{0,1,1,0},{0,0,1,1},{0,0,1,1}}, |
| 8293 |
{{0,1,1,0},{0,1,0,0},{0,1,1,0}}, |
| 8294 |
{{0,1,1,0},{0,1,1,0},{0,1,1,0}}, |
| 8295 |
{{0,1,1,0},{1,0,0,1},{1,0,0,1}}, |
| 8296 |
{{0,1,1,0},{1,0,1,0},{1,0,1,0}}, |
| 8297 |
{{0,1,1,0},{1,0,1,1},{1,0,1,1}}, |
| 8298 |
{{0,1,1,0},{1,1,0,0},{1,1,0,0}}, |
| 8299 |
{{0,1,1,0},{1,1,0,1},{1,1,0,1}}, |
| 8300 |
{{1,0,0,1},{0,0,0,0},{1,0,0,1}}, |
| 8301 |
{{1,0,0,1},{0,0,0,1},{1,0,0,1}}, |
| 8302 |
{{1,0,0,1},{0,0,1,0},{0,0,1,1}}, |
| 8303 |
{{1,0,0,1},{0,0,1,1},{0,0,1,1}}, |
| 8304 |
{{1,0,0,1},{0,1,0,0},{0,1,0,0}}, |
| 8305 |
{{1,0,0,1},{0,1,1,0},{0,1,1,0}}, |
| 8306 |
{{1,0,0,1},{1,0,0,1},{1,0,0,1}}, |
| 8307 |
{{1,0,0,1},{1,0,1,0},{1,0,1,0}}, |
| 8308 |
{{1,0,0,1},{1,0,1,1},{1,0,1,1}}, |
| 8309 |
{{1,0,0,1},{1,1,0,0},{1,1,0,1}}, |
| 8310 |
{{1,0,0,1},{1,1,0,1},{1,1,0,1}}, |
| 8311 |
{{1,0,1,0},{0,0,0,0},{1,0,1,0}}, |
| 8312 |
{{1,0,1,0},{0,0,0,1},{0,0,1,1}}, |
| 8313 |
{{1,0,1,0},{0,0,1,0},{1,0,1,0}}, |
| 8314 |
{{1,0,1,0},{0,0,1,1},{0,0,1,1}}, |
| 8315 |
{{1,0,1,0},{0,1,0,0},{1,0,1,0}}, |
| 8316 |
{{1,0,1,0},{0,1,1,0},{1,0,1,0}}, |
| 8317 |
{{1,0,1,0},{1,0,0,1},{1,0,0,1}}, |
| 8318 |
{{1,0,1,0},{1,0,1,0},{1,0,1,0}}, |
| 8319 |
{{1,0,1,0},{1,0,1,1},{1,0,1,1}}, |
| 8320 |
{{1,0,1,0},{1,1,0,0},{1,1,0,0}}, |
| 8321 |
{{1,0,1,0},{1,1,0,1},{1,1,0,1}}, |
| 8322 |
{{1,0,1,1},{0,0,0,0},{1,0,1,1}}, |
| 8323 |
{{1,0,1,1},{0,0,0,1},{1,0,1,1}}, |
| 8324 |
{{1,0,1,1},{0,0,1,0},{0,0,1,1}}, |
| 8325 |
{{1,0,1,1},{0,0,1,1},{0,0,1,1}}, |
| 8326 |
{{1,0,1,1},{0,1,0,0},{0,1,0,0}}, |
| 8327 |
{{1,0,1,1},{0,1,1,0},{0,1,1,0}}, |
| 8328 |
{{1,0,1,1},{1,0,0,1},{1,0,0,1}}, |
| 8329 |
{{1,0,1,1},{1,0,1,0},{1,0,1,0}}, |
| 8330 |
{{1,0,1,1},{1,0,1,1},{1,0,1,1}}, |
| 8331 |
{{1,0,1,1},{1,1,0,0},{1,1,0,1}}, |
| 8332 |
{{1,0,1,1},{1,1,0,1},{1,1,0,1}}, |
| 8333 |
{{1,1,0,0},{0,0,0,0},{1,1,0,0}}, |
| 8334 |
{{1,1,0,0},{0,0,0,1},{1,1,0,1}}, |
| 8335 |
{{1,1,0,0},{0,0,1,0},{0,0,1,0}}, |
| 8336 |
{{1,1,0,0},{0,0,1,1},{0,0,1,1}}, |
| 8337 |
{{1,1,0,0},{0,1,0,0},{0,1,0,0}}, |
| 8338 |
{{1,1,0,0},{0,1,1,0},{0,1,1,0}}, |
| 8339 |
{{1,1,0,0},{1,0,0,1},{1,0,0,1}}, |
| 8340 |
{{1,1,0,0},{1,0,1,0},{1,0,1,0}}, |
| 8341 |
{{1,1,0,0},{1,0,1,1},{1,0,1,1}}, |
| 8342 |
{{1,1,0,0},{1,1,0,0},{1,1,0,0}}, |
| 8343 |
{{1,1,0,0},{1,1,0,1},{1,1,0,1}}, |
| 8344 |
{{1,1,0,1},{0,0,0,0},{1,1,0,1}}, |
| 8345 |
{{1,1,0,1},{0,0,0,1},{0,0,0,1}}, |
| 8346 |
{{1,1,0,1},{0,0,1,0},{0,0,1,1}}, |
| 8347 |
{{1,1,0,1},{0,0,1,1},{0,0,1,1}}, |
| 8348 |
{{1,1,0,1},{0,1,0,0},{0,1,0,0}}, |
| 8349 |
{{1,1,0,1},{0,1,1,0},{0,1,1,0}}, |
| 8350 |
{{1,1,0,1},{1,0,0,1},{1,0,0,1}}, |
| 8351 |
{{1,1,0,1},{1,0,1,0},{1,0,1,0}}, |
| 8352 |
{{1,1,0,1},{1,0,1,1},{1,0,1,1}}, |
| 8353 |
{{1,1,0,1},{1,1,0,0},{1,1,0,1}}, |
| 8354 |
{{1,1,0,1},{1,1,0,1},{1,1,0,1}}, |
| 8355 |
}; |
| 8356 |
int failures = 0; |
| 8357 |
long start; |
| 8358 |
if (combinationTestsloopsNb > 1) { |
| 8359 |
start = System.currentTimeMillis(); |
| 8360 |
} |
| 8361 |
String header = "addInitializationsFrom failures: "; //$NON-NLS-1$ |
| 8362 |
for (int l = 0; l < combinationTestsloopsNb ; l++) { |
| 8363 |
for (int i = 0; i < testData.length; i++) { |
| 8364 |
UnconditionalFlowInfoTestHarness result; |
| 8365 |
if (!(result = (UnconditionalFlowInfoTestHarness)( |
| 8366 |
UnconditionalFlowInfoTestHarness. |
| 8367 |
testUnconditionalFlowInfo(testData[i][0])). |
| 8368 |
addInitializationsFrom( |
| 8369 |
UnconditionalFlowInfoTestHarness. |
| 8370 |
testUnconditionalFlowInfo(testData[i][1]))). |
| 8371 |
testEquals(UnconditionalFlowInfoTestHarness. |
| 8372 |
testUnconditionalFlowInfo(testData[i][2]))) { |
| 8373 |
if (failures == 0) { |
| 8374 |
System.out.println(header); |
| 8375 |
} |
| 8376 |
failures++; |
| 8377 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8378 |
',' + testStringValueOf(testData[i][1]) + |
| 8379 |
',' + result.testString() + |
| 8380 |
"}, // instead of: " + testStringValueOf(testData[i][2])); |
| 8381 |
} |
| 8382 |
} |
| 8383 |
} |
| 8384 |
if (combinationTestsloopsNb > 1) { |
| 8385 |
System.out.println("addInitial...\t\t" + combinationTestsloopsNb + "\t" + |
| 8386 |
(System.currentTimeMillis() - start)); |
| 8387 |
} |
| 8388 |
// PREMATURE optimize test (extraneous allocations and copies) |
| 8389 |
// PREMATURE optimize test (extraneous iterations - undup) |
| 8390 |
UnconditionalFlowInfoTestHarness |
| 8391 |
zero = UnconditionalFlowInfoTestHarness. |
| 8392 |
testUnconditionalFlowInfo(new long[] {0,0,0,0}), |
| 8393 |
left0, left1, right1, left2, right2, |
| 8394 |
expected0, expected1, expected2, result; |
| 8395 |
for (int i = 0; i < testData.length; i++) { |
| 8396 |
left0 = UnconditionalFlowInfoTestHarness. |
| 8397 |
testUnconditionalFlowInfo(testData[i][0]); |
| 8398 |
left1 = UnconditionalFlowInfoTestHarness. |
| 8399 |
testUnconditionalFlowInfo(testData[i][0], 64); |
| 8400 |
left2 = UnconditionalFlowInfoTestHarness. |
| 8401 |
testUnconditionalFlowInfo(testData[i][0], 128); |
| 8402 |
right1 = UnconditionalFlowInfoTestHarness. |
| 8403 |
testUnconditionalFlowInfo(testData[i][1], 64); |
| 8404 |
right2 = UnconditionalFlowInfoTestHarness. |
| 8405 |
testUnconditionalFlowInfo(testData[i][1], 128); |
| 8406 |
expected0 = UnconditionalFlowInfoTestHarness. |
| 8407 |
testUnconditionalFlowInfo(testData[i][2]); |
| 8408 |
expected1 = UnconditionalFlowInfoTestHarness. |
| 8409 |
testUnconditionalFlowInfo(testData[i][2], 64); |
| 8410 |
expected2 = UnconditionalFlowInfoTestHarness. |
| 8411 |
testUnconditionalFlowInfo(testData[i][2], 128); |
| 8412 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8413 |
left1.copy().addInitializationsFrom(right1)). |
| 8414 |
testEquals(expected1)) { |
| 8415 |
if (failures == 0) { |
| 8416 |
System.out.println(header); |
| 8417 |
} |
| 8418 |
failures++; |
| 8419 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8420 |
',' + testStringValueOf(testData[i][1]) + |
| 8421 |
',' + result.testString() + |
| 8422 |
"}, // (64, 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 8423 |
} |
| 8424 |
if ((testData[i][0][0] | testData[i][0][1] | |
| 8425 |
testData[i][0][2] | testData[i][0][3]) == 0) { |
| 8426 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8427 |
zero.copy().addInitializationsFrom(right1)). |
| 8428 |
testEquals(expected1)) { |
| 8429 |
if (failures == 0) { |
| 8430 |
System.out.println(header); |
| 8431 |
} |
| 8432 |
failures++; |
| 8433 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8434 |
',' + testStringValueOf(testData[i][1]) + |
| 8435 |
',' + result.testString() + |
| 8436 |
"}, // (zero, 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 8437 |
} |
| 8438 |
if (!(result = (UnconditionalFlowInfoTestHarness) right2.copy(). |
| 8439 |
addInitializationsFrom(right1)). |
| 8440 |
testEquals(expected1, 64)) { |
| 8441 |
if (failures == 0) { |
| 8442 |
System.out.println(header); |
| 8443 |
} |
| 8444 |
failures++; |
| 8445 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8446 |
',' + testStringValueOf(testData[i][1]) + |
| 8447 |
',' + result.testString() + |
| 8448 |
"}, // (zero 128, 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 8449 |
} |
| 8450 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8451 |
zero.copy().addInitializationsFrom(right2)). |
| 8452 |
testEquals(expected2, 128)) { |
| 8453 |
if (failures == 0) { |
| 8454 |
System.out.println(header); |
| 8455 |
} |
| 8456 |
failures++; |
| 8457 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8458 |
',' + testStringValueOf(testData[i][1]) + |
| 8459 |
',' + result.testString(128) + |
| 8460 |
"}, // (zero, 128) - instead of: " + testStringValueOf(testData[i][2])); |
| 8461 |
} |
| 8462 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8463 |
right1.copy().addInitializationsFrom(right2)). |
| 8464 |
testEquals(expected2, 128)) { |
| 8465 |
if (failures == 0) { |
| 8466 |
System.out.println(header); |
| 8467 |
} |
| 8468 |
failures++; |
| 8469 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8470 |
',' + testStringValueOf(testData[i][1]) + |
| 8471 |
',' + result.testString(128) + |
| 8472 |
"}, // (zero 64, 128) - instead of: " + testStringValueOf(testData[i][2])); |
| 8473 |
} |
| 8474 |
} |
| 8475 |
if ((testData[i][1][0] | testData[i][1][1] | |
| 8476 |
testData[i][1][2] | testData[i][1][3]) == 0) { |
| 8477 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8478 |
left0.copy().addInitializationsFrom(left2)). |
| 8479 |
testEquals(expected0, 0)) { |
| 8480 |
if (failures == 0) { |
| 8481 |
System.out.println(header); |
| 8482 |
} |
| 8483 |
failures++; |
| 8484 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8485 |
',' + testStringValueOf(testData[i][1]) + |
| 8486 |
',' + result.testString() + |
| 8487 |
"}, // (1, zero 128) - instead of: " + testStringValueOf(testData[i][2])); |
| 8488 |
} |
| 8489 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8490 |
left1.copy().addInitializationsFrom(zero)). |
| 8491 |
testEquals(expected1)) { |
| 8492 |
if (failures == 0) { |
| 8493 |
System.out.println(header); |
| 8494 |
} |
| 8495 |
failures++; |
| 8496 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8497 |
',' + testStringValueOf(testData[i][1]) + |
| 8498 |
',' + result.testString() + |
| 8499 |
"}, // (64, zero) - instead of: " + testStringValueOf(testData[i][2])); |
| 8500 |
} |
| 8501 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8502 |
left1.copy().addInitializationsFrom(left2)). |
| 8503 |
testEquals(expected1, 64)) { |
| 8504 |
if (failures == 0) { |
| 8505 |
System.out.println(header); |
| 8506 |
} |
| 8507 |
failures++; |
| 8508 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8509 |
',' + testStringValueOf(testData[i][1]) + |
| 8510 |
',' + result.testString() + |
| 8511 |
"}, // (64, zero 128) - instead of: " + testStringValueOf(testData[i][2])); |
| 8512 |
} |
| 8513 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8514 |
left2.copy().addInitializationsFrom(zero)). |
| 8515 |
testEquals(expected2, 128)) { |
| 8516 |
if (failures == 0) { |
| 8517 |
System.out.println(header); |
| 8518 |
} |
| 8519 |
failures++; |
| 8520 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8521 |
',' + testStringValueOf(testData[i][1]) + |
| 8522 |
',' + result.testString() + |
| 8523 |
"}, // (128, zero) - instead of: " + testStringValueOf(testData[i][2])); |
| 8524 |
} |
| 8525 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8526 |
left2.addInitializationsFrom(left1)). |
| 8527 |
testEquals(expected2, 128)) { |
| 8528 |
if (failures == 0) { |
| 8529 |
System.out.println(header); |
| 8530 |
} |
| 8531 |
failures++; |
| 8532 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8533 |
',' + testStringValueOf(testData[i][1]) + |
| 8534 |
',' + result.testString() + |
| 8535 |
"}, // (128, zero 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 8536 |
} |
| 8537 |
} |
| 8538 |
} |
| 8539 |
if (printTablesAsNames) { |
| 8540 |
System.out.println("RECAP TABLE FOR ADD"); |
| 8541 |
for (int i = 0; i < testData.length; i++) { |
| 8542 |
System.out.println(testSymbolicValueOf(testData[i][0]) + " + " + |
| 8543 |
testSymbolicValueOf(testData[i][1]) + " -> " + |
| 8544 |
testSymbolicValueOf(testData[i][2])); |
| 8545 |
} |
| 8546 |
} |
| 8547 |
if (printTablesAsCodes) { |
| 8548 |
System.out.println("RECAP TABLE FOR ADD"); |
| 8549 |
for (int i = 0; i < testData.length; i++) { |
| 8550 |
System.out.println(testCodedValueOf(testData[i][0]) + " " + |
| 8551 |
testCodedValueOf(testData[i][1]) + " " + |
| 8552 |
testCodedValueOf(testData[i][2])); |
| 8553 |
} |
| 8554 |
} |
| 8555 |
if (printTruthMaps) { |
| 8556 |
for (int i = 0; i < 4; i++) { |
| 8557 |
System.out.println("======================================================"); |
| 8558 |
System.out.println("Truth map for addInitializationsFrom null bit " + (i + 1)); |
| 8559 |
System.out.println(); |
| 8560 |
printTruthMap(testData, i); |
| 8561 |
} |
| 8562 |
} |
| 8563 |
assertTrue("nb of failures: " + failures, failures == 0); |
| 8564 |
} |
| 8565 |
|
| 8566 |
public void test2056_addPotentialInitializationsFrom() { |
| 8567 |
long [][][] testData = { |
| 8568 |
{{0,0,0,0},{0,0,0,0},{0,0,0,0}}, |
| 8569 |
{{0,0,0,0},{0,0,0,1},{0,0,0,1}}, |
| 8570 |
{{0,0,0,0},{0,0,1,0},{0,0,1,0}}, |
| 8571 |
{{0,0,0,0},{0,0,1,1},{0,0,1,1}}, |
| 8572 |
{{0,0,0,0},{0,1,0,0},{0,0,0,0}}, |
| 8573 |
{{0,0,0,0},{0,1,1,0},{0,0,1,0}}, |
| 8574 |
{{0,0,0,0},{1,0,0,1},{0,0,0,1}}, |
| 8575 |
{{0,0,0,0},{1,0,1,0},{0,0,1,0}}, |
| 8576 |
{{0,0,0,0},{1,0,1,1},{0,0,0,1}}, |
| 8577 |
{{0,0,0,0},{1,1,0,0},{0,0,0,0}}, |
| 8578 |
{{0,0,0,0},{1,1,0,1},{0,0,0,1}}, |
| 8579 |
{{0,0,0,1},{0,0,0,0},{0,0,0,1}}, |
| 8580 |
{{0,0,0,1},{0,0,0,1},{0,0,0,1}}, |
| 8581 |
{{0,0,0,1},{0,0,1,0},{0,0,1,1}}, |
| 8582 |
{{0,0,0,1},{0,0,1,1},{0,0,1,1}}, |
| 8583 |
{{0,0,0,1},{0,1,0,0},{0,0,0,1}}, |
| 8584 |
{{0,0,0,1},{0,1,1,0},{0,0,1,1}}, |
| 8585 |
{{0,0,0,1},{1,0,0,1},{0,0,0,1}}, |
| 8586 |
{{0,0,0,1},{1,0,1,0},{0,0,1,1}}, |
| 8587 |
{{0,0,0,1},{1,0,1,1},{0,0,0,1}}, |
| 8588 |
{{0,0,0,1},{1,1,0,0},{0,0,0,1}}, |
| 8589 |
{{0,0,0,1},{1,1,0,1},{0,0,0,1}}, |
| 8590 |
{{0,0,1,0},{0,0,0,0},{0,0,1,0}}, |
| 8591 |
{{0,0,1,0},{0,0,0,1},{0,0,1,1}}, |
| 8592 |
{{0,0,1,0},{0,0,1,0},{0,0,1,0}}, |
| 8593 |
{{0,0,1,0},{0,0,1,1},{0,0,1,1}}, |
| 8594 |
{{0,0,1,0},{0,1,0,0},{0,0,1,0}}, |
| 8595 |
{{0,0,1,0},{0,1,1,0},{0,0,1,0}}, |
| 8596 |
{{0,0,1,0},{1,0,0,1},{0,0,1,1}}, |
| 8597 |
{{0,0,1,0},{1,0,1,0},{0,0,1,0}}, |
| 8598 |
{{0,0,1,0},{1,0,1,1},{0,0,1,1}}, |
| 8599 |
{{0,0,1,0},{1,1,0,0},{0,0,1,0}}, |
| 8600 |
{{0,0,1,0},{1,1,0,1},{0,0,1,1}}, |
| 8601 |
{{0,0,1,1},{0,0,0,0},{0,0,1,1}}, |
| 8602 |
{{0,0,1,1},{0,0,0,1},{0,0,1,1}}, |
| 8603 |
{{0,0,1,1},{0,0,1,0},{0,0,1,1}}, |
| 8604 |
{{0,0,1,1},{0,0,1,1},{0,0,1,1}}, |
| 8605 |
{{0,0,1,1},{0,1,0,0},{0,0,1,1}}, |
| 8606 |
{{0,0,1,1},{0,1,1,0},{0,0,1,1}}, |
| 8607 |
{{0,0,1,1},{1,0,0,1},{0,0,1,1}}, |
| 8608 |
{{0,0,1,1},{1,0,1,0},{0,0,1,1}}, |
| 8609 |
{{0,0,1,1},{1,0,1,1},{0,0,1,1}}, |
| 8610 |
{{0,0,1,1},{1,1,0,0},{0,0,1,1}}, |
| 8611 |
{{0,0,1,1},{1,1,0,1},{0,0,1,1}}, |
| 8612 |
{{0,1,0,0},{0,0,0,0},{0,1,0,0}}, |
| 8613 |
{{0,1,0,0},{0,0,0,1},{0,0,0,1}}, |
| 8614 |
{{0,1,0,0},{0,0,1,0},{0,1,1,0}}, |
| 8615 |
{{0,1,0,0},{0,0,1,1},{0,0,1,1}}, |
| 8616 |
{{0,1,0,0},{0,1,0,0},{0,1,0,0}}, |
| 8617 |
{{0,1,0,0},{0,1,1,0},{0,1,1,0}}, |
| 8618 |
{{0,1,0,0},{1,0,0,1},{0,0,0,1}}, |
| 8619 |
{{0,1,0,0},{1,0,1,0},{0,1,1,0}}, |
| 8620 |
{{0,1,0,0},{1,0,1,1},{0,0,0,1}}, |
| 8621 |
{{0,1,0,0},{1,1,0,0},{0,1,0,0}}, |
| 8622 |
{{0,1,0,0},{1,1,0,1},{0,0,0,1}}, |
| 8623 |
{{0,1,1,0},{0,0,0,0},{0,1,1,0}}, |
| 8624 |
{{0,1,1,0},{0,0,0,1},{0,0,1,1}}, |
| 8625 |
{{0,1,1,0},{0,0,1,0},{0,1,1,0}}, |
| 8626 |
{{0,1,1,0},{0,0,1,1},{0,0,1,1}}, |
| 8627 |
{{0,1,1,0},{0,1,0,0},{0,1,1,0}}, |
| 8628 |
{{0,1,1,0},{0,1,1,0},{0,1,1,0}}, |
| 8629 |
{{0,1,1,0},{1,0,0,1},{0,0,1,1}}, |
| 8630 |
{{0,1,1,0},{1,0,1,0},{0,1,1,0}}, |
| 8631 |
{{0,1,1,0},{1,0,1,1},{0,0,1,1}}, |
| 8632 |
{{0,1,1,0},{1,1,0,0},{0,1,1,0}}, |
| 8633 |
{{0,1,1,0},{1,1,0,1},{0,0,1,1}}, |
| 8634 |
{{1,0,0,1},{0,0,0,0},{1,0,0,1}}, |
| 8635 |
{{1,0,0,1},{0,0,0,1},{1,0,1,1}}, |
| 8636 |
{{1,0,0,1},{0,0,1,0},{0,0,1,1}}, |
| 8637 |
{{1,0,0,1},{0,0,1,1},{0,0,1,1}}, |
| 8638 |
{{1,0,0,1},{0,1,0,0},{1,0,0,1}}, |
| 8639 |
{{1,0,0,1},{0,1,1,0},{0,0,1,1}}, |
| 8640 |
{{1,0,0,1},{1,0,0,1},{1,0,0,1}}, |
| 8641 |
{{1,0,0,1},{1,0,1,0},{0,0,1,1}}, |
| 8642 |
{{1,0,0,1},{1,0,1,1},{1,0,1,1}}, |
| 8643 |
{{1,0,0,1},{1,1,0,0},{1,0,0,1}}, |
| 8644 |
{{1,0,0,1},{1,1,0,1},{1,0,0,1}}, |
| 8645 |
{{1,0,1,0},{0,0,0,0},{1,0,1,0}}, |
| 8646 |
{{1,0,1,0},{0,0,0,1},{0,0,1,1}}, |
| 8647 |
{{1,0,1,0},{0,0,1,0},{1,0,1,0}}, |
| 8648 |
{{1,0,1,0},{0,0,1,1},{0,0,1,1}}, |
| 8649 |
{{1,0,1,0},{0,1,0,0},{1,0,1,0}}, |
| 8650 |
{{1,0,1,0},{0,1,1,0},{1,0,1,0}}, |
| 8651 |
{{1,0,1,0},{1,0,0,1},{0,0,1,1}}, |
| 8652 |
{{1,0,1,0},{1,0,1,0},{1,0,1,0}}, |
| 8653 |
{{1,0,1,0},{1,0,1,1},{0,0,1,1}}, |
| 8654 |
{{1,0,1,0},{1,1,0,0},{1,0,1,0}}, |
| 8655 |
{{1,0,1,0},{1,1,0,1},{0,0,1,1}}, |
| 8656 |
{{1,0,1,1},{0,0,0,0},{1,0,1,1}}, |
| 8657 |
{{1,0,1,1},{0,0,0,1},{1,0,1,1}}, |
| 8658 |
{{1,0,1,1},{0,0,1,0},{0,0,1,1}}, |
| 8659 |
{{1,0,1,1},{0,0,1,1},{0,0,1,1}}, |
| 8660 |
{{1,0,1,1},{0,1,0,0},{1,0,1,1}}, |
| 8661 |
{{1,0,1,1},{0,1,1,0},{0,0,1,1}}, |
| 8662 |
{{1,0,1,1},{1,0,0,1},{1,0,1,1}}, |
| 8663 |
{{1,0,1,1},{1,0,1,0},{0,0,1,1}}, |
| 8664 |
{{1,0,1,1},{1,0,1,1},{1,0,1,1}}, |
| 8665 |
{{1,0,1,1},{1,1,0,0},{1,0,1,1}}, |
| 8666 |
{{1,0,1,1},{1,1,0,1},{1,0,1,1}}, |
| 8667 |
{{1,1,0,0},{0,0,0,0},{1,1,0,0}}, |
| 8668 |
{{1,1,0,0},{0,0,0,1},{0,0,0,1}}, |
| 8669 |
{{1,1,0,0},{0,0,1,0},{0,0,1,0}}, |
| 8670 |
{{1,1,0,0},{0,0,1,1},{0,0,1,1}}, |
| 8671 |
{{1,1,0,0},{0,1,0,0},{1,1,0,0}}, |
| 8672 |
{{1,1,0,0},{0,1,1,0},{0,0,1,0}}, |
| 8673 |
{{1,1,0,0},{1,0,0,1},{0,0,0,1}}, |
| 8674 |
{{1,1,0,0},{1,0,1,0},{0,0,1,0}}, |
| 8675 |
{{1,1,0,0},{1,0,1,1},{0,0,0,1}}, |
| 8676 |
{{1,1,0,0},{1,1,0,0},{1,1,0,0}}, |
| 8677 |
{{1,1,0,0},{1,1,0,1},{1,1,0,1}}, |
| 8678 |
{{1,1,0,1},{0,0,0,0},{1,1,0,1}}, |
| 8679 |
{{1,1,0,1},{0,0,0,1},{0,0,0,1}}, |
| 8680 |
{{1,1,0,1},{0,0,1,0},{0,0,1,1}}, |
| 8681 |
{{1,1,0,1},{0,0,1,1},{0,0,1,1}}, |
| 8682 |
{{1,1,0,1},{0,1,0,0},{1,1,0,1}}, |
| 8683 |
{{1,1,0,1},{0,1,1,0},{0,0,1,1}}, |
| 8684 |
{{1,1,0,1},{1,0,0,1},{0,0,0,1}}, |
| 8685 |
{{1,1,0,1},{1,0,1,0},{0,0,1,1}}, |
| 8686 |
{{1,1,0,1},{1,0,1,1},{0,0,0,1}}, |
| 8687 |
{{1,1,0,1},{1,1,0,0},{1,1,0,1}}, |
| 8688 |
{{1,1,0,1},{1,1,0,1},{1,1,0,1}}, |
| 8689 |
}; |
| 8690 |
int failures = 0; |
| 8691 |
long start; |
| 8692 |
if (combinationTestsloopsNb > 1) { |
| 8693 |
start = System.currentTimeMillis(); |
| 8694 |
} |
| 8695 |
String header = "addPotentialInitializationsFrom failures: "; //$NON-NLS-1$ |
| 8696 |
for (int l = 0; l < combinationTestsloopsNb ; l++) { |
| 8697 |
for (int i = 0; i < testData.length; i++) { |
| 8698 |
UnconditionalFlowInfoTestHarness result; |
| 8699 |
if (!(result = (UnconditionalFlowInfoTestHarness)( |
| 8700 |
UnconditionalFlowInfoTestHarness. |
| 8701 |
testUnconditionalFlowInfo(testData[i][0])). |
| 8702 |
addPotentialInitializationsFrom( |
| 8703 |
UnconditionalFlowInfoTestHarness. |
| 8704 |
testUnconditionalFlowInfo(testData[i][1]))). |
| 8705 |
testEquals(UnconditionalFlowInfoTestHarness. |
| 8706 |
testUnconditionalFlowInfo(testData[i][2]))) { |
| 8707 |
if (failures == 0) { |
| 8708 |
System.out.println(header); |
| 8709 |
} |
| 8710 |
failures++; |
| 8711 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8712 |
',' + testStringValueOf(testData[i][1]) + |
| 8713 |
',' + result.testString() + |
| 8714 |
"}, // instead of: " + testStringValueOf(testData[i][2])); |
| 8715 |
} |
| 8716 |
if (combinationTestsloopsNb < 2 && |
| 8717 |
!(result = (UnconditionalFlowInfoTestHarness)( |
| 8718 |
UnconditionalFlowInfoTestHarness. |
| 8719 |
testUnconditionalFlowInfo(testData[i][0])). |
| 8720 |
addPotentialNullInfoFrom( |
| 8721 |
UnconditionalFlowInfoTestHarness. |
| 8722 |
testUnconditionalFlowInfo(testData[i][1], 128))). |
| 8723 |
testEquals(UnconditionalFlowInfoTestHarness. |
| 8724 |
testUnconditionalFlowInfo(testData[14][0], 65), 64)) { |
| 8725 |
if (failures == 0) { |
| 8726 |
System.out.println(header); |
| 8727 |
} |
| 8728 |
failures++; |
| 8729 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8730 |
',' + testStringValueOf(testData[i][1]) + |
| 8731 |
',' + result.testString(64) + |
| 8732 |
"}, // bit 64 only, instead of: {0,0,0,0}"); |
| 8733 |
} |
| 8734 |
} |
| 8735 |
} |
| 8736 |
if (combinationTestsloopsNb > 1) { |
| 8737 |
System.out.println("addPotential...\t" + combinationTestsloopsNb + "\t" + |
| 8738 |
(System.currentTimeMillis() - start)); |
| 8739 |
} |
| 8740 |
UnconditionalFlowInfoTestHarness |
| 8741 |
zero = UnconditionalFlowInfoTestHarness. |
| 8742 |
testUnconditionalFlowInfo(new long[] {0,0,0,0}), |
| 8743 |
left0, left1, right1, left2, right2, |
| 8744 |
expected0, expected1, expected2, result; |
| 8745 |
for (int i = 0; i < testData.length; i++) { |
| 8746 |
left0 = UnconditionalFlowInfoTestHarness. |
| 8747 |
testUnconditionalFlowInfo(testData[i][0]); |
| 8748 |
left1 = UnconditionalFlowInfoTestHarness. |
| 8749 |
testUnconditionalFlowInfo(testData[i][0], 64); |
| 8750 |
left2 = UnconditionalFlowInfoTestHarness. |
| 8751 |
testUnconditionalFlowInfo(testData[i][0], 128); |
| 8752 |
right1 = UnconditionalFlowInfoTestHarness. |
| 8753 |
testUnconditionalFlowInfo(testData[i][1], 64); |
| 8754 |
right2 = UnconditionalFlowInfoTestHarness. |
| 8755 |
testUnconditionalFlowInfo(testData[i][1], 128); |
| 8756 |
expected0 = UnconditionalFlowInfoTestHarness. |
| 8757 |
testUnconditionalFlowInfo(testData[i][2]); |
| 8758 |
expected1 = UnconditionalFlowInfoTestHarness. |
| 8759 |
testUnconditionalFlowInfo(testData[i][2], 64); |
| 8760 |
expected2 = UnconditionalFlowInfoTestHarness. |
| 8761 |
testUnconditionalFlowInfo(testData[i][2], 128); |
| 8762 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8763 |
left1.copy().addPotentialInitializationsFrom(right1)). |
| 8764 |
testEquals(expected1)) { |
| 8765 |
if (failures == 0) { |
| 8766 |
System.out.println(header); |
| 8767 |
} |
| 8768 |
failures++; |
| 8769 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8770 |
',' + testStringValueOf(testData[i][1]) + |
| 8771 |
',' + result.testString() + |
| 8772 |
"}, // (64, 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 8773 |
} |
| 8774 |
if (testData[i][0][0] + testData[i][0][1] + |
| 8775 |
testData[i][0][2] + testData[i][0][3] == 0) { |
| 8776 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8777 |
zero.copy().addPotentialInitializationsFrom(right1)). |
| 8778 |
testEquals(expected1)) { |
| 8779 |
if (failures == 0) { |
| 8780 |
System.out.println(header); |
| 8781 |
} |
| 8782 |
failures++; |
| 8783 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8784 |
',' + testStringValueOf(testData[i][1]) + |
| 8785 |
',' + result.testString() + |
| 8786 |
"}, // (zero, 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 8787 |
} |
| 8788 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8789 |
right2.copy().addPotentialInitializationsFrom(right1)). |
| 8790 |
testEquals(expected1, 64)) { |
| 8791 |
if (failures == 0) { |
| 8792 |
System.out.println(header); |
| 8793 |
} |
| 8794 |
failures++; |
| 8795 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8796 |
',' + testStringValueOf(testData[i][1]) + |
| 8797 |
',' + result.testString() + |
| 8798 |
"}, // (zero 128, 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 8799 |
} |
| 8800 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8801 |
(UnconditionalFlowInfoTestHarness. |
| 8802 |
testUnconditionalFlowInfo(new long[] {0,0,0,0}, 64)). |
| 8803 |
// make just in time to get the needed structure |
| 8804 |
addPotentialNullInfoFrom(right2)). |
| 8805 |
testEquals(expected2, 128)) { |
| 8806 |
if (failures == 0) { |
| 8807 |
System.out.println(header); |
| 8808 |
} |
| 8809 |
failures++; |
| 8810 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8811 |
',' + testStringValueOf(testData[i][1]) + |
| 8812 |
',' + result.testString() + |
| 8813 |
"}, // (zero extra, 128) null only - instead of: " + testStringValueOf(testData[i][2])); |
| 8814 |
} |
| 8815 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8816 |
((UnconditionalFlowInfo)right2.copy()). |
| 8817 |
addPotentialNullInfoFrom(right1)). |
| 8818 |
testEquals(expected1, 64)) { |
| 8819 |
if (failures == 0) { |
| 8820 |
System.out.println(header); |
| 8821 |
} |
| 8822 |
failures++; |
| 8823 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8824 |
',' + testStringValueOf(testData[i][1]) + |
| 8825 |
',' + result.testString() + |
| 8826 |
"}, // (zero 128, 64) null only - instead of: " + testStringValueOf(testData[i][2])); |
| 8827 |
} |
| 8828 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8829 |
((UnconditionalFlowInfo)zero.copy()). |
| 8830 |
addPotentialNullInfoFrom(right2)). |
| 8831 |
testEquals(expected2, 128)) { |
| 8832 |
if (failures == 0) { |
| 8833 |
System.out.println(header); |
| 8834 |
} |
| 8835 |
failures++; |
| 8836 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8837 |
',' + testStringValueOf(testData[i][1]) + |
| 8838 |
',' + result.testString(128) + |
| 8839 |
"}, // (zero, 128) null only - instead of: " + testStringValueOf(testData[i][2])); |
| 8840 |
} |
| 8841 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8842 |
((UnconditionalFlowInfo)right1.copy()). |
| 8843 |
addPotentialNullInfoFrom(right2)). |
| 8844 |
testEquals(expected2, 128)) { |
| 8845 |
if (failures == 0) { |
| 8846 |
System.out.println(header); |
| 8847 |
} |
| 8848 |
failures++; |
| 8849 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8850 |
',' + testStringValueOf(testData[i][1]) + |
| 8851 |
',' + result.testString(128) + |
| 8852 |
"}, // (zero 64, 128) null only - instead of: " + testStringValueOf(testData[i][2])); |
| 8853 |
} } |
| 8854 |
if (testData[i][1][0] + testData[i][1][1] + |
| 8855 |
testData[i][1][2] + testData[i][1][3] == 0) { |
| 8856 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8857 |
((UnconditionalFlowInfoTestHarness)left0.copy()). |
| 8858 |
addPotentialNullInfoFrom(left2)). |
| 8859 |
testEquals(expected0, 1)) { |
| 8860 |
if (failures == 0) { |
| 8861 |
System.out.println(header); |
| 8862 |
} |
| 8863 |
failures++; |
| 8864 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8865 |
',' + testStringValueOf(testData[i][1]) + |
| 8866 |
',' + result.testString() + |
| 8867 |
"}, // (1, zero 128) null only - instead of: " + testStringValueOf(testData[i][2])); |
| 8868 |
} |
| 8869 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8870 |
left1.copy().addPotentialInitializationsFrom(zero)). |
| 8871 |
testEquals(expected1)) { |
| 8872 |
if (failures == 0) { |
| 8873 |
System.out.println(header); |
| 8874 |
} |
| 8875 |
failures++; |
| 8876 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8877 |
',' + testStringValueOf(testData[i][1]) + |
| 8878 |
',' + result.testString() + |
| 8879 |
"}, // (64, zero) - instead of: " + testStringValueOf(testData[i][2])); |
| 8880 |
} |
| 8881 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8882 |
left1.copy().addPotentialInitializationsFrom(left2)). |
| 8883 |
testEquals(expected1, 64)) { |
| 8884 |
if (failures == 0) { |
| 8885 |
System.out.println(header); |
| 8886 |
} |
| 8887 |
failures++; |
| 8888 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8889 |
',' + testStringValueOf(testData[i][1]) + |
| 8890 |
',' + result.testString() + |
| 8891 |
"}, // (64, zero 128) - instead of: " + testStringValueOf(testData[i][2])); |
| 8892 |
} |
| 8893 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8894 |
((UnconditionalFlowInfo)left1.copy()). |
| 8895 |
addPotentialNullInfoFrom(left2)). |
| 8896 |
testEquals(expected1, 64)) { |
| 8897 |
if (failures == 0) { |
| 8898 |
System.out.println(header); |
| 8899 |
} |
| 8900 |
failures++; |
| 8901 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8902 |
',' + testStringValueOf(testData[i][1]) + |
| 8903 |
',' + result.testString() + |
| 8904 |
"}, // (64, zero 128) null only - instead of: " + testStringValueOf(testData[i][2])); |
| 8905 |
} |
| 8906 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8907 |
((UnconditionalFlowInfo)left2.copy()). |
| 8908 |
addPotentialNullInfoFrom(zero)). |
| 8909 |
testEquals(expected2, 128)) { |
| 8910 |
if (failures == 0) { |
| 8911 |
System.out.println(header); |
| 8912 |
} |
| 8913 |
failures++; |
| 8914 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8915 |
',' + testStringValueOf(testData[i][1]) + |
| 8916 |
',' + result.testString() + |
| 8917 |
"}, // (128, zero) null only - instead of: " + testStringValueOf(testData[i][2])); |
| 8918 |
} |
| 8919 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 8920 |
left2.addPotentialNullInfoFrom(left1)). |
| 8921 |
testEquals(expected2, 128)) { |
| 8922 |
if (failures == 0) { |
| 8923 |
System.out.println(header); |
| 8924 |
} |
| 8925 |
failures++; |
| 8926 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 8927 |
',' + testStringValueOf(testData[i][1]) + |
| 8928 |
',' + result.testString() + |
| 8929 |
"}, // (128, zero 64) null only - instead of: " + testStringValueOf(testData[i][2])); |
| 8930 |
} |
| 8931 |
} |
| 8932 |
} |
| 8933 |
if (printTablesAsNames) { |
| 8934 |
System.out.println("RECAP TABLE FOR ADD POTENTIAL"); |
| 8935 |
for (int i = 0; i < testData.length; i++) { |
| 8936 |
System.out.println(testSymbolicValueOf(testData[i][0]) + " + " + |
| 8937 |
testSymbolicValueOf(testData[i][1]) + " -> " + |
| 8938 |
testSymbolicValueOf(testData[i][2])); |
| 8939 |
} |
| 8940 |
} |
| 8941 |
if (printTablesAsCodes) { |
| 8942 |
System.out.println("RECAP TABLE FOR ADD POTENTIAL"); |
| 8943 |
for (int i = 0; i < testData.length; i++) { |
| 8944 |
System.out.println(testCodedValueOf(testData[i][0]) + " " + |
| 8945 |
testCodedValueOf(testData[i][1]) + " " + |
| 8946 |
testCodedValueOf(testData[i][2])); |
| 8947 |
} |
| 8948 |
} |
| 8949 |
if (printTruthMaps) { |
| 8950 |
for (int i = 0; i < 4; i++) { |
| 8951 |
System.out.println("======================================================"); |
| 8952 |
System.out.println("Truth map for addPotentialInitializationsFrom null bit " + (i + 1)); |
| 8953 |
System.out.println(); |
| 8954 |
} |
| 8955 |
} |
| 8956 |
assertTrue("nb of failures: " + failures, failures == 0); |
| 8957 |
} |
| 8958 |
|
| 8959 |
public void test2057_mergedWith() { |
| 8960 |
long [][][] testData = { |
| 8961 |
{{0,0,0,0},{0,0,0,0},{0,0,0,0}}, |
| 8962 |
{{0,0,0,0},{0,0,0,1},{0,0,0,1}}, |
| 8963 |
{{0,0,0,0},{0,0,1,0},{0,0,1,0}}, |
| 8964 |
{{0,0,0,0},{0,0,1,1},{0,0,1,1}}, |
| 8965 |
{{0,0,0,0},{0,1,0,0},{0,0,1,0}}, |
| 8966 |
{{0,0,0,0},{0,1,1,0},{0,0,1,0}}, |
| 8967 |
{{0,0,0,0},{1,0,0,1},{0,0,0,1}}, |
| 8968 |
{{0,0,0,0},{1,0,1,0},{0,0,1,0}}, |
| 8969 |
{{0,0,0,0},{1,0,1,1},{0,0,0,1}}, |
| 8970 |
{{0,0,0,0},{1,1,0,0},{0,0,0,0}}, |
| 8971 |
{{0,0,0,0},{1,1,0,1},{0,0,0,1}}, |
| 8972 |
{{0,0,0,1},{0,0,0,0},{0,0,0,1}}, |
| 8973 |
{{0,0,0,1},{0,0,0,1},{0,0,0,1}}, |
| 8974 |
{{0,0,0,1},{0,0,1,0},{0,0,1,1}}, |
| 8975 |
{{0,0,0,1},{0,0,1,1},{0,0,1,1}}, |
| 8976 |
{{0,0,0,1},{0,1,0,0},{0,0,1,1}}, |
| 8977 |
{{0,0,0,1},{0,1,1,0},{0,0,1,1}}, |
| 8978 |
{{0,0,0,1},{1,0,0,1},{0,0,0,1}}, |
| 8979 |
{{0,0,0,1},{1,0,1,0},{0,0,1,1}}, |
| 8980 |
{{0,0,0,1},{1,0,1,1},{0,0,0,1}}, |
| 8981 |
{{0,0,0,1},{1,1,0,0},{0,0,0,1}}, |
| 8982 |
{{0,0,0,1},{1,1,0,1},{0,0,0,1}}, |
| 8983 |
{{0,0,1,0},{0,0,0,0},{0,0,1,0}}, |
| 8984 |
{{0,0,1,0},{0,0,0,1},{0,0,1,1}}, |
| 8985 |
{{0,0,1,0},{0,0,1,0},{0,0,1,0}}, |
| 8986 |
{{0,0,1,0},{0,0,1,1},{0,0,1,1}}, |
| 8987 |
{{0,0,1,0},{0,1,0,0},{0,0,1,0}}, |
| 8988 |
{{0,0,1,0},{0,1,1,0},{0,0,1,0}}, |
| 8989 |
{{0,0,1,0},{1,0,0,1},{0,0,1,1}}, |
| 8990 |
{{0,0,1,0},{1,0,1,0},{0,0,1,0}}, |
| 8991 |
{{0,0,1,0},{1,0,1,1},{0,0,1,1}}, |
| 8992 |
{{0,0,1,0},{1,1,0,0},{0,0,1,0}}, |
| 8993 |
{{0,0,1,0},{1,1,0,1},{0,0,1,1}}, |
| 8994 |
{{0,0,1,1},{0,0,0,0},{0,0,1,1}}, |
| 8995 |
{{0,0,1,1},{0,0,0,1},{0,0,1,1}}, |
| 8996 |
{{0,0,1,1},{0,0,1,0},{0,0,1,1}}, |
| 8997 |
{{0,0,1,1},{0,0,1,1},{0,0,1,1}}, |
| 8998 |
{{0,0,1,1},{0,1,0,0},{0,0,1,1}}, |
| 8999 |
{{0,0,1,1},{0,1,1,0},{0,0,1,1}}, |
| 9000 |
{{0,0,1,1},{1,0,0,1},{0,0,1,1}}, |
| 9001 |
{{0,0,1,1},{1,0,1,0},{0,0,1,1}}, |
| 9002 |
{{0,0,1,1},{1,0,1,1},{0,0,1,1}}, |
| 9003 |
{{0,0,1,1},{1,1,0,0},{0,0,1,1}}, |
| 9004 |
{{0,0,1,1},{1,1,0,1},{0,0,1,1}}, |
| 9005 |
{{0,1,0,0},{0,0,0,0},{0,0,1,0}}, |
| 9006 |
{{0,1,0,0},{0,0,0,1},{0,0,1,1}}, |
| 9007 |
{{0,1,0,0},{0,0,1,0},{0,0,1,0}}, |
| 9008 |
{{0,1,0,0},{0,0,1,1},{0,0,1,1}}, |
| 9009 |
{{0,1,0,0},{0,1,0,0},{0,1,0,0}}, |
| 9010 |
{{0,1,0,0},{0,1,1,0},{0,1,1,0}}, |
| 9011 |
{{0,1,0,0},{1,0,0,1},{0,0,0,1}}, |
| 9012 |
{{0,1,0,0},{1,0,1,0},{0,1,1,0}}, |
| 9013 |
{{0,1,0,0},{1,0,1,1},{0,0,1,1}}, |
| 9014 |
{{0,1,0,0},{1,1,0,0},{0,0,1,0}}, |
| 9015 |
{{0,1,0,0},{1,1,0,1},{0,0,1,1}}, |
| 9016 |
{{0,1,1,0},{0,0,0,0},{0,0,1,0}}, |
| 9017 |
{{0,1,1,0},{0,0,0,1},{0,0,1,1}}, |
| 9018 |
{{0,1,1,0},{0,0,1,0},{0,0,1,0}}, |
| 9019 |
{{0,1,1,0},{0,0,1,1},{0,0,1,1}}, |
| 9020 |
{{0,1,1,0},{0,1,0,0},{0,1,1,0}}, |
| 9021 |
{{0,1,1,0},{0,1,1,0},{0,1,1,0}}, |
| 9022 |
{{0,1,1,0},{1,0,0,1},{0,0,1,1}}, |
| 9023 |
{{0,1,1,0},{1,0,1,0},{0,1,1,0}}, |
| 9024 |
{{0,1,1,0},{1,0,1,1},{0,0,1,1}}, |
| 9025 |
{{0,1,1,0},{1,1,0,0},{0,0,1,0}}, |
| 9026 |
{{0,1,1,0},{1,1,0,1},{0,0,1,1}}, |
| 9027 |
{{1,0,0,1},{0,0,0,0},{0,0,0,1}}, |
| 9028 |
{{1,0,0,1},{0,0,0,1},{0,0,0,1}}, |
| 9029 |
{{1,0,0,1},{0,0,1,0},{0,0,1,1}}, |
| 9030 |
{{1,0,0,1},{0,0,1,1},{0,0,1,1}}, |
| 9031 |
{{1,0,0,1},{0,1,0,0},{0,0,0,1}}, |
| 9032 |
{{1,0,0,1},{0,1,1,0},{0,0,1,1}}, |
| 9033 |
{{1,0,0,1},{1,0,0,1},{1,0,0,1}}, |
| 9034 |
{{1,0,0,1},{1,0,1,0},{0,0,1,1}}, |
| 9035 |
{{1,0,0,1},{1,0,1,1},{1,0,1,1}}, |
| 9036 |
{{1,0,0,1},{1,1,0,0},{1,1,0,1}}, |
| 9037 |
{{1,0,0,1},{1,1,0,1},{1,1,0,1}}, |
| 9038 |
{{1,0,1,0},{0,0,0,0},{0,0,1,0}}, |
| 9039 |
{{1,0,1,0},{0,0,0,1},{0,0,1,1}}, |
| 9040 |
{{1,0,1,0},{0,0,1,0},{0,0,1,0}}, |
| 9041 |
{{1,0,1,0},{0,0,1,1},{0,0,1,1}}, |
| 9042 |
{{1,0,1,0},{0,1,0,0},{0,1,1,0}}, |
| 9043 |
{{1,0,1,0},{0,1,1,0},{0,1,1,0}}, |
| 9044 |
{{1,0,1,0},{1,0,0,1},{0,0,1,1}}, |
| 9045 |
{{1,0,1,0},{1,0,1,0},{1,0,1,0}}, |
| 9046 |
{{1,0,1,0},{1,0,1,1},{0,0,1,1}}, |
| 9047 |
{{1,0,1,0},{1,1,0,0},{0,0,1,0}}, |
| 9048 |
{{1,0,1,0},{1,1,0,1},{0,0,1,1}}, |
| 9049 |
{{1,0,1,1},{0,0,0,0},{0,0,0,1}}, |
| 9050 |
{{1,0,1,1},{0,0,0,1},{0,0,0,1}}, |
| 9051 |
{{1,0,1,1},{0,0,1,0},{0,0,1,1}}, |
| 9052 |
{{1,0,1,1},{0,0,1,1},{0,0,1,1}}, |
| 9053 |
{{1,0,1,1},{0,1,0,0},{0,0,1,1}}, |
| 9054 |
{{1,0,1,1},{0,1,1,0},{0,0,1,1}}, |
| 9055 |
{{1,0,1,1},{1,0,0,1},{1,0,1,1}}, |
| 9056 |
{{1,0,1,1},{1,0,1,0},{0,0,1,1}}, |
| 9057 |
{{1,0,1,1},{1,0,1,1},{1,0,1,1}}, |
| 9058 |
{{1,0,1,1},{1,1,0,0},{0,0,0,1}}, |
| 9059 |
{{1,0,1,1},{1,1,0,1},{0,0,0,1}}, |
| 9060 |
{{1,1,0,0},{0,0,0,0},{0,0,0,0}}, |
| 9061 |
{{1,1,0,0},{0,0,0,1},{0,0,0,1}}, |
| 9062 |
{{1,1,0,0},{0,0,1,0},{0,0,1,0}}, |
| 9063 |
{{1,1,0,0},{0,0,1,1},{0,0,1,1}}, |
| 9064 |
{{1,1,0,0},{0,1,0,0},{0,0,1,0}}, |
| 9065 |
{{1,1,0,0},{0,1,1,0},{0,0,1,0}}, |
| 9066 |
{{1,1,0,0},{1,0,0,1},{1,1,0,1}}, |
| 9067 |
{{1,1,0,0},{1,0,1,0},{0,0,1,0}}, |
| 9068 |
{{1,1,0,0},{1,0,1,1},{0,0,0,1}}, |
| 9069 |
{{1,1,0,0},{1,1,0,0},{1,1,0,0}}, |
| 9070 |
{{1,1,0,0},{1,1,0,1},{1,1,0,1}}, |
| 9071 |
{{1,1,0,1},{0,0,0,0},{0,0,0,1}}, |
| 9072 |
{{1,1,0,1},{0,0,0,1},{0,0,0,1}}, |
| 9073 |
{{1,1,0,1},{0,0,1,0},{0,0,1,1}}, |
| 9074 |
{{1,1,0,1},{0,0,1,1},{0,0,1,1}}, |
| 9075 |
{{1,1,0,1},{0,1,0,0},{0,0,1,1}}, |
| 9076 |
{{1,1,0,1},{0,1,1,0},{0,0,1,1}}, |
| 9077 |
{{1,1,0,1},{1,0,0,1},{1,1,0,1}}, |
| 9078 |
{{1,1,0,1},{1,0,1,0},{0,0,1,1}}, |
| 9079 |
{{1,1,0,1},{1,0,1,1},{0,0,0,1}}, |
| 9080 |
{{1,1,0,1},{1,1,0,0},{1,1,0,1}}, |
| 9081 |
{{1,1,0,1},{1,1,0,1},{1,1,0,1}} |
| 9082 |
}; |
| 9083 |
int failures = 0; |
| 9084 |
long start; |
| 9085 |
if (combinationTestsloopsNb > 1) { |
| 9086 |
start = System.currentTimeMillis(); |
| 9087 |
} |
| 9088 |
String header = "mergedWith failures: "; |
| 9089 |
for (int l = 0; l < combinationTestsloopsNb ; l++) { |
| 9090 |
for (int i = 0; i < testData.length; i++) { |
| 9091 |
UnconditionalFlowInfoTestHarness result; |
| 9092 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9093 |
UnconditionalFlowInfoTestHarness. |
| 9094 |
testUnconditionalFlowInfo(testData[i][0]). |
| 9095 |
mergedWith( |
| 9096 |
UnconditionalFlowInfoTestHarness. |
| 9097 |
testUnconditionalFlowInfo(testData[i][1]))). |
| 9098 |
testEquals(UnconditionalFlowInfoTestHarness. |
| 9099 |
testUnconditionalFlowInfo(testData[i][2]))) { |
| 9100 |
if (failures == 0) { |
| 9101 |
System.out.println(header); |
| 9102 |
} |
| 9103 |
failures++; |
| 9104 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9105 |
',' + testStringValueOf(testData[i][1]) + |
| 9106 |
',' + result.testString() + |
| 9107 |
"}, // instead of: " + testStringValueOf(testData[i][2])); |
| 9108 |
} |
| 9109 |
} |
| 9110 |
} |
| 9111 |
if (combinationTestsloopsNb > 1) { |
| 9112 |
System.out.println("mergedWith\t\t\t" + combinationTestsloopsNb + "\t" + |
| 9113 |
(System.currentTimeMillis() - start)); |
| 9114 |
} |
| 9115 |
UnconditionalFlowInfoTestHarness |
| 9116 |
zero = UnconditionalFlowInfoTestHarness. |
| 9117 |
testUnconditionalFlowInfo(new long[] {0,0,0,0}), |
| 9118 |
left1, right1, left2, right2, |
| 9119 |
expected1, expected2, result; |
| 9120 |
for (int i = 0; i < testData.length; i++) { |
| 9121 |
left1 = UnconditionalFlowInfoTestHarness. |
| 9122 |
testUnconditionalFlowInfo(testData[i][0], 64); |
| 9123 |
left2 = UnconditionalFlowInfoTestHarness. |
| 9124 |
testUnconditionalFlowInfo(testData[i][0], 128); |
| 9125 |
right1 = UnconditionalFlowInfoTestHarness. |
| 9126 |
testUnconditionalFlowInfo(testData[i][1], 64); |
| 9127 |
right2 = UnconditionalFlowInfoTestHarness. |
| 9128 |
testUnconditionalFlowInfo(testData[i][1], 128); |
| 9129 |
expected1 = UnconditionalFlowInfoTestHarness. |
| 9130 |
testUnconditionalFlowInfo(testData[i][2], 64); |
| 9131 |
expected2 = UnconditionalFlowInfoTestHarness. |
| 9132 |
testUnconditionalFlowInfo(testData[i][2], 128); |
| 9133 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9134 |
left1.copy().mergedWith(right1)).testEquals(expected1)) { |
| 9135 |
if (failures == 0) { |
| 9136 |
System.out.println(header); |
| 9137 |
} |
| 9138 |
failures++; |
| 9139 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9140 |
',' + testStringValueOf(testData[i][1]) + |
| 9141 |
',' + result.testString() + |
| 9142 |
"}, // (64, 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 9143 |
} |
| 9144 |
if (testData[i][0][0] + testData[i][0][1] + |
| 9145 |
testData[i][0][2] + testData[i][0][3] == 0) { |
| 9146 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9147 |
zero.copy().mergedWith(right1)).testEquals(expected1)) { |
| 9148 |
if (failures == 0) { |
| 9149 |
System.out.println(header); |
| 9150 |
} |
| 9151 |
failures++; |
| 9152 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9153 |
',' + testStringValueOf(testData[i][1]) + |
| 9154 |
',' + result.testString() + |
| 9155 |
"}, // (zero, 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 9156 |
} |
| 9157 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9158 |
right2.copy().mergedWith(right1)). |
| 9159 |
testEquals(expected1, 64)) { |
| 9160 |
if (failures == 0) { |
| 9161 |
System.out.println(header); |
| 9162 |
} |
| 9163 |
failures++; |
| 9164 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9165 |
',' + testStringValueOf(testData[i][1]) + |
| 9166 |
',' + result.testString() + |
| 9167 |
"}, // (zero 128, 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 9168 |
} |
| 9169 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9170 |
zero.copy().mergedWith(right2)). |
| 9171 |
testEquals(expected2, 128)) { |
| 9172 |
if (failures == 0) { |
| 9173 |
System.out.println(header); |
| 9174 |
} |
| 9175 |
failures++; |
| 9176 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9177 |
',' + testStringValueOf(testData[i][1]) + |
| 9178 |
',' + result.testString() + |
| 9179 |
"}, // (zero, 128) - instead of: " + testStringValueOf(testData[i][2])); |
| 9180 |
} |
| 9181 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9182 |
right1.copy().mergedWith(right2)). |
| 9183 |
testEquals(expected2, 128)) { |
| 9184 |
if (failures == 0) { |
| 9185 |
System.out.println(header); |
| 9186 |
} |
| 9187 |
failures++; |
| 9188 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9189 |
',' + testStringValueOf(testData[i][1]) + |
| 9190 |
',' + result.testString() + |
| 9191 |
"}, // (zero 64, 128) - instead of: " + testStringValueOf(testData[i][2])); |
| 9192 |
} |
| 9193 |
} |
| 9194 |
if (testData[i][1][0] + testData[i][1][1] + |
| 9195 |
testData[i][1][2] + testData[i][1][3] == 0) { |
| 9196 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9197 |
left1.copy().mergedWith(zero)).testEquals(expected1)) { |
| 9198 |
if (failures == 0) { |
| 9199 |
System.out.println(header); |
| 9200 |
} |
| 9201 |
failures++; |
| 9202 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9203 |
',' + testStringValueOf(testData[i][1]) + |
| 9204 |
',' + result.testString() + |
| 9205 |
"}, // (64, zero) - instead of: " + testStringValueOf(testData[i][2])); |
| 9206 |
} |
| 9207 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9208 |
left1.mergedWith(left2)). |
| 9209 |
testEquals(expected1, 64)) { |
| 9210 |
if (failures == 0) { |
| 9211 |
System.out.println(header); |
| 9212 |
} |
| 9213 |
failures++; |
| 9214 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9215 |
',' + testStringValueOf(testData[i][1]) + |
| 9216 |
',' + result.testString() + |
| 9217 |
"}, // (64, zero 128) - instead of: " + testStringValueOf(testData[i][2])); |
| 9218 |
} |
| 9219 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9220 |
left2.copy().mergedWith(zero)). |
| 9221 |
testEquals(expected2, 128)) { |
| 9222 |
if (failures == 0) { |
| 9223 |
System.out.println(header); |
| 9224 |
} |
| 9225 |
failures++; |
| 9226 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9227 |
',' + testStringValueOf(testData[i][1]) + |
| 9228 |
',' + result.testString() + |
| 9229 |
"}, // (128, zero) - instead of: " + testStringValueOf(testData[i][2])); |
| 9230 |
} |
| 9231 |
if (!(result = (UnconditionalFlowInfoTestHarness) |
| 9232 |
left2.mergedWith(left1)). |
| 9233 |
testEquals(expected2, 128)) { |
| 9234 |
if (failures == 0) { |
| 9235 |
System.out.println(header); |
| 9236 |
} |
| 9237 |
failures++; |
| 9238 |
System.out.println("\t\t{" + testStringValueOf(testData[i][0]) + |
| 9239 |
',' + testStringValueOf(testData[i][1]) + |
| 9240 |
',' + result.testString() + |
| 9241 |
"}, // (128, zero 64) - instead of: " + testStringValueOf(testData[i][2])); |
| 9242 |
} |
| 9243 |
} |
| 9244 |
} |
| 9245 |
if (printTablesAsNames) { |
| 9246 |
System.out.println("RECAP TABLE FOR MERGE"); |
| 9247 |
for (int i = 0; i < testData.length; i++) { |
| 9248 |
System.out.println(testSymbolicValueOf(testData[i][0]) + " + " + |
| 9249 |
testSymbolicValueOf(testData[i][1]) + " -> " + |
| 9250 |
testSymbolicValueOf(testData[i][2])); |
| 9251 |
} |
| 9252 |
|
| 9253 |
} |
| 9254 |
if (printTablesAsCodes) { |
| 9255 |
System.out.println("RECAP TABLE FOR MERGE"); |
| 9256 |
for (int i = 0; i < testData.length; i++) { |
| 9257 |
System.out.println(testCodedValueOf(testData[i][0]) + " " + |
| 9258 |
testCodedValueOf(testData[i][1]) + " " + |
| 9259 |
testCodedValueOf(testData[i][2])); |
| 9260 |
} |
| 9261 |
} |
| 9262 |
if (printTruthMaps) { |
| 9263 |
for (int i = 0; i < 4; i++) { |
| 9264 |
System.out.println("======================================================"); |
| 9265 |
System.out.println("Truth map for mergedWith null bit " + (i + 1)); |
| 9266 |
System.out.println(); |
| 9267 |
} |
| 9268 |
} |
| 9269 |
assertTrue("nb of failures: " + failures, failures == 0); |
| 9270 |
} |
| 9271 |
|
| 9272 |
// Use for coverage tests only. Needs specific instrumentation of code, |
| 9273 |
// that is controled by UnconditionalFlowInfo#coverageTestFlag. |
| 9274 |
// Note: coverage tests tend to fill the console with messages, and the |
| 9275 |
// instrumented code is slower, so never release code with active |
| 9276 |
// coverage tests. |
| 9277 |
private static int coveragePointsNb = 46; |
| 9278 |
|
| 9279 |
// Coverage by state transition tables methods. |
| 9280 |
public void test2998_coverage() { |
| 9281 |
if (UnconditionalFlowInfo.coverageTestFlag) { |
| 9282 |
// sanity check: need to be sure that the tests execute properly when not |
| 9283 |
// trying to check coverage |
| 9284 |
UnconditionalFlowInfo.coverageTestId = 0; |
| 9285 |
test0053_array(); |
| 9286 |
test0070_type_reference(); |
| 9287 |
test2050_markAsComparedEqualToNonNull(); |
| 9288 |
test2051_markAsComparedEqualToNull(); |
| 9289 |
test2052_markAsDefinitelyNonNull(); |
| 9290 |
test2053_markAsDefinitelyNull(); |
| 9291 |
test2054_markAsDefinitelyUnknown(); |
| 9292 |
test2055_addInitializationsFrom(); |
| 9293 |
test2056_addPotentialInitializationsFrom(); |
| 9294 |
test2057_mergedWith(); |
| 9295 |
// coverage check |
| 9296 |
int failuresNb = 0; |
| 9297 |
for (int i = 1; i <= coveragePointsNb; i++) { |
| 9298 |
try { |
| 9299 |
UnconditionalFlowInfo.coverageTestId = i; |
| 9300 |
test0053_array(); |
| 9301 |
test0070_type_reference(); |
| 9302 |
test2050_markAsComparedEqualToNonNull(); |
| 9303 |
test2051_markAsComparedEqualToNull(); |
| 9304 |
test2052_markAsDefinitelyNonNull(); |
| 9305 |
test2053_markAsDefinitelyNull(); |
| 9306 |
test2054_markAsDefinitelyUnknown(); |
| 9307 |
test2055_addInitializationsFrom(); |
| 9308 |
test2056_addPotentialInitializationsFrom(); |
| 9309 |
test2057_mergedWith(); |
| 9310 |
} |
| 9311 |
catch (AssertionFailedError e) { |
| 9312 |
continue; |
| 9313 |
} |
| 9314 |
catch (AssertionFailedException e) { |
| 9315 |
continue; |
| 9316 |
} |
| 9317 |
failuresNb++; |
| 9318 |
System.out.println("Missing coverage point: " + i); |
| 9319 |
} |
| 9320 |
UnconditionalFlowInfo.coverageTestId = 0; // reset for other tests |
| 9321 |
assertEquals(failuresNb + " missing coverage point(s)", failuresNb, 0); |
| 9322 |
} |
| 9323 |
} |
| 9324 |
|
| 9325 |
// Coverage by code samples. |
| 9326 |
public void test2999_coverage() { |
| 9327 |
if (UnconditionalFlowInfo.coverageTestFlag) { |
| 9328 |
// sanity check: need to be sure that the tests execute properly when not |
| 9329 |
// trying to check coverage |
| 9330 |
UnconditionalFlowInfo.coverageTestId = 0; |
| 9331 |
test0001_simple_local(); |
| 9332 |
test0053_array(); |
| 9333 |
test0070_type_reference(); |
| 9334 |
test0327_if_else(); |
| 9335 |
test0401_while(); |
| 9336 |
test0420_while(); |
| 9337 |
test0509_try_finally_embedded(); |
| 9338 |
test2000_flow_info(); |
| 9339 |
test2004_flow_info(); |
| 9340 |
test2008_flow_info(); |
| 9341 |
test2011_flow_info(); |
| 9342 |
test2013_flow_info(); |
| 9343 |
test2018_flow_info(); |
| 9344 |
test2019_flow_info(); |
| 9345 |
test2020_flow_info(); |
| 9346 |
// coverage check |
| 9347 |
int failuresNb = 0; |
| 9348 |
for (int i = 1; i <= coveragePointsNb; i++) { |
| 9349 |
if (i > 4 && i < 15 || |
| 9350 |
i > 15 && i < 19 || |
| 9351 |
i == 22 || |
| 9352 |
i == 23 || |
| 9353 |
i == 27 || |
| 9354 |
i == 28 || |
| 9355 |
i == 30 || |
| 9356 |
i == 33 || |
| 9357 |
i == 34 || |
| 9358 |
i == 38 || |
| 9359 |
i >= 43 |
| 9360 |
) { // TODO (maxime) complete coverage tests |
| 9361 |
continue; |
| 9362 |
} |
| 9363 |
try { |
| 9364 |
UnconditionalFlowInfo.coverageTestId = i; |
| 9365 |
test0001_simple_local(); |
| 9366 |
test0053_array(); |
| 9367 |
test0070_type_reference(); |
| 9368 |
test0327_if_else(); |
| 9369 |
test0401_while(); |
| 9370 |
test0420_while(); |
| 9371 |
test0509_try_finally_embedded(); |
| 9372 |
test2000_flow_info(); |
| 9373 |
test2004_flow_info(); |
| 9374 |
test2008_flow_info(); |
| 9375 |
test2011_flow_info(); |
| 9376 |
test2013_flow_info(); |
| 9377 |
test2018_flow_info(); |
| 9378 |
test2019_flow_info(); |
| 9379 |
test2020_flow_info(); |
| 9380 |
} |
| 9381 |
catch (AssertionFailedError e) { |
| 9382 |
continue; |
| 9383 |
} |
| 9384 |
catch (AssertionFailedException e) { |
| 9385 |
continue; |
| 9386 |
} |
| 9387 |
failuresNb++; |
| 9388 |
System.out.println("Missing coverage point: " + i); |
| 9389 |
} |
| 9390 |
UnconditionalFlowInfo.coverageTestId = 0; // reset for other tests |
| 9391 |
assertEquals(failuresNb + " missing coverage point(s)", failuresNb, 0); |
| 9392 |
} |
| 9393 |
} |
| 9394 |
|
| 9395 |
// only works for info coded on bit 0 - least significant |
| 9396 |
String testCodedValueOf(long[] data) { |
| 9397 |
StringBuffer result = new StringBuffer(4); |
| 9398 |
for (int i = 0; i < data.length; i++) { |
| 9399 |
result.append(data[i] == 0 ? '0' : '1'); |
| 9400 |
} |
| 9401 |
return result.toString(); |
| 9402 |
} |
| 9403 |
|
| 9404 |
String testStringValueOf(long[] data) { |
| 9405 |
StringBuffer result = new StringBuffer(9); |
| 9406 |
result.append('{'); |
| 9407 |
for (int j = 0; j < 4; j++) { |
| 9408 |
if (j > 0) { |
| 9409 |
result.append(','); |
| 9410 |
} |
| 9411 |
result.append(data[j]); |
| 9412 |
} |
| 9413 |
result.append('}'); |
| 9414 |
return result.toString(); |
| 9415 |
} |
| 9416 |
|
| 9417 |
String testStringValueOf(long[][] data) { |
| 9418 |
StringBuffer result = new StringBuffer(25); |
| 9419 |
result.append('{'); |
| 9420 |
for (int i = 0; i < 3; i++) { |
| 9421 |
if (i > 0) { |
| 9422 |
result.append(','); |
| 9423 |
} |
| 9424 |
result.append('{'); |
| 9425 |
for (int j = 0; j < 4; j++) { |
| 9426 |
if (j > 0) { |
| 9427 |
result.append(','); |
| 9428 |
} |
| 9429 |
result.append(data[i][j]); |
| 9430 |
} |
| 9431 |
result.append('}'); |
| 9432 |
} |
| 9433 |
result.append('}'); |
| 9434 |
return result.toString(); |
| 9435 |
} |
| 9436 |
|
| 9437 |
// only works for info coded on bit 0 - least significant |
| 9438 |
String testSymbolicValueOf(long[] data) { |
| 9439 |
if (data[0] == 0) { |
| 9440 |
if (data[1] == 0) { |
| 9441 |
if (data[2] == 0) { |
| 9442 |
if (data[3] == 0) { |
| 9443 |
return "start "; //$NON-NLS1$ |
| 9444 |
} |
| 9445 |
else { |
| 9446 |
return "pot. nn/unknown "; //$NON-NLS1$ |
| 9447 |
} |
| 9448 |
} |
| 9449 |
else { |
| 9450 |
if (data[3] == 0) { |
| 9451 |
return "pot. null "; //$NON-NLS1$ |
| 9452 |
} |
| 9453 |
else { |
| 9454 |
return "pot. n/nn/unkn. "; //$NON-NLS1$ |
| 9455 |
} |
| 9456 |
} |
| 9457 |
} |
| 9458 |
else { |
| 9459 |
if (data[2] == 0) { |
| 9460 |
if (data[3] == 0) { |
| 9461 |
return "prot. null "; //$NON-NLS1$ |
| 9462 |
} |
| 9463 |
else { |
| 9464 |
return "0101 "; //$NON-NLS1$ |
| 9465 |
} |
| 9466 |
} |
| 9467 |
else { |
| 9468 |
if (data[3] == 0) { |
| 9469 |
return "prot. null + pot. null"; //$NON-NLS1$ |
| 9470 |
} |
| 9471 |
else { |
| 9472 |
return "0111 "; //$NON-NLS1$ |
| 9473 |
} |
| 9474 |
} |
| 9475 |
} |
| 9476 |
} |
| 9477 |
else { |
| 9478 |
if (data[1] == 0) { |
| 9479 |
if (data[2] == 0) { |
| 9480 |
if (data[3] == 0) { |
| 9481 |
return "1000 "; //$NON-NLS1$ |
| 9482 |
} |
| 9483 |
else { |
| 9484 |
return "assigned non null "; //$NON-NLS1$ |
| 9485 |
} |
| 9486 |
} |
| 9487 |
else { |
| 9488 |
if (data[3] == 0) { |
| 9489 |
return "assigned null "; //$NON-NLS1$ |
| 9490 |
} |
| 9491 |
else { |
| 9492 |
return "assigned unknown "; //$NON-NLS1$ |
| 9493 |
} |
| 9494 |
} |
| 9495 |
} |
| 9496 |
else { |
| 9497 |
if (data[2] == 0) { |
| 9498 |
if (data[3] == 0) { |
| 9499 |
return "protected non null "; //$NON-NLS1$ |
| 9500 |
} |
| 9501 |
else { |
| 9502 |
return "prot. nn + pot. nn/unknown"; //$NON-NLS1$ |
| 9503 |
} |
| 9504 |
} |
| 9505 |
else { |
| 9506 |
if (data[3] == 0) { |
| 9507 |
return "1110 "; //$NON-NLS1$ |
| 9508 |
} |
| 9509 |
else { |
| 9510 |
return "1111 "; //$NON-NLS1$ |
| 9511 |
} |
| 9512 |
} |
| 9513 |
} |
| 9514 |
} |
| 9515 |
} |
| 9516 |
|
| 9517 |
private void printTruthMap(long data[][][], int bit) { |
| 9518 |
final int dimension = 16; |
| 9519 |
printTruthMapHeader(); |
| 9520 |
char truthValues[][] = new char[dimension][dimension]; |
| 9521 |
int row, column; |
| 9522 |
for (row = 0; row < dimension; row++) { |
| 9523 |
for (column = 0; column < dimension; column++) { |
| 9524 |
truthValues[row][column] = '.'; |
| 9525 |
} |
| 9526 |
} |
| 9527 |
String rows[] = { |
| 9528 |
"0000", |
| 9529 |
"0001", |
| 9530 |
"0011", |
| 9531 |
"0111", |
| 9532 |
"1111", |
| 9533 |
"1110", |
| 9534 |
"1100", |
| 9535 |
"1000", |
| 9536 |
"1010", |
| 9537 |
"1011", |
| 9538 |
"1001", |
| 9539 |
"1101", |
| 9540 |
"0101", |
| 9541 |
"0100", |
| 9542 |
"0110", |
| 9543 |
"0010" |
| 9544 |
}; |
| 9545 |
if (false) { // checking row names |
| 9546 |
for (row = 0; row < dimension; row++) { |
| 9547 |
long [] state = new long [4]; |
| 9548 |
for (int i = 0; i < 4; i++) { |
| 9549 |
state[i] = rows[row].charAt(i) - '0'; |
| 9550 |
} |
| 9551 |
System.out.println(row + " " + rows[row] + " " + rankForState(state)); |
| 9552 |
} |
| 9553 |
} |
| 9554 |
for (int i = 0; i < data.length; i++) { |
| 9555 |
truthValues[rankForState(data[i][0])][rankForState(data[i][1])] = |
| 9556 |
(char) ('0' + data[i][2][bit]); |
| 9557 |
} |
| 9558 |
for (row = 0; row < dimension; row++) { |
| 9559 |
StringBuffer line = new StringBuffer(120); |
| 9560 |
line.append(rows[row]); |
| 9561 |
line.append(" | "); |
| 9562 |
for (column = 0; column < dimension; column++) { |
| 9563 |
line.append(truthValues[row][column]); |
| 9564 |
line.append(' '); |
| 9565 |
} |
| 9566 |
System.out.println(line); |
| 9567 |
} |
| 9568 |
} |
| 9569 |
|
| 9570 |
private void printTruthMapHeader() { |
| 9571 |
System.out.println(" 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0"); |
| 9572 |
System.out.println(" 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0"); |
| 9573 |
System.out.println(" 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1"); |
| 9574 |
System.out.println(" 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0"); |
| 9575 |
System.out.println(" --------------------------------"); |
| 9576 |
} |
| 9577 |
|
| 9578 |
private int rankForState(long [] state) { |
| 9579 |
if (state[0] == 0) { |
| 9580 |
if (state[1] == 0) { |
| 9581 |
if (state[2] == 0) { |
| 9582 |
if (state[3] == 0) { |
| 9583 |
return 0; // 0000 |
| 9584 |
} |
| 9585 |
else { |
| 9586 |
return 1; // 0001 |
| 9587 |
} |
| 9588 |
} |
| 9589 |
else { |
| 9590 |
if (state[3] == 0) { |
| 9591 |
return 15; // 0010 |
| 9592 |
} |
| 9593 |
else { |
| 9594 |
return 2; // 0011 |
| 9595 |
} |
| 9596 |
} |
| 9597 |
} |
| 9598 |
else { |
| 9599 |
if (state[2] == 0) { |
| 9600 |
if (state[3] == 0) { |
| 9601 |
return 13; // 0100 |
| 9602 |
} |
| 9603 |
else { |
| 9604 |
return 12; // 0101 |
| 9605 |
} |
| 9606 |
} |
| 9607 |
else { |
| 9608 |
if (state[3] == 0) { |
| 9609 |
return 14; // 0110 |
| 9610 |
} |
| 9611 |
else { |
| 9612 |
return 3; // 0111 |
| 9613 |
} |
| 9614 |
} |
| 9615 |
} |
| 9616 |
} |
| 9617 |
else { |
| 9618 |
if (state[1] == 0) { |
| 9619 |
if (state[2] == 0) { |
| 9620 |
if (state[3] == 0) { |
| 9621 |
return 7; // 1000 |
| 9622 |
} |
| 9623 |
else { |
| 9624 |
return 10; // 1001 |
| 9625 |
} |
| 9626 |
} |
| 9627 |
else { |
| 9628 |
if (state[3] == 0) { |
| 9629 |
return 8; // 1010 |
| 9630 |
} |
| 9631 |
else { |
| 9632 |
return 9; // 1011 |
| 9633 |
} |
| 9634 |
} |
| 9635 |
} |
| 9636 |
else { |
| 9637 |
if (state[2] == 0) { |
| 9638 |
if (state[3] == 0) { |
| 9639 |
return 6; // 1100 |
| 9640 |
} |
| 9641 |
else { |
| 9642 |
return 11; // 1101 |
| 9643 |
} |
| 9644 |
} |
| 9645 |
else { |
| 9646 |
if (state[3] == 0) { |
| 9647 |
return 5; // 1110 |
| 9648 |
} |
| 9649 |
else { |
| 9650 |
return 4; // 1111 |
| 9651 |
} |
| 9652 |
} |
| 9653 |
} |
| 9654 |
} |
| 9655 |
} |
| 9656 |
} |
| 9657 |
|
| 9658 |
class TestLocalVariableBinding extends LocalVariableBinding { |
| 9659 |
final static char [] testName = {'t', 'e', 's', 't'}; |
| 9660 |
TestLocalVariableBinding(int id) { |
| 9661 |
super(testName, null, 0, false); |
| 9662 |
this.id = id; |
| 9663 |
} |
| 9664 |
} |
| 9665 |
|
| 9666 |
/** |
| 9667 |
* A class meant to augment |
| 9668 |
* @link{org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo} with |
| 9669 |
* capabilities in the test domain. It especially provides factories to build |
| 9670 |
* fake flow info instances for use in state transition tables validation. |
| 9671 |
*/ |
| 9672 |
class UnconditionalFlowInfoTestHarness extends UnconditionalFlowInfo { |
| 9673 |
private int testPosition; |
| 9674 |
|
| 9675 |
/** |
| 9676 |
* Return a fake unconditional flow info which bit fields represent the given |
| 9677 |
* null bits for a local variable of id 0 within a class that would have no |
| 9678 |
* field. |
| 9679 |
* @param nullBits the bits that must be set, given in the same order as the |
| 9680 |
* nullAssignment* fields in UnconditionalFlowInfo definition; use 0 |
| 9681 |
* for a bit that is not set, 1 else |
| 9682 |
* @return a fake unconditional flow info which bit fields represent the |
| 9683 |
* null bits given in parameter |
| 9684 |
*/ |
| 9685 |
public static UnconditionalFlowInfoTestHarness testUnconditionalFlowInfo( |
| 9686 |
long [] nullBits) { |
| 9687 |
return testUnconditionalFlowInfo(nullBits, 0); |
| 9688 |
} |
| 9689 |
|
| 9690 |
public FlowInfo copy() { |
| 9691 |
UnconditionalFlowInfoTestHarness copy = |
| 9692 |
new UnconditionalFlowInfoTestHarness(); |
| 9693 |
copy.testPosition = this.testPosition; |
| 9694 |
copy.definiteInits = this.definiteInits; |
| 9695 |
copy.potentialInits = this.potentialInits; |
| 9696 |
boolean hasNullInfo = (this.tagBits & NULL_FLAG_MASK) != 0; |
| 9697 |
if (hasNullInfo) { |
| 9698 |
copy.nullAssignmentStatusBit1 = this.nullAssignmentStatusBit1; |
| 9699 |
copy.nullAssignmentStatusBit2 = this.nullAssignmentStatusBit2; |
| 9700 |
copy.nullAssignmentValueBit1 = this.nullAssignmentValueBit1; |
| 9701 |
copy.nullAssignmentValueBit2 = this.nullAssignmentValueBit2; |
| 9702 |
} |
| 9703 |
copy.tagBits = this.tagBits; |
| 9704 |
copy.maxFieldCount = this.maxFieldCount; |
| 9705 |
if (this.extra != null) { |
| 9706 |
int length; |
| 9707 |
copy.extra = new long[extraLength][]; |
| 9708 |
System.arraycopy(this.extra[0], 0, |
| 9709 |
(copy.extra[0] = new long[length = extra[0].length]), 0, length); |
| 9710 |
System.arraycopy(this.extra[1], 0, |
| 9711 |
(copy.extra[1] = new long[length]), 0, length); |
| 9712 |
if (hasNullInfo) { |
| 9713 |
for (int j = 0; j < extraLength; j++) { |
| 9714 |
System.arraycopy(this.extra[j], 0, |
| 9715 |
(copy.extra[j] = new long[length]), 0, length); |
| 9716 |
} |
| 9717 |
} |
| 9718 |
else { |
| 9719 |
for (int j = 0; j < extraLength; j++) { |
| 9720 |
copy.extra[j] = new long[length]; |
| 9721 |
} |
| 9722 |
} |
| 9723 |
} |
| 9724 |
return copy; |
| 9725 |
} |
| 9726 |
|
| 9727 |
/** |
| 9728 |
* Return a fake unconditional flow info which bit fields represent the given |
| 9729 |
* null bits for a local variable of id position within a class that would have |
| 9730 |
* no field. |
| 9731 |
* @param nullBits the bits that must be set, given in the same order as the |
| 9732 |
* nullAssignment* fields in UnconditionalFlowInfo definition; use 0 |
| 9733 |
* for a bit that is not set, 1 else |
| 9734 |
* @param position the position of the variable within the bit fields; use |
| 9735 |
* various values to test different parts of the bit fields, within |
| 9736 |
* or beyond BitCacheSize |
| 9737 |
* @return a fake unconditional flow info which bit fields represent the |
| 9738 |
* null bits given in parameter |
| 9739 |
*/ |
| 9740 |
public static UnconditionalFlowInfoTestHarness testUnconditionalFlowInfo( |
| 9741 |
long [] nullBits, int position) { |
| 9742 |
UnconditionalFlowInfoTestHarness result = |
| 9743 |
new UnconditionalFlowInfoTestHarness(); |
| 9744 |
result.testPosition = position; |
| 9745 |
if (position < BitCacheSize) { |
| 9746 |
result.nullAssignmentStatusBit1 = nullBits[0] << position; |
| 9747 |
result.nullAssignmentStatusBit2 = nullBits[1] << position; |
| 9748 |
result.nullAssignmentValueBit1 = nullBits[2] << position; |
| 9749 |
result.nullAssignmentValueBit2 = nullBits[3] << position; |
| 9750 |
} |
| 9751 |
else { |
| 9752 |
int vectorIndex = (position / BitCacheSize) - 1, |
| 9753 |
length = vectorIndex + 1; |
| 9754 |
position %= BitCacheSize; |
| 9755 |
result.extra = new long[extraLength][]; |
| 9756 |
result.extra[0] = new long[length]; |
| 9757 |
result.extra[1] = new long[length]; |
| 9758 |
for (int j = 2; j < extraLength; j++) { |
| 9759 |
result.extra[j] = new long[length]; |
| 9760 |
result.extra[j][vectorIndex] = nullBits[j - 2] << |
| 9761 |
position; |
| 9762 |
} |
| 9763 |
} |
| 9764 |
if ((nullBits[0] | nullBits[1] | nullBits[2] | nullBits[3]) != 0) { |
| 9765 |
result.tagBits |= NULL_FLAG_MASK; |
| 9766 |
} |
| 9767 |
result.maxFieldCount = 0; |
| 9768 |
return result; |
| 9769 |
} |
| 9770 |
|
| 9771 |
/** |
| 9772 |
* Return a fake unconditional flow info which bit fields represent the given |
| 9773 |
* null bits for a pair of local variables of id position and position + |
| 9774 |
* extra * BitCacheSize within a class that would have no field. |
| 9775 |
* @param nullBits the bits that must be set, given in the same order as the |
| 9776 |
* nullAssignment* fields in UnconditionalFlowInfo definition; use 0 |
| 9777 |
* for a bit that is not set, 1 else |
| 9778 |
* @param position the position of the variable within the bit fields; use |
| 9779 |
* various values to test different parts of the bit fields, within |
| 9780 |
* or beyond BitCacheSize |
| 9781 |
* @param extra the length of the allocated extra bit fields, if position is |
| 9782 |
* beyond BitCacheSize; unused otherwise; make sure it is big enough to |
| 9783 |
* match position (that is, extra > position - BitCacheSize) |
| 9784 |
* @return a fake unconditional flow info which bit fields represent the |
| 9785 |
* null bits given in parameter |
| 9786 |
*/ |
| 9787 |
public static UnconditionalFlowInfoTestHarness testUnconditionalFlowInfo( |
| 9788 |
long [] nullBits, int position, int extra) { |
| 9789 |
UnconditionalFlowInfoTestHarness result = |
| 9790 |
new UnconditionalFlowInfoTestHarness(); |
| 9791 |
result.testPosition = position; |
| 9792 |
if (position < BitCacheSize) { |
| 9793 |
result.nullAssignmentStatusBit1 = nullBits[0] << position; |
| 9794 |
result.nullAssignmentStatusBit2 = nullBits[1] << position; |
| 9795 |
result.nullAssignmentValueBit1 = nullBits[2] << position; |
| 9796 |
result.nullAssignmentValueBit2 = nullBits[3] << position; |
| 9797 |
} |
| 9798 |
else { |
| 9799 |
int vectorIndex = (position / BitCacheSize) - 1, |
| 9800 |
length = extra / BitCacheSize; |
| 9801 |
position %= BitCacheSize; |
| 9802 |
result.extra = new long[extraLength][]; |
| 9803 |
result.extra[0] = new long[length]; |
| 9804 |
result.extra[1] = new long[length]; |
| 9805 |
for (int j = 2; j < extraLength; j++) { |
| 9806 |
result.extra[j] = new long[length]; |
| 9807 |
result.extra[j] [vectorIndex]= nullBits[j - 2] << position; |
| 9808 |
} |
| 9809 |
} |
| 9810 |
if (nullBits[1] != 0 || nullBits[3] != 0 || nullBits[0] != 0 || nullBits[2] != 0 ) { |
| 9811 |
// cascade better than nullBits[0] | nullBits[1] | nullBits[2] | nullBits[3] |
| 9812 |
// by 10%+ |
| 9813 |
// TODO (maxime) run stats to determine which is the better order |
| 9814 |
result.tagBits |= NULL_FLAG_MASK; |
| 9815 |
} |
| 9816 |
result.maxFieldCount = 0; |
| 9817 |
return result; |
| 9818 |
} |
| 9819 |
|
| 9820 |
/** |
| 9821 |
* Return true iff this flow info can be considered as equal to the one passed |
| 9822 |
* in parameter. |
| 9823 |
* @param other the flow info to compare to |
| 9824 |
* @return true iff this flow info compares equal to other |
| 9825 |
*/ |
| 9826 |
public boolean testEquals(UnconditionalFlowInfo other) { |
| 9827 |
if (this.tagBits != other.tagBits) { |
| 9828 |
return false; |
| 9829 |
} |
| 9830 |
if (this.nullAssignmentStatusBit1 != other.nullAssignmentStatusBit1 || |
| 9831 |
this.nullAssignmentStatusBit2 != other.nullAssignmentStatusBit2 || |
| 9832 |
this.nullAssignmentValueBit1 != other.nullAssignmentValueBit1 || |
| 9833 |
this.nullAssignmentValueBit2 != other.nullAssignmentValueBit2) { |
| 9834 |
return false; |
| 9835 |
} |
| 9836 |
int left = this.extra == null ? 0 : this.extra[0].length, |
| 9837 |
right = other.extra == null ? 0 : other.extra[0].length, |
| 9838 |
both = 0, i; |
| 9839 |
if (left > right) { |
| 9840 |
both = right; |
| 9841 |
} |
| 9842 |
else { |
| 9843 |
both = left; |
| 9844 |
} |
| 9845 |
for (i = 0; i < both ; i++) { |
| 9846 |
if (this.extra[2][i] != |
| 9847 |
other.extra[2][i] || |
| 9848 |
this.extra[3][i] != |
| 9849 |
other.extra[3][i] || |
| 9850 |
this.extra[4][i] != |
| 9851 |
other.extra[4][i] || |
| 9852 |
this.extra[5][i] != |
| 9853 |
other.extra[5][i]) { |
| 9854 |
return false; |
| 9855 |
} |
| 9856 |
} |
| 9857 |
for (; i < left; i++) { |
| 9858 |
if (this.extra[2][i] != 0 || |
| 9859 |
this.extra[3][i] != 0 || |
| 9860 |
this.extra[4][i] != 0 || |
| 9861 |
this.extra[5][i] != 0) { |
| 9862 |
return false; |
| 9863 |
} |
| 9864 |
} |
| 9865 |
for (; i < right; i++) { |
| 9866 |
if (other.extra[2][i] != 0 || |
| 9867 |
other.extra[3][i] != 0 || |
| 9868 |
other.extra[4][i] != 0 || |
| 9869 |
other.extra[5][i] != 0) { |
| 9870 |
return false; |
| 9871 |
} |
| 9872 |
} |
| 9873 |
return true; |
| 9874 |
} |
| 9875 |
|
| 9876 |
/** |
| 9877 |
* Return true iff this flow info can be considered as equal to the one passed |
| 9878 |
* in parameter in respect with a single local variable which id would be |
| 9879 |
* position in a class with no field. |
| 9880 |
* @param other the flow info to compare to |
| 9881 |
* @param position the position of the local to consider |
| 9882 |
* @return true iff this flow info compares equal to other for a given local |
| 9883 |
*/ |
| 9884 |
public boolean testEquals(UnconditionalFlowInfo other, int position) { |
| 9885 |
int vectorIndex = position / BitCacheSize - 1; |
| 9886 |
if ((this.tagBits & other.tagBits & NULL_FLAG_MASK) == 0) { |
| 9887 |
return true; |
| 9888 |
} |
| 9889 |
long mask; |
| 9890 |
if (vectorIndex < 0) { |
| 9891 |
return ((this.nullAssignmentStatusBit1 & (mask = (1L << position))) ^ |
| 9892 |
(other.nullAssignmentStatusBit1 & mask)) == 0 && |
| 9893 |
((this.nullAssignmentStatusBit2 & mask) ^ |
| 9894 |
(other.nullAssignmentStatusBit2 & mask)) == 0 && |
| 9895 |
((this.nullAssignmentValueBit1 & mask) ^ |
| 9896 |
(other.nullAssignmentValueBit1 & mask)) == 0 && |
| 9897 |
((this.nullAssignmentValueBit2 & mask) ^ |
| 9898 |
(other.nullAssignmentValueBit2 & mask)) == 0; |
| 9899 |
} |
| 9900 |
else { |
| 9901 |
int left = this.extra == null ? |
| 9902 |
0 : |
| 9903 |
this.extra[0].length; |
| 9904 |
int right = other.extra == null ? |
| 9905 |
0 : |
| 9906 |
other.extra[0].length; |
| 9907 |
int both = left < right ? left : right; |
| 9908 |
if (vectorIndex < both) { |
| 9909 |
return ((this.extra[2][vectorIndex] & |
| 9910 |
(mask = (1L << (position % BitCacheSize)))) ^ |
| 9911 |
(other.extra[2][vectorIndex] & mask)) == 0 && |
| 9912 |
((this.extra[3][vectorIndex] & mask) ^ |
| 9913 |
(other.extra[3][vectorIndex] & mask)) == 0 && |
| 9914 |
((this.extra[4][vectorIndex] & mask) ^ |
| 9915 |
(other.extra[4][vectorIndex] & mask)) == 0 && |
| 9916 |
((this.extra[5][vectorIndex] & mask) ^ |
| 9917 |
(other.extra[5][vectorIndex] & mask)) == 0; |
| 9918 |
} |
| 9919 |
if (vectorIndex < left) { |
| 9920 |
return ((this.extra[2][vectorIndex] | |
| 9921 |
this.extra[3][vectorIndex] | |
| 9922 |
this.extra[4][vectorIndex] | |
| 9923 |
this.extra[5][vectorIndex]) & |
| 9924 |
(1L << (position % BitCacheSize))) == 0; |
| 9925 |
} |
| 9926 |
return ((other.extra[2][vectorIndex] | |
| 9927 |
other.extra[3][vectorIndex] | |
| 9928 |
other.extra[4][vectorIndex] | |
| 9929 |
other.extra[5][vectorIndex]) & |
| 9930 |
(1L << (position % BitCacheSize))) == 0; |
| 9931 |
} |
| 9932 |
} |
| 9933 |
|
| 9934 |
/** |
| 9935 |
* Return a string suitable for use as a representation of this flow info |
| 9936 |
* within test series. |
| 9937 |
* @return a string suitable for use as a representation of this flow info |
| 9938 |
*/ |
| 9939 |
public String testString() { |
| 9940 |
if (this == DEAD_END) { |
| 9941 |
return "FlowInfo.DEAD_END"; //$NON-NLS-1$ |
| 9942 |
} |
| 9943 |
return testString(this.testPosition); |
| 9944 |
} |
| 9945 |
|
| 9946 |
/** |
| 9947 |
* Return a string suitable for use as a representation of this flow info |
| 9948 |
* within test series. |
| 9949 |
* @param position a position to consider instead of this flow info default |
| 9950 |
* test position |
| 9951 |
* @return a string suitable for use as a representation of this flow info |
| 9952 |
*/ |
| 9953 |
public String testString(int position) { |
| 9954 |
if (this == DEAD_END) { |
| 9955 |
return "FlowInfo.DEAD_END"; //$NON-NLS-1$ |
| 9956 |
} |
| 9957 |
if (position < BitCacheSize) { |
| 9958 |
return "{" + (this.nullAssignmentStatusBit1 >> position) //$NON-NLS-1$ |
| 9959 |
+ "," + (this.nullAssignmentStatusBit2 >> position) //$NON-NLS-1$ |
| 9960 |
+ "," + (this.nullAssignmentValueBit1 >> position) //$NON-NLS-1$ |
| 9961 |
+ "," + (this.nullAssignmentValueBit2 >> position) //$NON-NLS-1$ |
| 9962 |
+ "}"; //$NON-NLS-1$ |
| 9963 |
} |
| 9964 |
else { |
| 9965 |
int vectorIndex = position / BitCacheSize - 1, |
| 9966 |
shift = position % BitCacheSize; |
| 9967 |
return "{" + (this.extra[2][vectorIndex] //$NON-NLS-1$ |
| 9968 |
>> shift) |
| 9969 |
+ "," + (this.extra[3][vectorIndex] //$NON-NLS-1$ |
| 9970 |
>> shift) |
| 9971 |
+ "," + (this.extra[4][vectorIndex] //$NON-NLS-1$ |
| 9972 |
>> shift) |
| 9973 |
+ "," + (this.extra[5][vectorIndex] //$NON-NLS-1$ |
| 9974 |
>> shift) |
| 9975 |
+ "}"; //$NON-NLS-1$ |
| 9976 |
} |
| 9977 |
} |
| 9978 |
} |
8053 |
} |