Skip to content

Commit 0e49b76

Browse files
committed
LVR tests
1 parent 3c621cc commit 0e49b76

3 files changed

Lines changed: 200 additions & 8 deletions

File tree

src/test/java/LVRTests.java

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
package test.java;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.util.Arrays;
6+
import java.util.Collection;
7+
import java.util.LinkedList;
8+
import java.util.List;
9+
import java.util.regex.Pattern;
10+
11+
import mujava.api.MutationOperator;
12+
import mujava.app.MutantInfo;
13+
14+
import org.junit.Test;
15+
import org.junit.runner.RunWith;
16+
import org.junit.runners.Parameterized;
17+
import org.junit.runners.Parameterized.Parameters;
18+
19+
import test.java.utils.Property;
20+
import test.java.utils.TestingTools;
21+
22+
@RunWith(Parameterized.class)
23+
public class LVRTests {
24+
25+
private Property prop;
26+
private List<MutantInfo> mutantsInfo;
27+
28+
public LVRTests(Property prop, List<MutantInfo> mutantsInfo) {
29+
this.prop = prop;
30+
this.mutantsInfo = mutantsInfo;
31+
}
32+
33+
34+
@Parameters
35+
public static Collection<Object[]> firstValues() {
36+
37+
//TESTS DEFINITIONS
38+
39+
Property propMutantsGenerated = new Property(MutationOperator.LVR, "lvr/LVR", "foo", 47, 47, TestingTools.NO_PATTERN_EXPECTED, TestingTools.NO_PATTERN_EXPECTED);
40+
41+
/*
42+
* original : int a = 5 \\+ 1 \\+ 0 \\+ (\\-1); //mutGenLimit 1
43+
* 9 mutants
44+
*/
45+
List<Pattern> ml1e = new LinkedList<Pattern>();
46+
ml1e.add(Pattern.compile("int a = 1 \\+ 1 \\+ 0 \\+ \\-1; //mutGenLimit 0"));
47+
ml1e.add(Pattern.compile("int a = \\-1 \\+ 1 \\+ 0 \\+ \\-1; //mutGenLimit 0"));
48+
ml1e.add(Pattern.compile("int a = 0 \\+ 1 \\+ 0 \\+ \\-1; //mutGenLimit 0"));
49+
50+
ml1e.add(Pattern.compile("int a = 5 \\+ \\-1 \\+ 0 \\+ \\-1; //mutGenLimit 0"));
51+
ml1e.add(Pattern.compile("int a = 5 \\+ 0 \\+ 0 \\+ \\-1; //mutGenLimit 0"));
52+
53+
ml1e.add(Pattern.compile("int a = 5 \\+ 1 \\+ 1 \\+ \\-1; //mutGenLimit 0"));
54+
ml1e.add(Pattern.compile("int a = 5 \\+ 1 \\+ \\-1 \\+ \\-1; //mutGenLimit 0"));
55+
56+
ml1e.add(Pattern.compile("int a = 5 \\+ 1 \\+ 0 \\+ 1; //mutGenLimit 0"));
57+
ml1e.add(Pattern.compile("int a = 5 \\+ 1 \\+ 0 \\+ 0; //mutGenLimit 0"));
58+
List<Pattern> ml1ne = new LinkedList<Pattern>();
59+
Property mutationsLine1 = new Property(MutationOperator.LVR, "lvr/LVR", "foo", TestingTools.NO_MUTANTS_EXPECTED, TestingTools.NO_MUTANTS_EXPECTED, ml1e, ml1ne);
60+
61+
/*
62+
* original : float b = 1\\.0f \\+ 0.0f \\+ (\\-1\\.0f) \\+ 1\\.2f; //mutGenLimit 1
63+
* 9 mutants
64+
*/
65+
List<Pattern> ml2e = new LinkedList<Pattern>();
66+
ml2e.add(Pattern.compile("float b = 0.0f \\+ 0.0f \\+ \\-1\\.0f \\+ 1\\.2f; //mutGenLimit 0"));
67+
ml2e.add(Pattern.compile("float b = \\-1\\.0f \\+ 0.0f \\+ \\-1\\.0f \\+ 1\\.2f; //mutGenLimit 0"));
68+
69+
ml2e.add(Pattern.compile("float b = 1\\.0f \\+ 1\\.0f \\+ \\-1\\.0f \\+ 1\\.2f; //mutGenLimit 0"));
70+
ml2e.add(Pattern.compile("float b = 1\\.0f \\+ \\-1\\.0f \\+ \\-1\\.0f \\+ 1\\.2f; //mutGenLimit 0"));
71+
72+
ml2e.add(Pattern.compile("float b = 1\\.0f \\+ 0.0f \\+ 1\\.0f \\+ 1\\.2f; //mutGenLimit 0"));
73+
ml2e.add(Pattern.compile("float b = 1\\.0f \\+ 0.0f \\+ 0.0f \\+ 1\\.2f; //mutGenLimit 0"));
74+
75+
ml2e.add(Pattern.compile("float b = 1\\.0f \\+ 0.0f \\+ \\-1\\.0f \\+ 1\\.0f; //mutGenLimit 0"));
76+
ml2e.add(Pattern.compile("float b = 1\\.0f \\+ 0.0f \\+ \\-1\\.0f \\+ \\-1\\.0f; //mutGenLimit 0"));
77+
ml2e.add(Pattern.compile("float b = 1\\.0f \\+ 0.0f \\+ \\-1\\.0f \\+ 0.0f; //mutGenLimit 0"));
78+
List<Pattern> ml2ne = new LinkedList<Pattern>();
79+
Property mutationsLine2 = new Property(MutationOperator.LVR, "lvr/LVR", "foo", TestingTools.NO_MUTANTS_EXPECTED, TestingTools.NO_MUTANTS_EXPECTED, ml2e, ml2ne);
80+
81+
/*
82+
* original : return "Hi " \\+ " ( " \\+ 5.0f \\+ 1\\.0f \\+ " alalala: " \\+ 0l \\+ (\\-1l) \\+ 42 * (5l \\+ 1l) \\+ ")"; //mutGenLimit 1
83+
* 21 mutants
84+
*
85+
*
86+
*/
87+
List<Pattern> ml3e = new LinkedList<Pattern>();
88+
ml3e.add(Pattern.compile("return \"\" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
89+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \"\" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
90+
91+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 1\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
92+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ \\-1\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
93+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 0\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
94+
95+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ \\-1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
96+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 0\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
97+
98+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \"\" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
99+
100+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 1l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
101+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ \\-1l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
102+
103+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ 1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
104+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ 0l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
105+
106+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 1 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
107+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ \\-1 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
108+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 0 \\* \\(5l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
109+
110+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(1l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
111+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(\\-1l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
112+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(0l \\+ 1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
113+
114+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ \\-1l\\) \\+ \"\\)\"; //mutGenLimit 0"));
115+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 0l\\) \\+ \"\\)\"; //mutGenLimit 0"));
116+
117+
ml3e.add(Pattern.compile("return \"Hi \" \\+ \" \\( \" \\+ 5\\.0f \\+ 1\\.0f \\+ \" alalala: \" \\+ 0l \\+ \\-1l \\+ 42 \\* \\(5l \\+ 1l\\) \\+ \"\"; //mutGenLimit 0"));
118+
List<Pattern> ml3ne = new LinkedList<Pattern>();
119+
Property mutationsLine3 = new Property(MutationOperator.LVR, "lvr/LVR", "foo", TestingTools.NO_MUTANTS_EXPECTED, TestingTools.NO_MUTANTS_EXPECTED, ml3e, ml3ne);
120+
121+
/*
122+
* original : String c = "It's " \\+ true \\+ " or " \\+ !false \\+ " or " \\+ false \\+ " but not " \\+ !true; //mutGenLimit 1
123+
* 8 mutants
124+
*/
125+
List<Pattern> ml4e = new LinkedList<Pattern>();
126+
ml4e.add(Pattern.compile("String c = \"\" \\+ true \\+ \" or \" \\+ !false \\+ \" or \" \\+ false \\+ \" but not \" \\+ !true; //mutGenLimit 0"));
127+
ml4e.add(Pattern.compile("String c = \"It's \" \\+ false \\+ \" or \" \\+ !false \\+ \" or \" \\+ false \\+ \" but not \" \\+ !true; //mutGenLimit 0"));
128+
ml4e.add(Pattern.compile("String c = \"It's \" \\+ true \\+ \"\" \\+ !false \\+ \" or \" \\+ false \\+ \" but not \" \\+ !true; //mutGenLimit 0"));
129+
ml4e.add(Pattern.compile("String c = \"It's \" \\+ true \\+ \" or \" \\+ !true \\+ \" or \" \\+ false \\+ \" but not \" \\+ !true; //mutGenLimit 0"));
130+
ml4e.add(Pattern.compile("String c = \"It's \" \\+ true \\+ \" or \" \\+ !false \\+ \"\" \\+ false \\+ \" but not \" \\+ !true; //mutGenLimit 0"));
131+
ml4e.add(Pattern.compile("String c = \"It's \" \\+ true \\+ \" or \" \\+ !false \\+ \" or \" \\+ true \\+ \" but not \" \\+ !true; //mutGenLimit 0"));
132+
ml4e.add(Pattern.compile("String c = \"It's \" \\+ true \\+ \" or \" \\+ !false \\+ \" or \" \\+ false \\+ \"\" \\+ !true; //mutGenLimit 0"));
133+
ml4e.add(Pattern.compile("String c = \"It's \" \\+ true \\+ \" or \" \\+ !false \\+ \" or \" \\+ false \\+ \" but not \" \\+ !false; //mutGenLimit 0"));
134+
List<Pattern> ml4ne = new LinkedList<Pattern>();
135+
Property mutationsLine4 = new Property(MutationOperator.LVR, "lvr/LVR", "foo", TestingTools.NO_MUTANTS_EXPECTED, TestingTools.NO_MUTANTS_EXPECTED, ml4e, ml4ne);
136+
137+
//MUTANTS FOLDERS
138+
List<MutantInfo> mfFoo;
139+
140+
141+
//MUTANTS GENERATION
142+
mfFoo = TestingTools.generateMutants(propMutantsGenerated);
143+
144+
//PARAMETERS
145+
return Arrays.asList(new Object[][] {
146+
{propMutantsGenerated, mfFoo},
147+
{mutationsLine1, mfFoo},
148+
{mutationsLine2, mfFoo},
149+
{mutationsLine3, mfFoo},
150+
{mutationsLine4, mfFoo}
151+
});
152+
}
153+
154+
@Test
155+
public void testThatMutantsCompile() {
156+
assertTrue(TestingTools.testThatMutantsCompile(this.prop, this.mutantsInfo));
157+
}
158+
159+
@Test
160+
public void testCorrectNumberOfMutants() {
161+
assertTrue(TestingTools.testCorrectNumberOfMutants(this.prop, this.mutantsInfo));
162+
}
163+
164+
@Test
165+
public void testCorrectMutantsGenerated() {
166+
assertTrue(TestingTools.testExpectedMutantsFound(this.prop, this.mutantsInfo));
167+
}
168+
169+
@Test
170+
public void testMutantsNotExpected() {
171+
assertTrue(TestingTools.testUnexpectedMutantsNotFound(this.prop, this.mutantsInfo));
172+
}
173+
174+
@Test
175+
public void testMutantsMD5hash() {
176+
assertTrue(TestingTools.testMD5Hash(this.mutantsInfo));
177+
}
178+
179+
}

src/test/java/MujavaTests.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
AOIUTests.class, AORBTests.class, AORSTests.class, AORUTests.class,
1616
ASRSTests.class, CODTests.class, COITests.class, CORTests.class,
1717
EAMTests.class, EMMTests.class, EOATests.class, EOA_DUMBTests.class,
18-
CRCRTests.class, ICTests.class, EOA_STRICTTests.class, EOCTests.class,
19-
IHDTests.class, IHITests.class, IODTests.class, IOPTests.class,
20-
IPCTests.class, ISD_DUMBTests.class, ISD_SMARTTests.class, ISI_SMARTTests.class,
21-
JDCTests.class, JIDTests.class, JSDTests.class, JSITests.class,
22-
JTDTests.class, JTI_DUMBTests.class, JTI_SMARTTests.class, LODTests.class,
23-
LOITests.class, LORTests.class, OANTests.class, OMRTests.class,
24-
PCCTests.class, PCDTests.class, PMDTests.class, PPDTests.class,
25-
PRVOTests.class, PRVO_no_method_allowed_Options_Tests.class, PRVO_replaceAllByOne_left_Options_Tests.class,
18+
CRCRTests.class, ICTests.class, LVRTests.class, EOA_STRICTTests.class,
19+
EOCTests.class, IHDTests.class, IHITests.class, IODTests.class,
20+
IOPTests.class, IPCTests.class, ISD_DUMBTests.class, ISD_SMARTTests.class,
21+
ISI_SMARTTests.class, JDCTests.class, JIDTests.class,
22+
JSDTests.class, JSITests.class, JTDTests.class, JTI_DUMBTests.class,
23+
JTI_SMARTTests.class, LODTests.class, LOITests.class,
24+
LORTests.class, OANTests.class, OMRTests.class, PCCTests.class,
25+
PCDTests.class, PMDTests.class, PPDTests.class, PRVOTests.class,
26+
PRVO_no_method_allowed_Options_Tests.class, PRVO_replaceAllByOne_left_Options_Tests.class,
2627
PRVO_replaceAllByOne_right_Options_Tests.class, PRVO_TwoByOne_OneByTwo_Disabled_Options_Tests.class,
2728
RORTests.class, SORTests.class, GenericsParsingTests.class, GenericsWritingTests.class,
2829
PCITests.class, PNCTests.class, ObtainingMutationsTest.class,

test/lvr/LVR.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package lvr;
2+
3+
public class LVR {
4+
5+
public String foo() {
6+
int a = 5 + 1 + 0 + (-1); //mutGenLimit 1
7+
float b = 1.0f + 0.0f + (-1.0f) + 1.2f; //mutGenLimit 1
8+
String c = "It's " + true + " or " + !false + " or " + false + " but not " + !true; //mutGenLimit 1
9+
return "Hi " + " ( " + 5.0f + 1.0f + " alalala: " + 0l + (-1l) + 42 * (5l + 1l) + ")"; //mutGenLimit 1
10+
}
11+
12+
}

0 commit comments

Comments
 (0)