From 97599aaad0dcc7cd745cc5445e3b21d200a2d699 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Mon, 24 Dec 2018 09:19:32 +0000 Subject: [PATCH] Fix emit of naked splat [Fix #724] --- lib/mutant/mutator/node/literal/array.rb | 4 +++- meta/lvasgn.rb | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/mutant/mutator/node/literal/array.rb b/lib/mutant/mutator/node/literal/array.rb index b18f71e4..18dcb391 100644 --- a/lib/mutant/mutator/node/literal/array.rb +++ b/lib/mutant/mutator/node/literal/array.rb @@ -9,6 +9,8 @@ module Mutant handle(:array) + children :first + private # Emit mutations @@ -19,7 +21,7 @@ module Mutant emit_type mutate_body return unless children.one? - emit(children.first) + emit(first) unless n_splat?(first) end # Mutate body diff --git a/meta/lvasgn.rb b/meta/lvasgn.rb index 1ba9e190..fb3e325c 100644 --- a/meta/lvasgn.rb +++ b/meta/lvasgn.rb @@ -8,3 +8,18 @@ Mutant::Meta::Example.add :lvasgn do mutation 'a = false' mutation 'a = nil' end + +Mutant::Meta::Example.add :array, :lvasgn do + source 'a = *b' + + singleton_mutations + mutation 'a__mutant__ = *b' + mutation 'a = nil' + mutation 'a = self' + mutation 'a = []' + mutation 'a = [nil]' + mutation 'a = [self]' + mutation 'a = [*self]' + mutation 'a = [*nil]' + mutation 'a = [b]' +end