Fix Expression::Method#match_length

This commit is contained in:
Markus Schirp 2014-10-08 14:56:46 +00:00
parent 593a6ef9a0
commit 58582a3a09
2 changed files with 23 additions and 1 deletions

View file

@ -25,6 +25,22 @@ module Mutant
MATCHERS.fetch(scope_symbol).new(env, scope) MATCHERS.fetch(scope_symbol).new(env, scope)
end end
# Return length of match
#
# @param [Expression] expression
#
# @return [Fixnum]
#
# @api private
#
def match_length(expression)
if expression.syntax.start_with?(syntax)
syntax.length
else
0
end
end
private private
# Return scope name # Return scope name

View file

@ -16,7 +16,13 @@ RSpec.describe Mutant::Expression::Methods do
it { should be(object.syntax.length) } it { should be(object.syntax.length) }
end end
context 'when other is an unequivalent expression' do context 'when other is matched' do
let(:other) { described_class.parse('TestApp::Literal#foo') }
it { should be(object.syntax.length) }
end
context 'when other is an not matched expression' do
let(:other) { described_class.parse('Foo*') } let(:other) { described_class.parse('Foo*') }
it { should be(0) } it { should be(0) }