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
/* OK but maybe warnings */
class Main {
public static void main(String[] args) {
int i = -2147483648;
i = 2147483647;
i = -2147483648 - 1;
i = 2147483647 + 1;
i = 1000000000 * 10000000;
i = -1000000000 * -10000000;
i = 1000000000 * -10000000;
i = 1000 / 0;
i = 1000 % 0;
i = 0 * 1000000000 * 1000000000;
}
}
/* `args` may not be used in the main body. */
class main {
public void foo(String[] args) {
}
public static void main(String[] args) {
main main = new main();
main.foo(args);
}
}
/* Array access is not allowed in expression statements. */
class Main {
public static void main(String[] args) {
int[] i = new int[10];
i[123];
}
}
/* This should fail because array objects don't have an length attribute. */
class Main {
public static void main(String[] args) {
int[] foo = new int[123];
int length = foo.length;
}
}
/* OK */
class Main {
public static void main(String[] args) {
boolean b;
if (b = true) System.out.println(123);
}
}
/* OK */
class Main {
public static void main(String[] args) {
int x = System.in.read();
System.out.println(x);
System.out.write(x);
System.out.flush();
}
}
/* OK */
class System {
}
class Main {
public Main in;
public Main out;
public int read(int x) {
return x;
}
public int println(int x) {
return x;
}
public int write(int x) {
return x;
}
public void flush(int x) {
}
public static void main(String[] args) {
Main System = new Main();
int x = System.in.read(0);
x = System.out.println(x);
x = System.out.write(x);
System.out.flush(x);
}
}
/* OK */
class System {
}
class Main {
public Main System;
public Main in;
public Main out;
public int read(int x) {
return x;
}
public int println(int x) {
return x;
}
public int write(int x) {
return x;
}
public void flush(int x) {
}
public void foo() {
int x = System.in.read(0);
x = System.out.println(x);
x = System.out.write(x);
System.out.flush(x);
}
public static void main(String[] args) {
Main System = new Main();
System.in = new Main();
System.in.foo();
}
}
/* OK */
class System {
}
class Main {
public Main in;
public Main out;
public int read(int x) {
return x;
}
public int println(int x) {
return x;
}
public int write(int x) {
return x;
}
public void flush(int x) {
}
public void foo(Main System) {
int x = System.in.read(0);
x = System.out.println(x);
x = System.out.write(x);
System.out.flush(x);
}
public static void main(String[] args) {
Main System = new Main();
System.in = new Main();
System.in.foo(System.in);
}
}
/* When a System type is present, System.in refers to a static field within System
* (which does not exist in Mini-Java), and should hence fail instead of succeed
* like if the builtin method was used instead. */
class System {
}
class Main {
public static void main(String[] args) {
int x = System.in.read();
}
}
/* largest int constant is 2147483647 */
class Main {
public static void main(String[] args) {
int i = 2147483648;
}
}
/* smallest integer constant is -2147483648 */
class Main {
public static void main(String[] args) {
int i = -2147483649;
}
}
/* Method overloading is not allowed */
class Foo {
public int i;
public void bar() {
}
public void bar(int x) {
}
}
class Main {
public static void main(String[] args) {
Foo foo = new Foo();
}
}
/* Duplicate fields are not allowed. */
class Main {
public int foo;
public int foo;
public static void main(String[] args) {
}
}
/* Duplicate parameters are not allowed. */
class Main {
public void foo(int foobar, int foobar) {
}
public static void main(String[] args) {
}
}
/* flush takes no arguments */
class Main {
public static void main(String[] args) {
System.out.flush(234);
}
}
/* OK */
class Main {
public Main m;
public int foobar1;
public boolean foobar2;
public void foo() {
System.out.println(foobar1);
System.out.println(m.foobar1);
if (foobar2) {
foobar1 = 1;
} else {
foobar1 = 2;
}
System.out.println(foobar1);
}
public static void main(String[] args) {
int foo;
boolean bar;
Main m;
System.out.println(foo);
System.out.println(m.foobar1);
if (bar) {
foo = 1;
} else {
foo = 2;
}
System.out.println(foo);
}
}
/* This should fail because int expression in if condition. */
class Main {
public static void main(String[] args) {
int x;
if (x = 22) System.out.println(123);
}
}
/* Some assignments are not allowed. */
class Main {
public static void main(String[] args) {
boolean x = true;
x || x = true;
}
}
/* Some assignments are not allowed. */
class Main {
public void foo() {
this = new Main();
}
public static void main(String[] args) {
}
}
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