From 45db4e9e57e7a33ce0a0bdb99402724773e44687 Mon Sep 17 00:00:00 2001 From: John Backus Date: Mon, 30 Jan 2017 16:14:25 -0800 Subject: [PATCH] Fix #ignore? for nodes without a location This is true for our custom nodes like the regexp nodes --- Gemfile.lock | 2 +- config/flay.yml | 2 +- lib/mutest/source_file.rb | 2 +- spec/unit/mutest/source_file_spec.rb | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4eb7a0e5..7859cbc4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,7 +35,7 @@ GIT PATH remote: . specs: - mutest (0.8.12) + mutest (0.0.2) abstract_type (~> 0.0.7) adamantium (~> 0.2.0) anima (~> 0.3.0) diff --git a/config/flay.yml b/config/flay.yml index 16c0d2eb..dd660e15 100644 --- a/config/flay.yml +++ b/config/flay.yml @@ -1,3 +1,3 @@ --- threshold: 16 -total_score: 1325 +total_score: 1329 diff --git a/lib/mutest/source_file.rb b/lib/mutest/source_file.rb index 2a171948..31a94bd5 100644 --- a/lib/mutest/source_file.rb +++ b/lib/mutest/source_file.rb @@ -22,7 +22,7 @@ def initialize(path, ast, comments) # TODO: Support inline comment disable def ignore?(node) location = node.location - return false unless location.expression + return false unless location && location.expression disable_lines.include?(location.line) end diff --git a/spec/unit/mutest/source_file_spec.rb b/spec/unit/mutest/source_file_spec.rb index dc0a39f7..331f27b1 100644 --- a/spec/unit/mutest/source_file_spec.rb +++ b/spec/unit/mutest/source_file_spec.rb @@ -33,10 +33,14 @@ def bar end end - it 'ignores nodes that do not have a location' do + it 'ignores nodes that do not have a line' do _, bar_method = *ast _, bar_method_args, = *bar_method expect(source_file.ignore?(bar_method_args)).to be(false) end + + it 'ignores nodes that do not have a location' do + expect(source_file.ignore?(s(:custom))).to be(false) + end end