Skip to content

Commit

Permalink
A bunch more tests - a few ecj based string switch ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
leibnitz27 committed Jun 5, 2020
1 parent 734d8b5 commit 9e7a2b5
Show file tree
Hide file tree
Showing 23 changed files with 317 additions and 0 deletions.
1 change: 1 addition & 0 deletions compile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ REM
@echo on
call mvn compile -P java_6
call mvn compile -P java_8
call mvn compile -P ojava_8
call mvn compile -P java_10
call mvn compile -P java_12
call mvn compile -P java_13
Expand Down
Binary file removed hardcoded/HackedName.class.bak
Binary file not shown.
Binary file removed hardcoded/ThrowsClauseExact.class.bak
Binary file not shown.
Binary file removed hardcoded/ThrowsClauseExact2.class.bak
Binary file not shown.
Binary file removed hardcoded/package-info.class.bak
Binary file not shown.
28 changes: 28 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,34 @@
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ojava_8</id>
<properties>
<langver>8</langver>
<path.javac>${OPEN_8_HOME}/bin/javac</path.javac>
<path.source_6>src_6</path.source_6>
<path.source_8>src_8</path.source_8>
<path.source_10>src</path.source_10>
<path.source_12>src</path.source_12>
<path.source_14>src</path.source_14>
<path.target>output/ojava_8</path.target>
<javac.arguments></javac.arguments>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<executable>${path.javac}</executable>
<compilerArgs>
<arg>-Xlint:none</arg>
<arg>${javac.arguments}</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
Expand Down
12 changes: 12 additions & 0 deletions src_6/org/benf/cfr/tests/ArrayTest20.java
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]);
}
}
12 changes: 12 additions & 0 deletions src_6/org/benf/cfr/tests/ArrayTest21.java
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]);
}
}
21 changes: 21 additions & 0 deletions src_6/org/benf/cfr/tests/DoubleNegationTest.java
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;
}
}
11 changes: 11 additions & 0 deletions src_6/org/benf/cfr/tests/InfiniteLoopTest1.java
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++;
}
}
}
11 changes: 11 additions & 0 deletions src_6/org/benf/cfr/tests/InfiniteLoopTest2.java
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);
}
}
25 changes: 25 additions & 0 deletions src_6/org/benf/cfr/tests/InnerClassTest50b.java
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");
}
};

}
}
18 changes: 18 additions & 0 deletions src_6/org/benf/cfr/tests/LoopTest73.java
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");
}
}
}
20 changes: 20 additions & 0 deletions src_6/org/benf/cfr/tests/OutNotConstantTest.java
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.");
}
}
}
22 changes: 22 additions & 0 deletions src_6/org/benf/cfr/tests/OutNotConstantTest2.java
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.");
}
}
}
13 changes: 13 additions & 0 deletions src_6/org/benf/cfr/tests/TypeClashTest.java
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];
}
}
11 changes: 11 additions & 0 deletions src_6/org/benf/cfr/tests/UncheckedCastTest.java
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
}
}
9 changes: 9 additions & 0 deletions src_8/org/benf/cfr/tests/NotLoopTest.java
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];
}
}
}
17 changes: 17 additions & 0 deletions src_8/org/benf/cfr/tests/StringSwitchTest5.java
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;
}
}
}

}
16 changes: 16 additions & 0 deletions src_8/org/benf/cfr/tests/StringSwitchTest6.java
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!");
}
}

}
18 changes: 18 additions & 0 deletions src_8/org/benf/cfr/tests/StringSwitchTest7.java
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!");
}
}

}
26 changes: 26 additions & 0 deletions src_8/org/benf/cfr/tests/StringSwitchTest8.java
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!");
}
}
}

}
26 changes: 26 additions & 0 deletions src_8/org/benf/cfr/tests/StringSwitchTest8a.java
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!");
}
}
}

}

0 comments on commit 9e7a2b5

Please sign in to comment.