Verified Commit 09453ccc authored by ubduq's avatar ubduq

Add test cases for semantic analysis

parent ad265467
class ArrayAccess {
public static void main(String[] args) {
int[] array = new int[3];
array[2] = 42;
int elem = array[2];
}
}
class Summator {
public int sum(int[] array, int len) {
int sum = 0;
int i = 0;
while(i < len) {
sum = sum + array[i];
i = i + 1;
}
return sum;
}
public static void main(String[] args) {
Summator acc = new Summator();
int arrayLen = System.in.read();
int[] array = new int[arrayLen];
int i = 0;
while(i < arrayLen) {
array[i] = System.in.read();
i = i + 1;
}
int arraySum = acc.sum(array, arrayLen);
System.out.write(arraySum);
System.out.flush();
}
}
class DuplicateClass {}
class DuplicateClass {}
class DuplicateField {
public int duplicate;
public int duplicate;
public static void main(String[] args) {}
}
class EmptyWhile {
public static void main(String[] args) {
while(true);
}
}
class FieldShadowing {
public int x;
public static void main(String[] args) {}
public void test() {
int x = 42;
this.x = x;
}
}
class MismatchingTypeComparison {
public static void main(String[] args) {
boolean x = false;
boolean y = true;
boolean a;
a = x < y;
a = x <= y;
a = x > y;
a = x >= y;
}
}
class MyClass {
public static void main(String[] args) {}
}
class DeepThought {
public static void main(String[] args) {
DeepThought a = new DeepThought();
boolean b = a.returnTheAnswer();
}
public int returnTheAnswer() {
return 42;
}
}
class MismatchingTypeComparison {
public static void main(String[] args) {
int a = 10;
int b = 42;
boolean x = false;
boolean y = true;
boolean z;
z = a < x;
z = a <= x;
z = a > x;
z = a >= x;
z = a != x;
z = b != y;
}
}
class MissingStaticMethod {
public void test() {
int a = 42;
}
}
class MultipleStaticMethods {
public static void main(String[] args) {}
public static void test(String[] args) {}
}
class Test {
public static void main(String[] args) { }
public void test(int a) {
int a = 23;
}
}
class RedeclarationSameScope {
public static void main(String[] args) {
int a = 0;
int a = 42;
}
}
class Test {
public static void main(String[] args) {
}
public void test() {
int a = 0;
{
int a = 42;
}
}
}
class Test {
public static void test(String[] params) {}
}
class Test {
public static void main(String[] args) {}
public boolean test() {
int a = 10;
if(a > 0)
if(a > 5)
return true;
else return false;
else return true;
}
}
class SpecialParamUsage {
public static void main(String[] args) {
String[] myArgs = args;
}
}
class StandardLibraryCalls {
public static void main(String[] args) {
int a = 42;
int b = System.in.read();
System.out.println(a);
System.out.write(a);
System.out.flush();
}
}
class StaticMethodCall {
public static void main(String[] args) {}
public void test() {
int arg = 10;
main(arg);
}
}
class StaticMethodThrows {
public static void main(String[] args) throws RuntimeException {}
}
class StringUsage {
public String test;
public static void main(String[] args) {}
}
class UsageBeforeDeclarationField {
public static void main(String[] args) {
UsageBeforeDeclarationField x = new UsageBeforeDeclarationField();
x.test();
}
public void test() {
a = 42;
}
public int a;
}
class UsageBeforeDeclarationMethod {
public static void main(String[] args) {}
public void methodA() {
methodB();
}
public void methodB() {
methodA();
}
}
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