Commit c1c61750 authored by updjx's avatar updjx

this a squased commit with testcases from group1

parent ad265467
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
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;
}
}
/**
* 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
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
/**
* 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
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;
}
}
/**
* 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;
}
}
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 {}
/**
* 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
/**
* Declare void as type for variale
* java:6: error: '(' expected -> for method
*/
class VoidAttribute {
public void a;
public static void main(String[] args) {}
}
class WrongReturnTypeVoid {
public static void main(String[] args) {}
public void a() {
/*should not allow return of integer*/
return 5;
}
}
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