-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
365 additions
and
3 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
68 changes: 68 additions & 0 deletions
68
.../src/test/java/fr/inria/diversify/transformation/query/AddMethodInvocationQuerryTest.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,68 @@ | ||
package fr.inria.diversify.transformation.query; | ||
|
||
import fr.inria.diversify.runner.InputConfiguration; | ||
import fr.inria.diversify.runner.InputProgram; | ||
import fr.inria.diversify.transformation.AddMethodInvocation; | ||
import fr.inria.diversify.util.InitUtils; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by nharrand on 23/01/17. | ||
*/ | ||
public class AddMethodInvocationQuerryTest { | ||
|
||
InputProgram inputProgram; | ||
|
||
public void setUp(boolean isStatic, boolean isInternal) { | ||
try { | ||
FileInputStream propertiesFile = new FileInputStream(new File("src/test/resources/jDummy/addMI/addMI_" | ||
+ (isStatic ? "s" : "ns") + "_" + (isInternal ? "i" : "e") + ".properties")); | ||
InputConfiguration inputConfiguration = new InputConfiguration(propertiesFile); | ||
|
||
inputProgram = InitUtils.initInputProgram(inputConfiguration); | ||
|
||
InitUtils.initSpoon(inputProgram, false); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static boolean containsString(Iterable<String> s, String v) { | ||
for(String str : s) { | ||
if(str.compareTo(v) == 0) return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Test | ||
public void query() throws Exception { | ||
setUp(true, true); | ||
AddMethodInvocationQuerry q = new AddMethodInvocationQuerry(inputProgram); | ||
|
||
while(q.hasNextTransformation()) { | ||
AddMethodInvocation t = (AddMethodInvocation) q.query(); | ||
//assertTrue(t.isjStatic()); | ||
} | ||
|
||
|
||
setUp(true, false); | ||
q = new AddMethodInvocationQuerry(inputProgram); | ||
|
||
while(q.hasNextTransformation()) { | ||
AddMethodInvocation t = (AddMethodInvocation) q.query(); | ||
assertTrue(t.isjStatic()); | ||
} | ||
|
||
} | ||
|
||
@Test | ||
public void hasNextTransformation() throws Exception { | ||
|
||
} | ||
|
||
} |
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
15 changes: 15 additions & 0 deletions
15
generator/src/test/resources/jDummy/addMI/addMI_ns_e.properties
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,15 @@ | ||
project=src/test/resources/jDummy/addMI/ | ||
javaVersion=8 | ||
nbRun=2 | ||
timeOut=-1 | ||
runner=simple | ||
transformation.type=addMI | ||
|
||
addmi.internalMethods=false | ||
addmi.externalMethods=true | ||
addmi.staticMethods=false | ||
addmi.nonstaticMethods=true | ||
addmi.dumpMethodsAfterSuccess=false | ||
addmi.shuffleCandidate=false | ||
addmi.shuffleMethods=false | ||
|
15 changes: 15 additions & 0 deletions
15
generator/src/test/resources/jDummy/addMI/addMI_ns_i.properties
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,15 @@ | ||
project=src/test/resources/jDummy/addMI/ | ||
javaVersion=8 | ||
nbRun=2 | ||
timeOut=-1 | ||
runner=simple | ||
transformation.type=addMI | ||
|
||
addmi.internalMethods=true | ||
addmi.externalMethods=false | ||
addmi.staticMethods=false | ||
addmi.nonstaticMethods=true | ||
addmi.dumpMethodsAfterSuccess=false | ||
addmi.shuffleCandidate=false | ||
addmi.shuffleMethods=false | ||
|
15 changes: 15 additions & 0 deletions
15
generator/src/test/resources/jDummy/addMI/addMI_s_e.properties
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,15 @@ | ||
project=src/test/resources/jDummy/addMI/ | ||
javaVersion=8 | ||
nbRun=2 | ||
timeOut=-1 | ||
runner=simple | ||
transformation.type=addMI | ||
|
||
addmi.internalMethods=false | ||
addmi.externalMethods=true | ||
addmi.staticMethods=true | ||
addmi.nonstaticMethods=false | ||
addmi.dumpMethodsAfterSuccess=false | ||
addmi.shuffleCandidate=false | ||
addmi.shuffleMethods=false | ||
|
15 changes: 15 additions & 0 deletions
15
generator/src/test/resources/jDummy/addMI/addMI_s_i.properties
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,15 @@ | ||
project=src/test/resources/jDummy/addMI/ | ||
javaVersion=8 | ||
nbRun=2 | ||
timeOut=-1 | ||
runner=simple | ||
transformation.type=addMI | ||
|
||
addmi.internalMethods=true | ||
addmi.externalMethods=false | ||
addmi.staticMethods=true | ||
addmi.nonstaticMethods=false | ||
addmi.dumpMethodsAfterSuccess=false | ||
addmi.shuffleCandidate=false | ||
addmi.shuffleMethods=false | ||
|
File renamed without changes.
66 changes: 66 additions & 0 deletions
66
generator/src/test/resources/jDummy/addMI/src/main/java/inria/A.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,66 @@ | ||
package inria; | ||
|
||
|
||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class A | ||
{ | ||
public byte b; | ||
public short s; | ||
public int i; | ||
public long l; | ||
public float f; | ||
public double d; | ||
public char c; | ||
public boolean bo; | ||
|
||
public A(byte b, short s, int i, long l, float f, double d, char c, boolean bo) { | ||
this.b = b; | ||
this.s = s; | ||
this.i = i; | ||
this.l = l; | ||
this.f = f; | ||
this.d = d; | ||
this.c = c; | ||
this.bo = bo; | ||
} | ||
|
||
public static void printHello() { | ||
System.out.println("Hello"); | ||
} | ||
|
||
public static A clone(A a) { | ||
A res = new A(a.b,a.s,a.i,a.l,a.f,a.d,a.c,a.bo); | ||
return res; | ||
} | ||
|
||
public int getI() { | ||
return i; | ||
} | ||
|
||
public int addI(int a) { | ||
return a + i; | ||
} | ||
|
||
public void print() { | ||
System.out.println("A: " + this.toString()); | ||
} | ||
|
||
public void addA(A a) { | ||
this.b = a.b; | ||
this.s = a.s; | ||
this.i = a.i; | ||
this.l = a.l; | ||
this.f = a.f; | ||
this.d = a.d; | ||
this.c = a.c; | ||
this.bo = a.bo; | ||
} | ||
|
||
public void addB(B b) { | ||
this.i += b.getI(); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
generator/src/test/resources/jDummy/addMI/src/main/java/inria/App.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,73 @@ | ||
package inria; | ||
|
||
|
||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class App | ||
{ | ||
public static void main( String[] args ) { | ||
|
||
System.out.println("0: "); | ||
A a = new A((byte) 0, (short) 0, (int) 0, (long) 0, (float) 0.0, (double) 0.0, '0', false); | ||
B b = new B(a); | ||
A ab = b.ba(a); | ||
ab.print(); | ||
System.out.println("1: " + loops()); | ||
System.out.println("2: " + conditions(15)); | ||
} | ||
|
||
public static int loops(){ | ||
int s = 0; | ||
for(int i = 0 ; 5 >= i; i = i + 1) { | ||
s += i; | ||
} | ||
|
||
int[] array = {1,2,3,4,5}; | ||
for(int i : array) { | ||
s += i; | ||
} | ||
|
||
int i = 0; | ||
while(i < 5) { | ||
s += i; | ||
i++; | ||
} | ||
|
||
i = 0; | ||
do { | ||
s += i; | ||
i++; | ||
} while (i < 5); | ||
return s; | ||
} | ||
|
||
public static int conditions(int i) { | ||
int r; | ||
if((i % 3) == 0) { | ||
r = 100; | ||
} else { | ||
r = 200; | ||
} | ||
if((i % 3) == 0) { | ||
r += 10; | ||
} else if ((i % 3) == 0) { | ||
r += 20; | ||
} else { | ||
r += 30; | ||
} | ||
switch(i % 3) { | ||
case 0: | ||
r += 1; | ||
break; | ||
case 1: | ||
r += 2; | ||
break; | ||
default: | ||
r += 3; | ||
} | ||
return r; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
generator/src/test/resources/jDummy/addMI/src/main/java/inria/B.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,19 @@ | ||
package inria; | ||
|
||
/** | ||
* Created by nharrand on 23/11/16. | ||
*/ | ||
public class B { | ||
int i; | ||
public B(A a) { | ||
this.i = a.i; | ||
} | ||
|
||
public A ba(A a) { | ||
return new A(a.b,a.s,a.i,a.l,a.f,a.d,a.c,a.bo); | ||
} | ||
|
||
public int getI() { | ||
return i; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...test/resources/jDummy/loopflip.properties → ...urces/jDummy/loopflip/loopflip.properties
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
project=src/test/resources/jDummy | ||
project=src/test/resources/jDummy/loopflip/ | ||
javaVersion=8 | ||
nbRun=2 | ||
timeOut=-1 | ||
|
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 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>inria</groupId> | ||
<artifactId>java-dummy</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>java-dummy</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
File renamed without changes.