Fix Expression::Method#match_length
This commit is contained in:
parent
593a6ef9a0
commit
58582a3a09
2 changed files with 23 additions and 1 deletions
|
@ -25,6 +25,22 @@ module Mutant
|
|||
MATCHERS.fetch(scope_symbol).new(env, scope)
|
||||
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
|
||||
|
||||
# Return scope name
|
||||
|
|
|
@ -16,7 +16,13 @@ RSpec.describe Mutant::Expression::Methods do
|
|||
it { should be(object.syntax.length) }
|
||||
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*') }
|
||||
|
||||
it { should be(0) }
|
||||
|
|
Loading…
Reference in a new issue