Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IPDSnelting
mjtest-tests
Commits
a4b6e13a
Commit
a4b6e13a
authored
Nov 17, 2021
by
ucifm
Browse files
added semantic tests of group 5
parent
06736cad
Pipeline
#177366
failed with stage
in 10 minutes and 13 seconds
Changes
63
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
semantic/InvalidAssignment11.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Some assignments are not allowed. */
class Main {
public static void main(String[] args) {
new Main() = new Main();
}
}
semantic/InvalidAssignment12.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Some assignments are not allowed. */
class Main {
public static void main(String[] args) {
new int[3][] = new int[3][];
}
}
semantic/InvalidAssignment2.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Some assignments are not allowed. */
class Main {
public static void main(String[] args) {
int x = 0;
x + x = 1;
}
}
semantic/InvalidAssignment3.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Some assignments are not allowed. */
class Main {
public static void main(String[] args) {
int x = 0;
-x = 1;
}
}
semantic/InvalidAssignment4.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Some assignments are not allowed. */
class Main {
public void foo() {
}
public static void main(String[] args) {
Main m = new Main();
m.foo() = 1;
}
}
semantic/InvalidAssignment5.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Some assignments are not allowed. */
class Main {
public static void main(String[] args) {
null = 1;
}
}
semantic/InvalidAssignment6.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Some assignments are not allowed. */
class Main {
public static void main(String[] args) {
false = true;
}
}
semantic/InvalidAssignment7.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Some assignments are not allowed. */
class Main {
public static void main(String[] args) {
0 = 1;
}
}
semantic/InvalidAssignment9.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Some assignments are not allowed. */
class Main {
public void bar() {
}
public void foo() {
bar() = 1;
}
public static void main(String[] args) {
}
}
semantic/InvalidMethodInvocation.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Method invocation is missing parentheses */
class Foo {
public int i;
public void bar() {
}
}
class Main {
public static void main(String[] args) {
Foo foo = new Foo();
foo.bar;
}
}
semantic/InvalidVoid1.invalid.mj
0 → 100644
View file @
a4b6e13a
/* `void` cannot be used outside of the return type. */
class Main {
public static void main(String[] args) {
void x;
}
}
semantic/InvalidVoid2.invalid.mj
0 → 100644
View file @
a4b6e13a
/* `void` cannot be used outside of the return type. */
class Main {
public void x;
public static void main(String[] args) {
}
}
semantic/InvalidVoid3.invalid.mj
0 → 100644
View file @
a4b6e13a
/* `void` cannot be used outside of the return type. */
class Main {
public void foo(void x) {
}
public static void main(String[] args) {
}
}
semantic/LvalueInParenthesesAssigned.valid.mj
0 → 100644
View file @
a4b6e13a
/* OK */
class Main {
public static void main(String[] args) {
int x = 1;
(x) = 2;
}
}
semantic/MainMethodArgUsageNotNamedArgs.invalid.mj
0 → 100644
View file @
a4b6e13a
/* NOT OK */
class Main {
public static void main(String[] i) {
String s = i[0];
}
}
semantic/MainMethodCalled.invalid.mj
0 → 100644
View file @
a4b6e13a
/* It is not allowed to call the main method */
class Main {
public static void main(String[] args) {
main(args);
}
}
semantic/MainMethodWithoutStatic.invalid.mj
0 → 100644
View file @
a4b6e13a
/* This should fail, because the main method doesn't have the static keyword */
class Main {
public void main(String[] args) {
}
}
semantic/MissingMainMethod.invalid.mj
0 → 100644
View file @
a4b6e13a
/* This should fail because there is no main method (with public static) */
class Main {
public void main(String[] args) {
}
}
semantic/MissingMethod.invalid.mj
0 → 100644
View file @
a4b6e13a
/* Methods that are called need to be declared. */
class Main {
public void foo() {
}
public static void main(String[] args) {
Main m = new Main();
m.bar();
}
}
semantic/MissingReturn1.invalid.mj
0 → 100644
View file @
a4b6e13a
/* All control paths need a return. */
class Main {
public int foo() {
if (0 == 0) {
return 1;
} else {
}
}
public static void main(String[] args) {
}
}
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment