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
8f3571f5
Commit
8f3571f5
authored
Nov 02, 2021
by
Schaback
Committed by
Paul Brinkmeier
Nov 04, 2021
Browse files
Added first syntax tests
parent
7f44cdbc
Changes
27
Hide whitespace changes
Inline
Side-by-side
syntax/assignment_expression_statement_after_if.valid.mj
0 → 100644
View file @
8f3571f5
/* OK */
class Main {
public static void main(String[] args) {
int x;
if (true) x = 3;
}
}
syntax/class_with_public.invalid.mj
0 → 100644
View file @
8f3571f5
public class Foo {
int i;
}
class Main {
public static void main(String[] args) {
}
}
syntax/deeply_nested_calc.valid.mj
0 → 100644
View file @
8f3571f5
/* OK */
class Main {
public static void main(String[] args) {
int i = 1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 +
(1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 + (1 )
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))));
}
}
syntax/disallowed_bitwise_or.invalid.mj
0 → 100644
View file @
8f3571f5
/* Bitwise or is disallowed */
class Main {
public static void main(String[] args) {
int x = 123 | 33;
}
}
syntax/disallowed_constructors.invalid.mj
0 → 100644
View file @
8f3571f5
/* Constructors are not allowed.
// Alternatively, methods needs to have a return type. */
class Foo {
public Foo() {
}
}
class Main {
public static void main(String[] args) {
}
}
syntax/disallowed_initialized_attributes.invalid.mj
0 → 100644
View file @
8f3571f5
/* This should fail because you are not allowed to initialize attributes. */
class Foo {
int i = 123;
}
class Main {
public static void main(String[] args) {
}
}
syntax/every_possible_language_construct.valid.mj
0 → 100644
View file @
8f3571f5
/* OK */
class Main {
public int x;
public String s;
public Object[][][][] o;
public static void main(String[] args) {
}
public void test(int x, String s) {
Object a = new Object();
int[] b = new int[0];
SomeClass[][][] c = new SomeClass[22][][];
int important_calculation = 4 >= 5 || y % true + this / b * -a - !(a && b);
Main m = new Main();
m.x = 666;
m.s = null;
m.o = new Object[3][][][];
m.o[m.x] = this.m.o[m.x / 123];
if (null) return;
else ;;;;;
boolean b = !new Main().test().foo();
boolean c = new Main().o[foo(test())[1]].foo(!new int[0]);
}
public boolean foo() {
while (true) {
String a = null;
if (x > 123) {
} else
System.out.println(xx);
}
while (1 + 5 > x) return x;
test(43, new String());
return true || bb && aa;
}
}
class OtherClass {
public void fun;
}
syntax/invalid_identifier_1.invalid.mj
0 → 100644
View file @
8f3571f5
/* This should fail because 'throw' is a keyword and therefore not an acceptable identifier */
class Main {
public static void main(String[] args) {
int throw = 123;
}
}
syntax/invalid_identifier_2.invalid.mj
0 → 100644
View file @
8f3571f5
/* This should fail because '11foo' is not an acceptable identifier */
class Main {
public static void main(String[] args) {
int 11foo = 123;
}
}
syntax/invalid_identifier_3.invalid.mj
0 → 100644
View file @
8f3571f5
/* This should fail because '!' is not allowed in identifiers */
class Main {
public static void main(String[] args) {
int asd! = 123;
}
}
syntax/local_variable_statement_after_if.invalid.mj
0 → 100644
View file @
8f3571f5
/* This should fail because the statement after an if can't be a local variable statement. */
class Main {
public static void main(String[] args) {
if (true) int x = 123;
}
}
syntax/main_method_without_public.invalid.mj
0 → 100644
View file @
8f3571f5
/* This should fail, because the main method doesn't have the public access modifier. */
class Main {
static void main(String[] args) {
}
}
syntax/many_braces.valid.mj
0 → 100644
View file @
8f3571f5
/* OK */
class Main {
public static void main(String[] args) {
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{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}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}};
}
}
syntax/many_parentheses.valid.mj
0 → 100644
View file @
8f3571f5
/* OK */
class Main {
public static void main(String[] args) {
int i =(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
1 + 1
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
}
}
syntax/method_invocation.valid.mj
0 → 100644
View file @
8f3571f5
/* OK , method invocation */
class Foo {
public int i;
public void bar() {
}
}
class Main {
public static void main(String[] args) {
Foo foo = new Foo();
foo.bar();
}
}
syntax/method_without_public.invalid.mj
0 → 100644
View file @
8f3571f5
/* This should fail, because the 'fac' method doesn't have the public access modifier. */
class Main {
public static void main(String[] args) {
}
int fac(int i) {
return i;
}
}
syntax/missing_string_param_main_method.invalid.mj
0 → 100644
View file @
8f3571f5
/* This should fail because the main method is missing its String[] argument. */
class Main {
public static void main() {
}
}
syntax/nested_comments.invalid.mj
0 → 100644
View file @
8f3571f5
/* This should fail because nested comments are not supported */
/*
* This is a mini java program. /* it is very good */
*/
class Main {
public static void main(String[] args) {
}
}
syntax/no_ternary_op.invalid.mj
0 → 100644
View file @
8f3571f5
/* No ternary operator allowed */
class Main {
public static void main(String[] args) {
int x = 213;
int y = x == 100 ? 2 : 4;
}
}
syntax/simple_method_call.valid.mj
0 → 100644
View file @
8f3571f5
/* OK tests implicit method call */
class Main {
public static void main(String[] args) {
foo();
}
}
Prev
1
2
Next
Write
Preview
Supports
Markdown
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