From 4fba42a5db2fa6d15dcbc7c1325e314e55325b73 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Mon, 24 Dec 2018 00:50:19 +0000 Subject: [PATCH] Fix invalid block mutations on lambda [Fix #802] --- lib/mutant/mutator/node/block.rb | 2 +- meta/lambda.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/mutant/mutator/node/block.rb b/lib/mutant/mutator/node/block.rb index ae31e6aa..84cc6fe6 100644 --- a/lib/mutant/mutator/node/block.rb +++ b/lib/mutant/mutator/node/block.rb @@ -51,7 +51,7 @@ module Mutant # # @return [undefined] def mutate_body_receiver - return unless n_send?(body) + return if n_lambda?(send) || !n_send?(body) body_meta = AST::Meta::Send.new(body) diff --git a/meta/lambda.rb b/meta/lambda.rb index 99b518ad..b09c602f 100644 --- a/meta/lambda.rb +++ b/meta/lambda.rb @@ -7,3 +7,17 @@ Mutant::Meta::Example.add :block, :lambda do mutation '->() { raise }' end + +Mutant::Meta::Example.add :block, :lambda do + source '->() { foo.bar }' + + singleton_mutations + + mutation '->() { }' + mutation '->() { self }' + mutation '->() { nil }' + mutation '->() { raise }' + mutation '->() { self.bar }' + mutation '->() { foo }' + mutation 'foo.bar' +end