-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutation_config.xml
151 lines (145 loc) · 6.46 KB
/
mutation_config.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?xml version="1.0" encoding="UTF-8"?>
<mutations version="1.0">
<!-- The rules element describes all mutations done during a mutation test -->
<!-- The following children are parsed: literal and regex -->
<!-- A literal element matches the literal text -->
<!-- A regex element mutates source code if the regular expression matches -->
<!-- Each of them must have at least one mutation child -->
<rules>
<!-- A literal element matches the literal text and replaces it with the list of mutations -->
<literal text="&&">
<mutation text="||"/>
</literal>
<literal text="||">
<mutation text="&&"/>
</literal>
<literal text="+">
<mutation text="-"/>
<mutation text="*"/>
</literal>
<literal text="-">
<mutation text="+"/>
<mutation text="*"/>
</literal>
<literal text="*">
<mutation text="+"/>
<mutation text="-"/>
</literal>
<literal text="/">
<mutation text="*"/>
<mutation text="+"/>
</literal>
<literal text="==">
<mutation text="!="/>
</literal>
<literal text="<=">
<mutation text="=="/>
<mutation text="<"/>
</literal>
<literal text=">=">
<mutation text="=="/>
<mutation text=">"/>
</literal>
<literal text="!=">
<mutation text="=="/>
</literal>
<!-- It is also possible to match a regular expression with capture groups. -->
<!-- If the optional attribute dotAll is set to true, then the . will also match newlines. -->
<!-- If not present, the default value for dotAll is false. -->
<!-- Here, we capture everything inside of the braces of "if ()" -->
<regex pattern="[\s]if[\s]*\((.*?)\)[\s]*{" dotAll="true">
<!-- You can access groups via $1. -->
<!-- If your string contains a $ followed by a number that should not be replaced, escape the dollar \$ -->
<!-- If your string contains a \$ followed by a number that should not be replaced, escape the slash \\$ -->
<!-- Tabs and newlines should also be escaped. -->
<mutation text=" if (!($1)) {"/>
</regex>
<!-- Matches long chains of && -->
<regex pattern="&([^&()]+?)&" dotAll="true">
<mutation text="&!($1)&"/>
</regex>
<!-- Matches long chains of || -->
<regex pattern="\|([^|()]+?)\|" dotAll="true">
<mutation text="|!($1)|"/>
</regex>
<regex pattern="\(([^$(]*?)&&([^$()]*?)\)">
<mutation text="(!($1)&&$2)"/>
<mutation text="($1&&!($2))"/>
</regex>
<regex pattern="\(([^|(]*?)\|\|([^()|]*?)\)">
<mutation text="(!($1)||$2)"/>
<mutation text="($1||!($2))"/>
</regex>
<!-- Replace start of conditional block -->
<regex pattern="if\s*\(([^|&\)]*?)([|&][|&])">
<mutation text="if (!($1)$2"/>
</regex>
<!-- Replace end of conditional block -->
<regex pattern="([|&][|&])([^|&]*?)\)">
<mutation text="$1!($2))"/>
</regex>
<regex pattern="([|&][|&])[\s]*?\(" dotAll="true">
<mutation text="$1!("/>
</regex>
<!-- Replaces numbers with negative values -->
<regex pattern="([\s=\(])([1-9\.]+[0-9]+|0\.0*[1-9])">
<mutation text="$1-$2"/>
</regex>
<!-- switch function call arguments. Matches 2 args -->
<regex pattern="([\s][a-zA-z]*?[^\(;\s]*?)\s*\(([^,]*),([^,]*)\)\s*;">
<mutation text="$1($3,$2);"/>
</regex>
<!-- switch function call arguments. Matches 3 args -->
<regex pattern="([\s][a-zA-z]*?[^\(;\s{}]*?)\s*\(([^,\n\(]*),([^,\n\(]*),([^,\n\(]*)\)\s*;">
<mutation text="$1($3,$2,$4);"/>
<mutation text="$1($2,$4,$3);"/>
</regex>
<!-- switch function call arguments. Matches 4 args -->
<regex pattern="([\s][a-zA-z]*?[^\(;\s{}]*?)\s*\(([^,\n\(]*),([^,\n\(]*),([^,\n\(]*),([^,\n\(]*)\)\s*;">
<mutation text="$1($3,$2,$4,$5);"/>
<mutation text="$1($2,$4,$3,$5);"/>
<mutation text="$1($2,$3,$5,$4);"/>
</regex>
</rules>
<!-- This element creates a blacklist, allowing you to exclude parts from the mutations -->
<exclude>
<!-- excludes anything between two tokens -->
<!-- single line comments -->
<token begin="//" end="\n"/>
<!-- exclude dart exports and imports -->
<token begin="export '" end="';"/>
<token begin="import '" end="';"/>
<token begin="export "" end="";"/>
<token begin="import "" end="";"/>
<!-- exclude dart part and part of -->
<token begin="part '" end="';"/>
<token begin="part of '" end="';"/>
<token begin="part "" end="";"/>
<token begin="part of "" end="";"/>
<!-- excludes anything that matches a pattern -->
<!-- multi line comments -->
<regex pattern="/[*].*?[*]/" dotAll="true"/>
<!-- exclude increment and decrement operators. Produces mostly false positives. -->
<regex pattern="\+\+"/>
<regex pattern="--"/>
<!-- exclude loops to prevent infinte tests -->
<regex pattern="[\s]for[\s]*\(.*?\)[\s]*{" dotAll="true"/>
<regex pattern="[\s]while[\s]*\(.*?\)[\s]*{.*?}" dotAll="true"/>
<!-- lines can also be globally excluded -->
<!-- line index starts at 1 -->
<!-- lines begin="1" end="2"/-->
</exclude>
<!-- Configures the reporting thresholds as percentage of detected mutations -->
<!-- Attribute failure is required and must be a floating point number. -->
<!-- Note: There can only be one threshold element in all input files! -->
<!-- If no threshold element is found, these values will be used. -->
<threshold failure="80">
<!-- Provides reliability rating levels. Attributes are required. -->
<rating over="100" name="A"/>
<rating over="80" name="B"/>
<rating over="60" name="C"/>
<rating over="40" name="D"/>
<rating over="20" name="E"/>
<rating over="0" name="F"/>
</threshold>
</mutations>