Skip to content

Commit 81c5980

Browse files
authored
Fix/unary (#123)
* fix: unary operator swapped too much * chore: bump lock file * fix: tests
1 parent 46f8fb5 commit 81c5980

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

move-mutator/src/operators/unary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl MutationOperator for Unary {
4646
let start = source[start..]
4747
.find(|c: char| !c.is_whitespace())
4848
.map_or(start, |i| start + i);
49-
let end = self.loc.span().end().to_usize();
49+
let end = start + 1;
5050
let cur_op = &source[start..end];
5151

5252
// For unary operator mutations, we only need to replace the operator with a space (to ensure the same file length).

move-mutator/tests/move-assets/same_names/report.txt.spec-exp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"killed": 1,
88
"mutants_alive_diffs": [],
99
"mutants_killed_diff": [
10-
"--- original\n+++ modified\n@@ -1,6 +1,6 @@\n module TestAccount::Negation_main {\n fun neg_log(x: bool): bool {\n- !x\n+ \n }\n\n spec neg_log {\n"
10+
"--- original\n+++ modified\n@@ -1,6 +1,6 @@\n module TestAccount::Negation_main {\n fun neg_log(x: bool): bool {\n- !x\n+ x\n }\n\n spec neg_log {\n"
1111
]
1212
}
1313
],
@@ -18,7 +18,7 @@
1818
"killed": 1,
1919
"mutants_alive_diffs": [],
2020
"mutants_killed_diff": [
21-
"--- original\n+++ modified\n@@ -1,6 +1,6 @@\n module TestAccount::Negation_m1 {\n fun neg_log(x: bool): bool {\n- !x\n+ \n }\n\n spec neg_log {\n"
21+
"--- original\n+++ modified\n@@ -1,6 +1,6 @@\n module TestAccount::Negation_m1 {\n fun neg_log(x: bool): bool {\n- !x\n+ x\n }\n\n spec neg_log {\n"
2222
]
2323
}
2424
],
@@ -29,7 +29,7 @@
2929
"killed": 1,
3030
"mutants_alive_diffs": [],
3131
"mutants_killed_diff": [
32-
"--- original\n+++ modified\n@@ -1,6 +1,6 @@\n module TestAccount::Negation_m1_1 {\n fun neg_log(x: bool): bool {\n- !x\n+ \n }\n\n spec neg_log {\n"
32+
"--- original\n+++ modified\n@@ -1,6 +1,6 @@\n module TestAccount::Negation_m1_1 {\n fun neg_log(x: bool): bool {\n- !x\n+ x\n }\n\n spec neg_log {\n"
3333
]
3434
}
3535
],
@@ -40,10 +40,10 @@
4040
"killed": 1,
4141
"mutants_alive_diffs": [],
4242
"mutants_killed_diff": [
43-
"--- original\n+++ modified\n@@ -1,6 +1,6 @@\n module TestAccount::Negation_m2 {\n fun neg_log(x: bool): bool {\n- !x\n+ \n }\n\n spec neg_log {\n"
43+
"--- original\n+++ modified\n@@ -1,6 +1,6 @@\n module TestAccount::Negation_m2 {\n fun neg_log(x: bool): bool {\n- !x\n+ x\n }\n\n spec neg_log {\n"
4444
]
4545
}
4646
]
4747
},
4848
"package_dir": "/Users/karlomardesic/Workspace/move-spec-testing/move-mutator/tests/move-assets/same_names"
49-
}
49+
}

move-mutator/tests/move-assets/simple/report.txt.mutation-exp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@
130130
]
131131
}
132132
],
133+
"sources/Negation.move": [
134+
{
135+
"module_func": "Negation::neg_log",
136+
"tested": 1,
137+
"killed": 1,
138+
"mutants_alive_diffs": [],
139+
"mutants_killed_diff": [
140+
"--- original\n+++ modified\n@@ -1,6 +1,6 @@\n module TestAccount::Negation {\n fun neg_log(x: bool): bool {\n- !x\n+ x\n }\n\n #[test]\n"
141+
]
142+
}
143+
],
133144
"sources/Operators.move": [
134145
{
135146
"module_func": "Operators::div",
@@ -231,6 +242,15 @@
231242
"--- original\n+++ modified\n@@ -219,7 +219,7 @@\n }\n\n fun logical_and(x: bool, y: bool): bool {\n- x && y\n+ x || y\n }\n\n #[test]\n"
232243
]
233244
},
245+
{
246+
"module_func": "Operators::logical_not",
247+
"tested": 1,
248+
"killed": 1,
249+
"mutants_alive_diffs": [],
250+
"mutants_killed_diff": [
251+
"--- original\n+++ modified\n@@ -231,7 +231,7 @@\n }\n\n fun logical_not(x: bool): bool {\n- !x\n+ x\n }\n\n #[test]\n"
252+
]
253+
},
234254
{
235255
"module_func": "Operators::logical_or",
236256
"tested": 2,
@@ -568,5 +588,5 @@
568588
}
569589
]
570590
},
571-
"package_dir": "/home/jos/Projects/move-mutation-tools/move-mutator/tests/move-assets/simple"
591+
"package_dir": "/Users/jos/Projects/move-mutation-tools/move-mutator/tests/move-assets/simple"
572592
}

0 commit comments

Comments
 (0)