forked from leibnitz27/cfr_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A bunch more tests - a few ecj based string switch ones.
- Loading branch information
1 parent
734d8b5
commit 9e7a2b5
Showing
23 changed files
with
317 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class ArrayTest20 { | ||
static boolean byteArray = true; | ||
|
||
public static void main(String[] args) { | ||
Object array = null; | ||
array = byteArray ? new byte[1] : new boolean[1]; | ||
((byte[])array)[0] = 0; | ||
System.out.println(((byte[])array)[0]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class ArrayTest21 { | ||
static boolean byteArray = true; | ||
|
||
public static void main(String[] args) { | ||
Object[] array = null; | ||
array = byteArray ? new Byte[1] : new Boolean[1]; | ||
((Byte[])array)[0] = 0; | ||
System.out.println(((Byte[])array)[0]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class DoubleNegationTest { | ||
Boolean f1(boolean b){ | ||
return !!b; | ||
} | ||
|
||
boolean f2(boolean b) { | ||
return !!b; | ||
} | ||
|
||
// Fun - Fernflower bollocks up and returns b ;) | ||
// Idea also bollocks up and suggests you remove the negation. | ||
Boolean f3(Boolean b) { | ||
return !!b; | ||
} | ||
|
||
boolean f4(Boolean b) { | ||
return !!b; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class InfiniteLoopTest1 { | ||
public void foo(int x,int y) { | ||
while (true) { | ||
if (x>y) break; | ||
System.out.println(x); | ||
x++; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class InfiniteLoopTest2 { | ||
public void foo(int x,int y) { | ||
do { | ||
if (x>y) break; | ||
System.out.println(x); | ||
x++; | ||
} while (true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.benf.cfr.tests; | ||
|
||
|
||
/** | ||
* Another AbeC! | ||
*/ | ||
public class InnerClassTest50b { | ||
|
||
public void foo() { | ||
class Bug { | ||
void foo() { | ||
System.out.println("Bob"); | ||
} | ||
} | ||
Bug b = new Bug(); | ||
|
||
Bug c = new Bug() { | ||
@Override | ||
void foo() { | ||
System.out.println("Bar"); | ||
} | ||
}; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.benf.cfr.tests; | ||
|
||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class LoopTest73 { | ||
public static void main(String[] args) | ||
{ | ||
while (true) { | ||
System.out.println("HERE"); | ||
if (args.length < 10) continue;; | ||
System.out.println("THERE"); | ||
if (args.length < 5) continue;; | ||
System.out.println("EVERYWHERE"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.benf.cfr.tests; | ||
|
||
import java.io.PrintStream; | ||
|
||
public class OutNotConstantTest { | ||
public static void main(String ... args) { | ||
doAthing(); | ||
System.setOut(null); | ||
doAthing(); | ||
} | ||
|
||
private static void doAthing() { | ||
PrintStream ps = System.out; | ||
if (ps == null) { | ||
System.err.println("You've found it!"); | ||
} else { | ||
System.err.println("Nothing to see."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.benf.cfr.tests; | ||
|
||
import java.io.PrintStream; | ||
|
||
public class OutNotConstantTest2 { | ||
public static void main(String ... args) { | ||
try { | ||
doAthing(); | ||
} catch (Throwable t) { | ||
System.err.println("You found it!"); | ||
} | ||
} | ||
|
||
private static void doAthing() { | ||
PrintStream ps = System.out; | ||
if (ps == null) { | ||
System.err.println("Nothing to see."); | ||
} else { | ||
System.err.println("Nothing to see."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class TypeClashTest { | ||
void test() { | ||
for (int i = 0; i < 10; i++) { | ||
// CFR incorrectly moves aArr up and reuses it for this string | ||
String s = "test"; | ||
} | ||
|
||
int[] aArr = new int[1]; | ||
int[] bArr = new int[1]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.benf.cfr.tests; | ||
|
||
import java.util.List; | ||
|
||
public class UncheckedCastTest<T> { | ||
void use(T t) { } | ||
|
||
void doSomething(List<T> l) { | ||
use((T) l); // Unchecked cast | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class NotLoopTest { | ||
public void doIt(Boolean[] b) { | ||
for (int x=0;x<b.length;++x) { | ||
b[x] = !b[x]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class StringSwitchTest5 { | ||
public static void foo(String string) { | ||
while (true) { | ||
switch (string) { | ||
case "apples": | ||
System.out.println("apples"); | ||
break; | ||
case "pears": | ||
System.out.println("pears"); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class StringSwitchTest6 { | ||
public static void foo() { | ||
while (true) { | ||
switch ("test") { | ||
case "okay": | ||
System.out.println("wow!"); | ||
case "test": | ||
continue; | ||
} | ||
System.out.println("wow x2!"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class StringSwitchTest7 { | ||
public static void foo(int x) { | ||
while (true) { | ||
if (x < 5) { | ||
switch ("test") { | ||
case "okay": | ||
continue; | ||
default: | ||
continue; | ||
} | ||
} | ||
System.out.println("wow x2!"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class StringSwitchTest8 { | ||
public static void foo(int x, String a) { | ||
l1: while (true) { | ||
System.out.println("Such loop"); | ||
l2 : while (true) { | ||
System.out.println("Much pain"); | ||
if (x++ < 5) { | ||
switch (a) { | ||
case "Aa": | ||
case "okay": | ||
case "there": | ||
case "fellow": | ||
continue l1; | ||
case "BB": | ||
default: | ||
continue l2; | ||
} | ||
} | ||
System.out.println("wow x2!"); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.benf.cfr.tests; | ||
|
||
public class StringSwitchTest8a { | ||
public static void foo(int x, String a) { | ||
l1: while (x > 0) { | ||
System.out.println("Such loop"); | ||
l2 : while (true) { | ||
System.out.println("Much pain"); | ||
if (x++ < 5) { | ||
switch (a) { | ||
case "Aa": | ||
case "okay": | ||
case "there": | ||
case "fellow": | ||
continue l1; | ||
case "BB": | ||
default: | ||
continue l2; | ||
} | ||
} | ||
System.out.println("wow x2!"); | ||
} | ||
} | ||
} | ||
|
||
} |