Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
uydwl
mjtest-tests
Commits
c1c61750
Commit
c1c61750
authored
Nov 12, 2018
by
updjx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
this a squased commit with testcases from group1
parent
ad265467
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
291 additions
and
0 deletions
+291
-0
semantic/AttributeKill.valid.java
semantic/AttributeKill.valid.java
+29
-0
semantic/AttributeOrSystem.valid.java
semantic/AttributeOrSystem.valid.java
+30
-0
semantic/CompareClassAttributes.valid.java
semantic/CompareClassAttributes.valid.java
+50
-0
semantic/LocalInitClass.valid.java
semantic/LocalInitClass.valid.java
+22
-0
semantic/LocalVariableOverwriteAttribute.valid.java
semantic/LocalVariableOverwriteAttribute.valid.java
+24
-0
semantic/NoConstructedObjectCall.invalid.mj
semantic/NoConstructedObjectCall.invalid.mj
+28
-0
semantic/NoParameterDeclaration.invalid.mj
semantic/NoParameterDeclaration.invalid.mj
+19
-0
semantic/OverwriteAttributeWithUndeclaredVariable.invalid.mj
semantic/OverwriteAttributeWithUndeclaredVariable.invalid.mj
+17
-0
semantic/RightVariable.valid.java
semantic/RightVariable.valid.java
+46
-0
semantic/VoidAttribute.invalid.mj
semantic/VoidAttribute.invalid.mj
+13
-0
semantic/WrongReturnTypeVoid.invalid.mj
semantic/WrongReturnTypeVoid.invalid.mj
+13
-0
No files found.
semantic/AttributeKill.valid.java
0 → 100644
View file @
c1c61750
class
AttributeKill
{
public
A
objectA
;
public
static
void
main
(
String
[]
args
)
{
A
objectA
=
new
A
();
objectA
.
init
();
objectA
=
null
;
int
a
=
objectA
.
atr
;
}
}
class
A
{
public
int
atr
;
/* pseudo constructor */
public
void
init
()
{
atr
=
2
;
}
}
\ No newline at end of file
semantic/AttributeOrSystem.valid.java
0 → 100644
View file @
c1c61750
class
AttributeOrSystem
{
/* public int System; // error: int cannot be dereferenced*/
public
static
void
main
(
String
[]
args
)
{
A
objA
=
new
A
();
objA
.
init
();
System
.
out
.
println
(
objA
.
atr
);
}
}
class
A
{
public
int
atr
;
public
void
init
()
{
atr
=
2
;
}
}
semantic/CompareClassAttributes.valid.java
0 → 100644
View file @
c1c61750
/**
* TODO 2 testcases?
*/
class
CompareClassAttributes
{
public
static
void
main
(
String
[]
args
)
{
A
objectA
=
new
A
();
B
objectB
=
new
B
();
objectA
.
init
();
objectB
.
init
();
int
result
;
boolean
bigger
;
bigger
=
objectA
.
atr
>
objectB
.
atr
;
result
=
objectA
.
atr
+
objectB
.
atr
;
}
}
class
A
{
public
int
atr
;
public
void
init
()
{
atr
=
2
;
}
}
class
B
{
public
int
atr
;
public
void
init
()
{
atr
=
3
;
}
}
\ No newline at end of file
semantic/LocalInitClass.valid.java
0 → 100644
View file @
c1c61750
class
LocalInitClass
{
public
static
void
main
(
String
[]
args
)
{
Test
test
=
new
Test
();
/*giving the localVariable itself as parameter*/
test
.
algorithm
(
test
);
}
}
class
Test
{
public
Test
testlocalVar
;
public
int
algorithm
(
Test
Test
)
{
testlocalVar
=
Test
;
return
0
;
}
}
\ No newline at end of file
semantic/LocalVariableOverwriteAttribute.valid.java
0 → 100644
View file @
c1c61750
/**
* Check if attribute can be initializsed with expression and then used for initializing other local variable
*/
class
LocalVariableOverwriteAttribute
{
public
int
varInt
;
public
void
algorithm
()
{
varInt
=
1
+
2
;
int
localVar
=
varInt
;
System
.
out
.
println
(
localVar
);
}
public
static
void
main
(
String
[]
args
)
{
LocalVariableOverwriteAttribute
test
=
new
LocalVariableOverwriteAttribute
();
test
.
algorithm
();
}
}
\ No newline at end of file
semantic/NoConstructedObjectCall.invalid.mj
0 → 100644
View file @
c1c61750
class NoConstructedObjectCall {
public static void main(String[] args) {}
public void test() {
int b = objA.atr;
return;
}
}
class A {
public int atr;
public void init () {
atr = 2;
}
}
semantic/NoParameterDeclaration.invalid.mj
0 → 100644
View file @
c1c61750
/**
* Call without Parameter to Method
* error: variable a is already defined in method test(int)
*/
class NoParameterDeclaration {
public static void main(String[] args) {
/*there is no parameter given here*/
testObj.test();
}
public void test (int i) {
int a = i;
}
}
semantic/OverwriteAttributeWithUndeclaredVariable.invalid.mj
0 → 100644
View file @
c1c61750
class OverwriteAttributeWithUndeclaredVariable {
public static void main(String[] args) {}
public String a;
public void test () {
/*should break here because of undeclared unknown variable*/
int a = i;
}
}
class String {}
semantic/RightVariable.valid.java
0 → 100644
View file @
c1c61750
/**
* Tests a lot of double naming
*/
class
RightVariable
{
public
static
void
main
(
String
[]
args
)
{}
public
int
Test
;
public
Test
Test
(
Test
Test
)
{
return
Test
;
}
public
void
testMethod
()
{
/*init Test object*/
Test
test
=
new
Test
();
/*call and init attribute of class*/
test
.
Test
=
3
;
/*init RightVariable Attribute*/
Test
=
5
;
/*Overwrite test attribute with RightVariable class Attribute*/
test
.
Test
=
Test
;
/*call local method with test*/
Test
(
test
);
/*Overwrite class Test with with local method Test, with itself given as an obj ref..*/
test
=
Test
(
test
);
}
}
class
Test
{
public
int
Test
;
public
void
Test
()
{}
}
\ No newline at end of file
semantic/VoidAttribute.invalid.mj
0 → 100644
View file @
c1c61750
/**
* Declare void as type for variale
* java:6: error: '(' expected -> for method
*/
class VoidAttribute {
public void a;
public static void main(String[] args) {}
}
semantic/WrongReturnTypeVoid.invalid.mj
0 → 100644
View file @
c1c61750
class WrongReturnTypeVoid {
public static void main(String[] args) {}
public void a() {
/*should not allow return of integer*/
return 5;
}
}
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