Commit a4b6e13a authored by ucifm's avatar ucifm
Browse files

added semantic tests of group 5

parent 06736cad
Pipeline #177366 failed with stage
in 10 minutes and 13 seconds
/* All control paths need a return. */
class Main {
public int foo() {
if (0 == 0) {
} else {
return 0;
}
}
public static void main(String[] args) {
}
}
/* All control paths need a return. */
class Main {
public int foo() {
if (0 == 0) {
return 1;
}
}
public static void main(String[] args) {
}
}
/* All control paths need a return. */
class Main {
public int foo() {
/* Ironically, this is valid in proper Java, but let's not. */
while (true) {
if (0 == 0) {
return 1;
}
}
}
public static void main(String[] args) {
}
}
/* All control paths need a return. */
class Main {
public int foo() {
while (false) {
return 1;
}
}
public static void main(String[] args) {
}
}
/* OK */
class Main {
public int foo1() {
if (0 == 0) {
}
return 1;
}
public int foo2() {
if (0 == 0) {
return 0;
} else {
}
return 1;
}
public int foo3() {
if (0 == 0) {
return 0;
} else {
return 1;
}
}
public int foo4() {
while (true) {
}
return 0;
}
public int foo5() {
while (true) {
if (true) {
return 1;
}
}
return 0;
}
public static void main(String[] args) {
}
}
/* You may only instanciate a variable once per block */
class Main {
public static void main(String[] args) {
int i = 0;
{
int i = 2;
}
int i = 3;
}
}
/* new array expression is not allowed in expression statements. */
class Main {
public static void main(String[] args) {
new int[10];
}
}
/* NewObjectExpressions are not allowed in expression statements. */
class Main {
public static void main(String[] args) {
new Main();
}
}
/* println can only take ints */
class Main {
public static void main(String[] args) {
System.out.println();
}
}
/* println can only take ints */
class Main {
public static void main(String[] args) {
System.out.println(true);
}
}
/* Can not redefine string */
class String {
}
class Main {
public static void main(String[] args) {
}
}
/* Declaring a main method in the same class as the static main method is not allowed. */
class Main {
public void main() {
}
public static void main(String[] args) {
Main m = new Main();
m.main();
}
}
/* OK */
/* According to the language spec, `args` from the main may not
be used in the body of the main method, but strictly speaking
that does not exclude (valid) usage elsewhere. */
class foo {
public void main(String[] args) {
}
}
class main {
public void foo(String[] args) {
foo foo = new foo();
foo.main(args);
}
public static void main(String[] args) {
main main = new main();
main.foo(null);
}
}
/* String may not be declared as a user type. */
class String {
}
class Main {
public static void main(String[] args) {
}
}
/* Instances of type String may not be created. */
class Main {
public static void main(String[] args) {
String s = new String();
}
}
/* Can not create objects of String */
class Main {
public static void main(String[] args) {
String s = new String();
}
}
/* OK */
class Main {
public static void main(String[] args) {
String s = null;
}
}
/* System is not an intrinsic class (like String) */
class Main {
public static void main(String[] args) {
System s = null;
}
}
/* `this` is not allowed in `main`. */
class Main {
public int x;
public static void main(String[] args) {
this.x = 2;
}
}
/* OK */
class Main {
public void foo() throws Exception {
}
public static void main(String[] args) {
Main m = new Main();
m.foo();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment