Skip to content

Commit

Permalink
Add new rules removing lines of code
Browse files Browse the repository at this point in the history
  • Loading branch information
domohuhn committed Mar 24, 2024
1 parent 8ab5447 commit addf9f2
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 96 deletions.
10 changes: 5 additions & 5 deletions doc/output/example/source.dart.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@

<tr>
<td class="ItemLabel" width="10%">Date:</td>
<td class="ItemText" width="35%">2023-10-25 20:12:26.292830</td>
<td class="ItemText" width="35%">2024-03-24 15:27:37.230520</td>
<td class="ItemLabel" width="10%">Mutations:</td>
<td class="ItemReport" width="15%">22</td>
<td class="ItemReport" width="15%">42</td>
Expand All @@ -359,9 +359,9 @@
<td class="ItemLabel" width="10%">Builtin rules:</td>
<td class="ItemText" width="35%">true</td>
<td class="ItemLabel" width="10%">Blocked:</td>
<td class="ItemReport" width="15%">5</td>
<td class="ItemReport" width="15%">0</td>
<td class="ItemReport" width="15%">42</td>
<td class="ItemReportHigh" width="15%">11.9 %</td>
<td class="ItemReportHigh" width="15%">0.0 %</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -474,7 +474,7 @@
<a name="37"><span class="lineNumber"> 37 </span>double polyNotCovered(double x, double a, double b, double c) {</a>
<a name="38"><button class="collapsible problem"><pre class="fileContents"><span class="lineNumber"> 38 </span> return a * x * x + b * x + c;</pre></button>
<div class="content">
<b>Mutations not covered by tests:</b>
<b>Undetected mutations:</b>
<table class="mutationTable" width="100%">
<tr><td class="mutationLabel" width="5%">1 :</td><td class="mutationText" width="87%"><span class="addedLine">+ return a * x * x <span class="changedTokens">- </span>b * x + c;</span></td><td class="match">RegExp: pattern=\+([^=]) flags=m<span class="tooltip">Id: builtin.arith.add</span></td></tr><tr><td colspan="3"><hr class="ruler"/></td></tr><tr><td class="mutationLabel" width="5%">2 :</td><td class="mutationText" width="87%"><span class="addedLine">+ return a * x * x + b * x <span class="changedTokens">- </span>c;</span></td><td class="match">RegExp: pattern=\+([^=]) flags=m<span class="tooltip">Id: builtin.arith.add</span></td></tr><tr><td colspan="3"><hr class="ruler"/></td></tr><tr><td class="mutationLabel" width="5%">3 :</td><td class="mutationText" width="87%"><span class="addedLine">+ return a <span class="changedTokens">/ </span>x * x + b * x + c;</span></td><td class="match">RegExp: pattern=\*([^=]) flags=m<span class="tooltip">Id: builtin.arith.mul</span></td></tr><tr><td colspan="3"><hr class="ruler"/></td></tr><tr><td class="mutationLabel" width="5%">4 :</td><td class="mutationText" width="87%"><span class="addedLine">+ return a * x <span class="changedTokens">/ </span>x + b * x + c;</span></td><td class="match">RegExp: pattern=\*([^=]) flags=m<span class="tooltip">Id: builtin.arith.mul</span></td></tr><tr><td colspan="3"><hr class="ruler"/></td></tr><tr><td class="mutationLabel" width="5%">5 :</td><td class="mutationText" width="87%"><span class="addedLine">+ return a * x * x + b <span class="changedTokens">/ </span>x + c;</span></td><td class="match">RegExp: pattern=\*([^=]) flags=m<span class="tooltip">Id: builtin.arith.mul</span></td></tr></table>

Expand Down Expand Up @@ -506,7 +506,7 @@
}
</script><table width ="100%" cellspacing="0" border="0">
<tr><td><hr class="ruler"/></td></tr>
<tr><td class="footer">Generated by mutation-test version: 1.6.0</td></tr>
<tr><td class="footer">Generated by mutation-test version: 1.6.1</td></tr>
</table>
</body>
</html>
Expand Down
94 changes: 73 additions & 21 deletions doc/output/example/source2.dart.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions doc/output/example/source3.dart.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@

