Merge pull request #761 from mbj/fix/recursive-prefix-length

Fix prefix check for equivalent recursive namespaces
This commit is contained in:
Markus Schirp 2018-11-16 15:50:56 +00:00 committed by GitHub
commit 9e504b688e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -44,7 +44,9 @@ module Mutant
#
# @return [Integer]
def match_length(expression)
if @recursion_pattern.match?(expression.syntax)
if eql?(expression)
syntax.length
elsif @recursion_pattern.match?(expression.syntax)
scope_name.length
else
0

View file

@ -22,7 +22,7 @@ RSpec.describe Mutant::Expression::Namespace::Recursive do
context 'when other is an equivalent expression' do
let(:other) { parse_expression(object.syntax) }
it { should be(0) }
it { should be(object.syntax.length) }
end
context 'when other expression describes a shorter prefix' do