Skip to content
Snippets Groups Projects
Commit e94f3833 authored by Xun Yang's avatar Xun Yang
Browse files

add a4 tests

parent 4c111a8d
No related branches found
No related tags found
No related merge requests found
Showing
with 319 additions and 0 deletions
// REACHABILITY
public class J1_7_Reachability_AfterIfWithWhileTrue {
public J1_7_Reachability_AfterIfWithWhileTrue () {}
public static int test() {
int x=123;
if (x==122) while (true);
return x;
}
}
// REACHABILITY
public class J1_7_Reachability_EmptyVoidMethod {
public J1_7_Reachability_EmptyVoidMethod() {}
public void empty() {}
public static int test() {
return 123;
}
}
// REACHABILITY
public class J1_7_Reachability_IfAndWhile_Return {
public J1_7_Reachability_IfAndWhile_Return() {}
public static int test() {
int x=121;
if (x==120) return x;
while (x==121) return x+2;
return x;
}
}
// REACHABILITY
public class J1_7_Reachability_IfThenElse_InConstructor {
public J1_7_Reachability_IfThenElse_InConstructor(boolean b) {
if (b) return;
else return;
}
public static int test() {
return 123;
}
}
// REACHABILITY
public class J1_7_Reachability_IfThenElse_InValueMethod {
public J1_7_Reachability_IfThenElse_InValueMethod() {}
public int method(boolean b) {
if (b) return 42;
else return 123;
}
public static int test() {
return 123;
}
}
// REACHABILITY
public class J1_7_Reachability_IfThenElse_InVoidMethod {
public J1_7_Reachability_IfThenElse_InVoidMethod() {}
public void method(boolean b) {
if (b) return;
else return;
}
public static int test() {
return 123;
}
}
// REACHABILITY
/**
* Reachability:
* - If the body of a method whose return type is not void can
* complete normally, produce an error message.
*
* The condition (false || true) is constant folded into ABooleanConstExp, x, with x.value == true.
*/
public class J1_7_Reachability_WhileTrue_ConstantFolding {
public J1_7_Reachability_WhileTrue_ConstantFolding() {}
public int method() {
while (false || true) {}
}
public static int test() {
return 123;
}
}
// REACHABILITY
/**
* Reachability:
* - Check that all statements (including empty statements and empty
* blocks) are reachable.
*/
public class J1_7_Unreachable_IfEqualsNot {
public J1_7_Unreachable_IfEqualsNot(){}
public static int test(){
return J1_7_Unreachable_IfEqualsNot.bar(true);
}
public static int bar(boolean foo) {
if (foo == !foo) {
int h = 100;
return h;
}
return 123;
}
}
// REACHABILITY
public class J1_Reachable1 {
public J1_Reachable1(){}
public String test2() {
for (int i = 100; i < 50; i=i+1) {
i = i + 1;
}
return "";
}
public static int test() {
return 123;
}
}
// REACHABILITY
public class J1_Reachable2 {
public J1_Reachable2(){}
public static int test() {
int i = 1;
;;;
int j = 2;
return 120 + j + i;
}
}
// REACHABILITY
public class J1_Reachable3 {
public J1_Reachable3(){}
public static int test() {
int h = 1;
{
}
int j = 2;
return 120 + j + h;
}
}
// REACHABILITY
public class J1_Reachable4 {
public J1_Reachable4(){}
public static int test() {
int x = 1;
if (false) { x=3; }
return 122 + x;
}
}
// REACHABILITY
public class J1_Unreachable {
public J1_Unreachable(){}
public static int test() {
String foo = "foo";
String bar = "bar";
for (int i = 100; foo.equals((Object) bar); i=i+1) {
i = i + 1;
}
return 123;
}
}
// REACHABILITY
public class J1_arbitraryreturn {
public J1_arbitraryreturn() {}
public int m(int x) {
if (x==42)
return 123;
else
return 117;
}
public static int test() {
J1_arbitraryreturn obj = new J1_arbitraryreturn();
int y = obj.m(42);
if (y!=123) {
return 42;
}
else {
return y;
}
}
}
// DEFINITE_ASSIGNMENT
public class J1_defasn_use_before_declare {
public J1_defasn_use_before_declare() {}
public static int test() {return new J1_defasn_use_before_declare().foo();}
protected int a = 23;
public int foo() {
int tmp = a;
int a = 100;
return a+tmp;
}
}
// PARSER_WEEDER,REACHABILITY
public class J1_ifThenElse {
public J1_ifThenElse () {
}
public static int test() {
if (true)
if (false) {
return 7;
}
else {
return 123;
}
else
return 7;
}
public static void main(String[] args) {
System.out.println(J1_ifThenElse.test());
}
}
// PARSER_WEEDER,REACHABILITY
public class J1_if_then {
public J1_if_then() {}
public static int test() {
if (true)
return 123;
return 7;
}
}
// REACHABILITY
public class J1_multipleReturn {
public J1_multipleReturn () {}
public static int test() {
return new J1_multipleReturn().foo(-1) + new J1_multipleReturn().foo(1);
}
public int foo(int j) {
if (j <= 0) {
return 27;
}
else {
return 96;
}
}
}
// REACHABILITY
public class J1_omittedvoidreturn {
public J1_omittedvoidreturn() {}
public int y;
public void m() {
this.y = 17;
// return;
}
public static int test() {
J1_omittedvoidreturn obj = new J1_omittedvoidreturn();
obj.m();
return obj.y+106;
}
}
// REACHABILITY
import java.util.Random;
public class Main {
public Random random = new Random();
public Main () {}
public void m() {
if (random.nextBoolean()) {
System.out.println("then branch completes normally!");
}
else {
return;
}
}
public void m1() {
if (random.nextBoolean()) {
return;
}
else {
return;
}
}
public static int test() {
Main j = new Main();
j.m();
j.m1();
return 123;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment