diff --git a/lib/mutant/mutator/node/define.rb b/lib/mutant/mutator/node/define.rb index 64350181a..5e18d2143 100644 --- a/lib/mutant/mutator/node/define.rb +++ b/lib/mutant/mutator/node/define.rb @@ -14,6 +14,7 @@ def dispatch emit_optarg_body_assignments emit_restarg_body_mutation emit_body(N_RAISE) + emit_body(N_ZSUPER) emit_body(nil) emit_body_mutations if body end diff --git a/meta/def.rb b/meta/def.rb index 14f2fe3a9..b51689cec 100644 --- a/meta/def.rb +++ b/meta/def.rb @@ -2,6 +2,7 @@ source 'def foo; end' mutation 'def foo; raise; end' + mutation 'def foo; super; end' end Mutant::Meta::Example.add :def do @@ -14,6 +15,7 @@ mutation 'def foo(a); nil; end' mutation 'def foo(*b); nil; end' mutation 'def foo(a, *b); b = []; nil; end' + mutation 'def foo(a, *b); super; end' end Mutant::Meta::Example.add :def do @@ -25,6 +27,7 @@ mutation 'def foo(a, *); raise; end' mutation 'def foo(a); nil; end' mutation 'def foo(*); nil; end' + mutation 'def foo(a, *); super; end' end Mutant::Meta::Example.add :def do @@ -34,6 +37,7 @@ mutation 'def foo; nil; rescue; end' mutation 'def foo; self; rescue; end' mutation 'def foo; end' + mutation 'def foo; super; end' # Promote rescue resbody bodies mutation 'def foo; foo; end' @@ -65,6 +69,8 @@ # Failing body mutation 'def a; raise; end' + # Superclass implementation + mutation 'def a; super; end' end Mutant::Meta::Example.add :def do @@ -85,6 +91,7 @@ mutation 'def foo; raise; end' + mutation 'def foo; super; end' end Mutant::Meta::Example.add :def do @@ -103,7 +110,7 @@ # Mutation of body mutation 'def foo(a, b); raise; end' - + mutation 'def foo(a, b); super; end' end Mutant::Meta::Example.add :def do @@ -120,6 +127,7 @@ mutation 'def foo(b = nil); true; end' mutation 'def foo(a, _b = nil); true; end' mutation 'def foo(a, b); true; end' + mutation 'def foo(a, b = nil); super; end' end Mutant::Meta::Example.add :def do @@ -127,6 +135,7 @@ mutation 'def foo(_unused); raise; end' mutation 'def foo; end' + mutation 'def foo(_unused); super; end' end Mutant::Meta::Example.add :def do @@ -137,6 +146,7 @@ mutation 'def foo(_unused = true); raise; end' mutation 'def foo(_unused); end' mutation 'def foo; end' + mutation 'def foo(_unused = true); super; end' end Mutant::Meta::Example.add :def do @@ -158,6 +168,7 @@ mutation 'def foo(a = 0, b = 0); a = 0; end' mutation 'def foo(a = 0, b = 0); b = 0; end' mutation 'def foo(a = 0, b = 0); raise; end' + mutation 'def foo(a = 0, b = 0); super; end' end Mutant::Meta::Example.add :def do @@ -170,6 +181,7 @@ mutation 'def foo(_a = true); end' mutation 'def foo(a = true); raise; end' mutation 'def foo(a = true); a = true; end' + mutation 'def foo(a = true); super; end' end Mutant::Meta::Example.add :def do @@ -189,6 +201,8 @@ mutation 'def self.foo; end' mutation 'def self.foo; raise; end' + + mutation 'def self.foo; super; end' end Mutant::Meta::Example.add :def do @@ -208,4 +222,5 @@ # Mutation of body mutation 'def self.foo(a, b); raise; end' + mutation 'def self.foo(a, b); super; end' end diff --git a/meta/kwarg.rb b/meta/kwarg.rb index 13c27d38f..78784e510 100644 --- a/meta/kwarg.rb +++ b/meta/kwarg.rb @@ -3,5 +3,6 @@ mutation 'def foo; end' mutation 'def foo(bar:); raise; end' + mutation 'def foo(bar:); super; end' mutation 'def foo(_bar:); end' end diff --git a/meta/kwoptarg.rb b/meta/kwoptarg.rb index dbe7d04e5..695c20aff 100644 --- a/meta/kwoptarg.rb +++ b/meta/kwoptarg.rb @@ -3,6 +3,7 @@ mutation 'def foo; end' mutation 'def foo(bar: baz); raise; end' + mutation 'def foo(bar: baz); super; end' mutation 'def foo(bar: nil); end' mutation 'def foo(bar: self); end' mutation 'def foo(bar:); end' diff --git a/meta/rescue.rb b/meta/rescue.rb index bbd5240b5..a5da4b7be 100644 --- a/meta/rescue.rb +++ b/meta/rescue.rb @@ -74,6 +74,9 @@ # Failing body mutation 'def a; raise; end' + + # Superclass implementation + mutation 'def a; super; end' end Mutant::Meta::Example.add :rescue do diff --git a/meta/restarg.rb b/meta/restarg.rb index fae77a092..7eb608ca7 100644 --- a/meta/restarg.rb +++ b/meta/restarg.rb @@ -4,4 +4,5 @@ mutation 'def foo; end' mutation 'def foo(*bar); bar = []; end' mutation 'def foo(*bar); raise; end' + mutation 'def foo(*bar); super; end' end diff --git a/spec/unit/mutant/subject/method/instance_spec.rb b/spec/unit/mutant/subject/method/instance_spec.rb index 23fb1ef89..441c291b8 100644 --- a/spec/unit/mutant/subject/method/instance_spec.rb +++ b/spec/unit/mutant/subject/method/instance_spec.rb @@ -116,6 +116,11 @@ def foo; end s(:begin, s(:def, :foo, s(:args), s(:send, nil, :raise)), s(:send, nil, :memoize, s(:args, s(:sym, :foo)))) ), + Mutant::Mutation::Evil.new( + object, + s(:begin, + s(:def, :foo, s(:args), s(:zsuper)), s(:send, nil, :memoize, s(:args, s(:sym, :foo)))) + ), Mutant::Mutation::Evil.new( object, s(:begin,