Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for labeled blocks in constructor #437

Open
wants to merge 1 commit into
base: develop/1.11.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion test/org/jetbrains/java/decompiler/SingleClassesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private void registerDefault() {
register(JAVA_8_NODEBUG, "TestArrayNull2");
register(JAVA_8, "TestArrayNullAccess");
register(JAVA_8, "TestArrayTernary");
// TODO: Do while loops become standard while loops
// TODO: Do while loops become standard while loops, and creates incorrect short-circuiting
register(JAVA_8, "TestAssignmentInDoWhile");
register(JAVA_8, "TestBooleanAssignment");
register(JAVA_8, "TestCastObjectToPrimitive");
Expand Down Expand Up @@ -520,6 +520,8 @@ private void registerDefault() {
registerRaw(CUSTOM, "TestHotjava");
registerRaw(CUSTOM, "TestJava1Synchronized");
register(JAVA_8, "TestLabeledBreaks");
// TODO: the super() call ends up inside the labeled block
register(JAVA_8, "TestLabeledBlockInConstructor");
// TODO: test9&10- for loop not created, loop extractor needs another pass
register(JAVA_8, "TestSwitchLoop");
register(JAVA_8, "TestSwitchFinally");
Expand Down
80 changes: 80 additions & 0 deletions testData/results/pkg/TestLabeledBlockInConstructor.dec
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package pkg;

public class TestLabeledBlockInConstructor {
public TestLabeledBlockInConstructor() {
boolean result;
label12: {
super();// 4
if (Math.random() < 0.5) {// 7
System.out.println(1);// 8
if (Math.random() < 0.5) {// 9
result = false;// 10
break label12;// 11
}
}

result = true;// 14
}

System.out.println(result);// 16
}// 17
}

class 'pkg/TestLabeledBlockInConstructor' {
method '<init> ()V' {
1 6
2 6
3 6
4 7
5 7
6 7
7 7
8 7
9 7
a 7
b 7
c 7
d 7
e 8
f 8
10 8
11 8
12 8
13 8
14 8
15 9
16 9
17 9
18 9
19 9
1a 9
1b 9
1c 9
1d 9
1e 9
1f 10
20 10
21 11
24 15
25 15
26 18
27 18
28 18
29 18
2a 18
2b 18
2c 18
2d 19
}
}

Lines mapping:
4 <-> 7
7 <-> 8
8 <-> 9
9 <-> 10
10 <-> 11
11 <-> 12
14 <-> 16
16 <-> 19
17 <-> 20
18 changes: 18 additions & 0 deletions testData/src/java8/pkg/TestLabeledBlockInConstructor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package pkg;

public class TestLabeledBlockInConstructor {
public TestLabeledBlockInConstructor() {
boolean result;
block: {
if (Math.random() < 0.5) {
System.out.println(1); // print statement to prevent simplification into ||
if (Math.random() < 0.5) {
result = false;
break block;
}
}
result = true;
}
System.out.println(result);
}
}