Fix naming of Expression.{try_,}_parse

* try_parse is now the one that does not raise
* parse is now the one that does rase
This commit is contained in:
Markus Schirp 2014-06-29 23:16:34 +00:00
parent 7b4652d8d7
commit 3390d59954
9 changed files with 13 additions and 17 deletions

View file

@ -108,11 +108,7 @@ module Mutant
def parse_matchers(patterns)
raise Error, 'No patterns given' if patterns.empty?
patterns.each do |pattern|
expression = Expression.parse(pattern)
unless expression
raise Error, "Invalid mutant expression: #{pattern.inspect}"
end
@builder.add_match_expression(expression)
@builder.add_match_expression(Expression.parse(pattern))
end
end

View file

@ -97,7 +97,7 @@ module Mutant
#
def match_expressions
name_nesting.each_index.reverse_each.map do |index|
Expression.parse_strict("#{name_nesting.take(index.succ).join(NAMESPACE_DELIMITER)}*")
Expression.parse("#{name_nesting.take(index.succ).join(NAMESPACE_DELIMITER)}*")
end
end
memoize :match_expressions

View file

@ -87,8 +87,8 @@ module Mutant
#
# @api private
#
def self.parse_strict(input)
parse(input) or raise "Expression: #{input.inspect} is not valid"
def self.parse(input)
try_parse(input) or raise "Expression: #{input.inspect} is not valid"
end
# Parse input into expression
@ -103,7 +103,7 @@ module Mutant
#
# @api private
#
def self.parse(input)
def self.try_parse(input)
expressions = expressions(input)
case expressions.length
when 0

View file

@ -48,7 +48,7 @@ module Mutant
#
def all_tests
example_group_index.keys.each_with_object([]) do |full_description, aggregate|
expression = Expression.parse(full_description) or next
expression = Expression.try_parse(full_description) or next
aggregate << Test.new(self, expression)
end

View file

@ -82,7 +82,7 @@ module Mutant
return
end
scope_expression = Expression.parse(name)
scope_expression = Expression.try_parse(name)
unless scope_expression
$stderr.puts("WARNING: #{name.inspect} is not an identifiable ruby class name.")

View file

@ -28,7 +28,7 @@ module Mutant
# @api private
#
def expression
Expression.parse_strict("#{context.identification}#{self.class::SYMBOL}#{name}")
Expression.parse("#{context.identification}#{self.class::SYMBOL}#{name}")
end
memoize :expression

View file

@ -80,7 +80,7 @@ describe Mutant::CLI, '.new' do
context 'with debug flag' do
let(:pattern) { 'TestApp*' }
let(:arguments) { %W[--debug #{pattern}] }
let(:expected_matcher) { ns::Namespace.new(cache, Mutant::Expression.parse_strict(pattern)) }
let(:expected_matcher) { ns::Namespace.new(cache, Mutant::Expression.parse(pattern)) }
it_should_behave_like 'a cli parser'
@ -92,7 +92,7 @@ describe Mutant::CLI, '.new' do
context 'with zombie flag' do
let(:pattern) { 'TestApp*' }
let(:arguments) { %W[--zombie #{pattern}] }
let(:expected_matcher) { ns::Namespace.new(cache, Mutant::Expression.parse_strict(pattern)) }
let(:expected_matcher) { ns::Namespace.new(cache, Mutant::Expression.parse(pattern)) }
it_should_behave_like 'a cli parser'
@ -104,7 +104,7 @@ describe Mutant::CLI, '.new' do
context 'with namespace pattern' do
let(:pattern) { 'TestApp*' }
let(:arguments) { [pattern] }
let(:expected_matcher) { ns::Namespace.new(cache, Mutant::Expression.parse_strict(pattern)) }
let(:expected_matcher) { ns::Namespace.new(cache, Mutant::Expression.parse(pattern)) }
it_should_behave_like 'a cli parser'
end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe Mutant::Expression::Namespace::Recursive do
let(:object) { described_class.parse_strict(input) }
let(:object) { described_class.parse(input) }
let(:cache) { Mutant::Cache.new }
let(:input) { 'TestApp::Literal*' }

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Mutant::Matcher::Namespace do
let(:object) { described_class.new(cache, Mutant::Expression.parse_strict('TestApp::Literal')) }
let(:object) { described_class.new(cache, Mutant::Expression.parse('TestApp::Literal')) }
let(:yields) { [] }
let(:cache) { Mutant::Cache.new }