diff --git a/corpus/python/bin-op-eq/2ece1bc50c50.mutation.json b/corpus/python/bin-op-eq/2ece1bc50c50.mutation.json new file mode 100644 index 00000000..85ee1ac6 --- /dev/null +++ b/corpus/python/bin-op-eq/2ece1bc50c50.mutation.json @@ -0,0 +1,36 @@ +{ + "mutant": { + "lang": "py", + "twig": [ + "src/a.py" + ], + "kind": { + "BinaryOp": "Eq" + }, + "subst_span": { + "start": { + "line": 2, + "col": 6, + "byte": 18 + }, + "end": { + "line": 2, + "col": 8, + "byte": 20 + } + }, + "effect_span": { + "start": { + "line": 2, + "col": 4, + "byte": 16 + }, + "end": { + "line": 2, + "col": 10, + "byte": 22 + } + } + }, + "subst": "!=" +} \ No newline at end of file diff --git a/corpus/python/bin-op-eq/2ece1bc50c50.py b/corpus/python/bin-op-eq/2ece1bc50c50.py new file mode 100644 index 00000000..aeb9f06d --- /dev/null +++ b/corpus/python/bin-op-eq/2ece1bc50c50.py @@ -0,0 +1,3 @@ +a = 1 +b = 2 +x = a != b diff --git a/crates/bough-core/src/language/python.rs b/crates/bough-core/src/language/python.rs index 31f9f02e..92563ad5 100644 --- a/crates/bough-core/src/language/python.rs +++ b/crates/bough-core/src/language/python.rs @@ -33,6 +33,15 @@ impl LanguageDriver for PythonDriver { }; Some((MutantKind::BinaryOp(kind), span_from_node(&op_node), span_from_node(node))) } + "comparison_operator" => { + let op_node = node.child_by_field_name("operators")?; + let op_text = op_node.utf8_text(file_content).ok()?; + let kind = match op_text { + "==" => BinaryOpMutationKind::Eq, + _ => return None, + }; + Some((MutantKind::BinaryOp(kind), span_from_node(&op_node), span_from_node(node))) + } "boolean_operator" => { let op_node = node.child_by_field_name("operator")?; let op_text = op_node.utf8_text(file_content).ok()?; @@ -65,6 +74,7 @@ impl LanguageDriver for PythonDriver { MutantKind::BinaryOp(BinaryOpMutationKind::Shr) => vec!["<<".into()], MutantKind::BinaryOp(BinaryOpMutationKind::And) => vec!["or".into()], MutantKind::BinaryOp(BinaryOpMutationKind::Or) => vec!["and".into()], + MutantKind::BinaryOp(BinaryOpMutationKind::Eq) => vec!["!=".into()], _ => vec![], } } @@ -102,6 +112,6 @@ mod tests { #[test] #[ignore] fn debug_tree() { - dump_tree("a = True\nb = False\nx = a and b"); + dump_tree("a = 1\nb = 2\nx = a == b\ny = a is not None\nz = 1 in [1,2]"); } }