<tr>
<td class="ItemLabel" width="10%">Date:</td>
<td class="ItemText" width="35%">2023-10-25 20:12:26.293830</td>
<td class="ItemText" width="35%">2024-03-24 15:27:37.231554</td>
<td class="ItemLabel" width="10%">Mutations:</td>
<td class="ItemReport" width="15%">0</td>
<td class="ItemReport" width="15%">0</td>
Expand Down Expand Up @@ -407,7 +407,7 @@
}
</script><table width ="100%" cellspacing="0" border="0">
<tr><td><hr class="ruler"/></td></tr>
<tr><td class="footer">Generated by mutation-test version: 1.6.0</td></tr>
<tr><td class="footer">Generated by mutation-test version: 1.6.1</td></tr>
</table>
</body>
</html>
28 changes: 14 additions & 14 deletions doc/output/mutation-test-report.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,20 @@

<tr>
<td class="ItemLabel" width="10%">Date:</td>
<td class="ItemText" width="35%">2023-10-25 20:12:26.292830</td>
<td class="ItemText" width="35%">2024-03-24 15:27:37.229545</td>
<td class="ItemLabel" width="10%">Mutations:</td>
<td class="ItemReport" width="15%">23</td>
<td class="ItemReport" width="15%">79</td>
<td class="ItemReportLow" width="15%">29.1 %</td>
<td class="ItemReport" width="15%">24</td>
<td class="ItemReport" width="15%">98</td>
<td class="ItemReportLow" width="15%">24.5 %</td>
</tr>

<tr>
<td class="ItemLabel" width="10%">Builtin rules:</td>
<td class="ItemText" width="35%">true</td>
<td class="ItemLabel" width="10%">Blocked:</td>
<td class="ItemReport" width="15%">21</td>
<td class="ItemReport" width="15%">79</td>
<td class="ItemReportMedium" width="15%">26.6 %</td>
<td class="ItemReport" width="15%">0</td>
<td class="ItemReport" width="15%">98</td>
<td class="ItemReportHigh" width="15%">0.0 %</td>
</tr>
<tr>
<td class="ItemLabel" width="10%">Quality rating:</td>
Expand Down Expand Up @@ -395,18 +395,18 @@
</td>
<td class="ItemReportMedium" width="10%">52.4 %</td>
<td class="ItemReportMedium" width="10%">22 / 42</td>
<td class="ItemReportHigh" width="10%">5 / 42</td>
<td class="ItemReportHigh" width="10%">0 / 42</td>
</tr>
<tr><td class="FileLink" width="60%"><a href="example/source2.dart.html">example/source2.dart</a></td>
<td class="ItemReport" width="10%">
<table width="100%" cellpadding="0" border="1"><tr>
<td class="barLo" width="2.7027027027027026%" height="10"></td>
<td class="barBg" width="97.29729729729729%" height="10"></td>
<td class="barLo" width="3.5714285714285716%" height="10"></td>
<td class="barBg" width="96.42857142857143%" height="10"></td>
</tr></table>
</td>
<td class="ItemReportLow" width="10%">2.7 %</td>
<td class="ItemReportLow" width="10%">1 / 37</td>
<td class="ItemReportMedium" width="10%">16 / 37</td>
<td class="ItemReportLow" width="10%">3.6 %</td>
<td class="ItemReportLow" width="10%">2 / 56</td>
<td class="ItemReportHigh" width="10%">0 / 56</td>
</tr>
<tr><td class="FileLink" width="60%"><a href="example/source3.dart.html">example/source3.dart</a></td>
<td class="ItemReport" width="10%">
Expand All @@ -426,7 +426,7 @@

