Prefer Kernel#fail over Kernel#raise

This commit is contained in:
Markus Schirp 2014-11-17 17:00:05 +00:00
parent 511702af4c
commit f3720a6366
5 changed files with 10 additions and 10 deletions

View file

@ -44,7 +44,7 @@ module Mutant
# @api private
#
def self.find_last_path(node, &predicate)
raise ArgumentError, 'block expected' unless block_given?
fail ArgumentError, 'block expected' unless block_given?
path = []
walk(node, [node]) do |candidate, stack|
if predicate.call(candidate, &predicate)

View file

@ -50,7 +50,7 @@ module Mutant
when ::Module
s(:module, name, node)
else
raise "Cannot wrap scope: #{scope.inspect}"
fail "Cannot wrap scope: #{scope.inspect}"
end
end

View file

@ -25,7 +25,7 @@ module Mutant
methods_matcher = MATCHERS.fetch(scope_symbol).new(env, scope)
method = methods_matcher.methods.detect do |meth|
meth.name.equal?(method_name)
end or raise NameError, "Cannot find method #{method_name}"
end or fail NameError, "Cannot find method #{method_name}"
methods_matcher.matcher.build(env, scope, method)
end

View file

@ -40,7 +40,7 @@ module Mutant
# @api private
#
def example
raise 'source not defined' unless @source
fail 'source not defined' unless @source
Example.new(@file, @source, @expected)
end
@ -55,7 +55,7 @@ module Mutant
# @api private
#
def source(input)
raise 'source already defined' if @source
fail 'source already defined' if @source
@source = node(input)
self
@ -72,7 +72,7 @@ module Mutant
def mutation(input)
node = node(input)
if @expected.include?(node)
raise "Node for input: #{input.inspect} is already expected"
fail "Node for input: #{input.inspect} is already expected"
end
@expected << node
@ -108,7 +108,7 @@ module Mutant
when Parser::AST::Node
input
else
raise "Cannot coerce to node: #{source.inspect}"
fail "Cannot coerce to node: #{source.inspect}"
end
end

View file

@ -39,7 +39,7 @@ module Mutant
def self.lookup(node)
type = node.type
registry.fetch(type) do
raise ArgumentError, "No mutator to handle: #{type.inspect}"
fail ArgumentError, "No mutator to handle: #{type.inspect}"
end
end
@ -67,7 +67,7 @@ module Mutant
#
def self.assert_valid_type(type)
unless AST::Types::ALL.include?(type) || type.is_a?(Class)
raise InvalidTypeError, "invalid type registration: #{type}"
fail InvalidTypeError, "invalid type registration: #{type}"
end
end
private_class_method :assert_valid_type
@ -83,7 +83,7 @@ module Mutant
#
def self.assert_unique_type(type)
if registry.key?(type)
raise DuplicateTypeError, "duplicate type registration: #{type}"
fail DuplicateTypeError, "duplicate type registration: #{type}"
end
end
private_class_method :assert_unique_type