Fix Mutant::Expression#inspect to be more usable
This commit is contained in:
parent
2ad980dbe5
commit
e8f09b988d
3 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 18
|
||||
total_score: 1040
|
||||
total_score: 1043
|
||||
|
|
|
@ -13,6 +13,8 @@ module Mutant
|
|||
*AST::Types::OPERATOR_METHODS.map(&:to_s)
|
||||
).freeze
|
||||
|
||||
INSPECT_FORMAT = '<Mutant::Expression: %s>'.freeze
|
||||
|
||||
SCOPE_PATTERN = /#{SCOPE_NAME_PATTERN}(?:#{SCOPE_OPERATOR}#{SCOPE_NAME_PATTERN})*/.freeze
|
||||
|
||||
REGISTRY = {}
|
||||
|
@ -32,8 +34,17 @@ module Mutant
|
|||
def initialize(*)
|
||||
super
|
||||
@syntax = match.to_s
|
||||
@inspect = format(INSPECT_FORMAT, syntax)
|
||||
end
|
||||
|
||||
# Return inspection
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :inspect
|
||||
|
||||
# Return syntax
|
||||
#
|
||||
# @return [String]
|
||||
|
|
|
@ -35,6 +35,14 @@ describe Mutant::Expression do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#inspect' do
|
||||
let(:object) { described_class.parse('Foo') }
|
||||
subject { object.inspect }
|
||||
|
||||
it { should eql('<Mutant::Expression: Foo>') }
|
||||
it_should_behave_like 'an idempotent method'
|
||||
end
|
||||
|
||||
describe '.parse' do
|
||||
subject { object.parse(input) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue