Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TestCases directory holds JDT projects for Ekeko tests.
- Loading branch information
Showing
13 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>TestCase-JDT-CompositeVisitor</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package test.damp.ekeko.cases; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
|
||
test.damp.ekeko.cases.compositevisitor.TestCase.runTest(); | ||
|
||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/Component.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
public class Component { | ||
public void addComponent(Component element) { | ||
} | ||
|
||
public void acceptVisitor(ComponentVisitor v) { | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/ComponentVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
public class ComponentVisitor { | ||
public void visitEmptyLeaf(Component c1) { | ||
} | ||
|
||
public void visitOnlyLoggingLeaf(Component c2) { | ||
|
||
} | ||
|
||
public void visitMustAliasLeaf(Component c3) { | ||
|
||
} | ||
|
||
public void visitMayAliasLeaf(Component c5) { | ||
|
||
} | ||
|
||
public void visitPrototypicalLeaf(Component c4) { | ||
|
||
} | ||
|
||
public void visitSuperLogLeaf(Component c4) { | ||
|
||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/Composite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
import java.util.Iterator; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
public class Composite extends Component { | ||
|
||
public List<Component> elements; | ||
|
||
public Composite() { | ||
elements = new LinkedList<Component>(); | ||
} | ||
|
||
public void addComponent(Component element) { | ||
elements.add(element); | ||
} | ||
|
||
public void acceptVisitor(ComponentVisitor v) { | ||
Iterator<Component> i = elements.iterator(); | ||
while (i.hasNext()) { | ||
Component comp = (Component) i.next(); | ||
comp.acceptVisitor(v); | ||
} | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/EmptyLeaf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
public class EmptyLeaf extends Component { | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/MayAliasLeaf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
public class MayAliasLeaf extends Component { | ||
|
||
public int getInput() { | ||
return 1; | ||
} | ||
|
||
public Object m(Object o) { | ||
if(getInput() % 2 == 0) | ||
return o; | ||
else | ||
return new MayAliasLeaf(); | ||
} | ||
|
||
public void acceptVisitor(ComponentVisitor v) { | ||
System.out.println("May alias."); | ||
v.visitMayAliasLeaf((MayAliasLeaf)m(this)); | ||
} | ||
} | ||
|
||
|
9 changes: 9 additions & 0 deletions
9
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/MustAliasLeaf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
public class MustAliasLeaf extends Component { | ||
public void acceptVisitor(ComponentVisitor v) { | ||
System.out.println("Must alias."); | ||
Component temp = this; | ||
v.visitMustAliasLeaf(temp); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/OnlyLoggingLeaf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
public class OnlyLoggingLeaf extends Component { | ||
public void acceptVisitor(ComponentVisitor v) { | ||
System.out.println("Only logging."); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/PrototypicalLeaf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
public class PrototypicalLeaf extends Component { | ||
public void acceptVisitor(ComponentVisitor v) { | ||
System.out.println("Prototypical."); | ||
v.visitPrototypicalLeaf(this); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/SuperLogLeaf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
public class SuperLogLeaf extends OnlyLoggingLeaf { | ||
public void acceptVisitor(ComponentVisitor v) { | ||
super.acceptVisitor(v); | ||
v.visitSuperLogLeaf(this); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
TestCases/Ekeko-JDT/src/test/damp/ekeko/cases/compositevisitor/TestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package test.damp.ekeko.cases.compositevisitor; | ||
|
||
public class TestCase { | ||
static public void runTest() { | ||
Composite cs = new Composite(); | ||
cs.addComponent(new EmptyLeaf()); | ||
cs.addComponent(new MayAliasLeaf()); | ||
cs.addComponent(new MustAliasLeaf()); | ||
cs.addComponent(new OnlyLoggingLeaf()); | ||
cs.addComponent(new PrototypicalLeaf()); | ||
cs.addComponent(new SuperLogLeaf()); | ||
ComponentVisitor vstor = new ComponentVisitor(); | ||
cs.acceptVisitor(vstor); | ||
System.out.println("done"); | ||
} | ||
} |