Commit ba41596e authored by uwdkn's avatar uwdkn

Merge branch 'additional-semantic-testcases' into 'master'

Supplemental semantic test cases

See merge request !37
parents fc83035f 80cf892a
class Main {
public static void main(String[] arguments) {
Main main = new Main();
main.getArray()[0] = 1;
new Main().getArray()[0] = 2;
}
public int[] getArray() {
int[] result = new int[1];
result[0] = 42;
return result;
}
}
class Main {
public static void main(String[] arguments) {
System = null;
}
}
class Main {
public static void main(String[] arguments) {
System.out = null;
}
}
class FieldAccessStatic {
public int nonStatic;
public static void main(String[] args) {
nonStatic = 42;
}
}
class FieldAccess {
public int field;
public static void main(String[] args) {
new FieldAccess().accessField();
}
public void accessField() {
int i = FieldAccess.field;
}
}
class Main {
public static void main(String[] arguments) {
Main main = new Main();
main.getX().x = null;
new Main().getX().x = null;
}
public X getX() {
return new X();
}
}
class X {
public X x;
}
/*
* This should be rejected by a MiniJava compiler like it is by the
* Java compiler as the class "System" shadows the default System
* declaration, but cannot have a static field named "out".
*/
class System {
public static void main(String[] args) {
System.out.println(42);
}
}
class TooMuchArrayAccess {
public static void main(String[] args) {
int[] array = new int[3];
array[2][1] = 42;
}
}
/*
* MiniJava compilers are not allowed to reject programs only because
* they contain unreachable code, unlike Java compilers.
*/
class UnreachableCode {
public static void main(String[] args) {
int i = 42;
return;
int j = 23;
}
}
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