<table width ="100%" cellspacing="0" border="0">
<tr><td><hr class="ruler"/></td></tr>
<tr><td class="footer">Generated by mutation-test version: 1.6.0</td></tr>
<tr><td class="footer">Generated by mutation-test version: 1.6.1</td></tr>
</table>
</body>
</html>
2 changes: 1 addition & 1 deletion example/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- lines can be whitelisted -->
<!-- if there is no whitelist, the whole file is used -->
<!-- line index starts at 1 -->
<lines begin="9" end="33"/>
<lines begin="9" end="60"/>
</file>
<file>example/source3.dart</file>
</files>
Expand Down
48 changes: 0 additions & 48 deletions example/lcov.info

This file was deleted.

11 changes: 11 additions & 0 deletions example/source2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,15 @@ class TestData {
on = true;
}
}

List<double> values = [];
void fillList(double x) {
values = [x, calc(x), calc(number1)];
}

double voidCalls(double x) {
fillList(x);
format(x);
return x;
}
}
11 changes: 11 additions & 0 deletions lib/src/configuration/builtin_rules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ String _xmlRules() {
<regex pattern="break;(\s+)case" id="builtin.switch.break">
<mutation text="$1case"/>
</regex>
<!-- Removes entries in a list in dart -->
<regex pattern="([=:>]\s*)\[([^\],]+),([^\]]+)\]" id="builtin.list.clear">
<mutation text="$1[]"/>
</regex>
<!-- Removes function calls that are not returned or assigned to a value -->
<regex pattern="([{]\s*)([^\(;=\s}]+\([^;]+\)\s*;)" id="builtin.function.removeVoidCall1">
<mutation text="$1"/>
</regex>
<regex pattern="([};]\s*)([^\(;=\s}]+\([^;]+\)\s*;)" id="builtin.function.removeVoidCall2">
<mutation text="$1"/>
</regex>
</rules>
<!-- This element creates a blacklist, allowing you to exclude parts from the mutations -->
<exclude>
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

/// Returns the version of this library.
String mutationTestVersion() {
return 'mutation-test version: 1.6.0';
return 'mutation-test version: 1.6.1';
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mutation_test
description: A command line application to measure the quality of your test cases by mutating your code and checking if your tests detect the changes.
version: 1.6.0
version: 1.6.1
homepage: https://domohuhn.github.io/mutation-test/
repository: https://github.com/domohuhn/mutation-test
issue_tracker: https://github.com/domohuhn/mutation-test/issues
Expand Down
4 changes: 2 additions & 2 deletions test/configuration/parse_xml_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() {
final configuration = Configuration(mock, true);
configuration.parseXMLString(builtinMutationRules());
expect(configuration.exclusions.length, 10);
expect(configuration.mutations.length, 29);
expect(configuration.mutations.length, 32);
expect(configuration.files.length, 0);
expect(configuration.commands.length, 0);
});
Expand All @@ -23,7 +23,7 @@ void main() {
final configuration = Configuration(mock, true);
configuration.parseXMLString(fullXMLFile());
expect(configuration.exclusions.length, 10);
expect(configuration.mutations.length, 29);
expect(configuration.mutations.length, 32);
expect(configuration.files.length, 2);
expect(configuration.commands.length, 2);
configuration.validate();
Expand Down
2 changes: 1 addition & 1 deletion test/core/system_interactions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void main() {
test('list directory', () {
var sys = SystemInteractions(true, false);
final list = sys.listDirectoryContents(dir, false, []);
expect(list.length, 10);
expect(list.length, 9);
});

test('list directory with pattern', () {
Expand Down
9 changes: 9 additions & 0 deletions test/example2_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ void main() {
test('TestData format 3', () {
expect(data.format(2.0), 'default 2.0');
});

test('TestData list', () {
data.fillList(2.0);
expect(data.values.length, 3);
});

test('TestData voidCalls', () {
expect(data.voidCalls(2.0), 2.0);
});
}

0 comments on commit addf9f2

Please sign in to comment.