Merge pull request #547 from mbj/enhancement/add-support-for-explicit-types-in-meta

Add support for explicit type in meta examples
This commit is contained in:
Dan Kubb 2016-03-20 14:49:04 -07:00
commit 00b8ab1e38
66 changed files with 186 additions and 182 deletions

View file

@ -1,3 +1,3 @@
---
threshold: 18
total_score: 1168
total_score: 1160

View file

@ -32,6 +32,7 @@ LongParameterList:
enabled: true
exclude:
- Mutant::Matcher::Method::Instance#self.build
- Mutant::Meta::Example::DSL # 3 vars
max_params: 2
LongYieldList:
enabled: true
@ -64,6 +65,7 @@ TooManyInstanceVariables:
exclude:
- Mutant::Mutator # 4 vars
- Mutant::Parallel::Master # 4 vars
- Mutant::Meta::Example::DSL # 4 vars
max_instance_variables: 3
TooManyMethods:
enabled: true

View file

@ -14,9 +14,9 @@ module Mutant
# Add example
#
# @return [undefined]
def self.add(&block)
def self.add(type, &block)
file = caller.first.split(':in', 2).first
ALL << DSL.call(file, block)
ALL << DSL.call(file, type, block)
end
Pathname.glob(Pathname.new(__dir__).parent.parent.join('meta', '*.rb'))

View file

@ -1,7 +1,7 @@
module Mutant
module Meta
class Example
include Adamantium, Concord::Public.new(:file, :node, :mutations)
include Adamantium, Anima.new(:file, :node, :node_type, :expected)
# Verification instance for example
#
@ -27,6 +27,7 @@ module Mutant
end
end
memoize :generated
end # Example
end # Meta
end # Mutant

View file

@ -8,8 +8,8 @@ module Mutant
# Run DSL on block
#
# @return [Example]
def self.call(file, block)
instance = new(file)
def self.call(file, type, block)
instance = new(file, type)
instance.instance_eval(&block)
instance.example
end
@ -19,9 +19,10 @@ module Mutant
# Initialize object
#
# @return [undefined]
def initialize(file)
def initialize(file, type)
@file = file
@source = nil
@type = type
@node = nil
@expected = []
end
@ -32,8 +33,13 @@ module Mutant
# @raise [RuntimeError]
# in case example cannot be build
def example
fail 'source not defined' unless @source
Example.new(@file, @source, @expected)
fail 'source not defined' unless @node
Example.new(
file: @file,
node: @node,
node_type: @type,
expected: @expected
)
end
private
@ -44,8 +50,8 @@ module Mutant
#
# @return [undefined]
def source(input)
fail 'source already defined' if @source
@source = node(input)
fail 'source already defined' if @node
@node = node(input)
end
# Add expected mutation

View file

@ -34,7 +34,7 @@ module Mutant
#
# @return [Array<Parser::AST::Node>]
def unexpected
mutations.map(&:node) - example.mutations
mutations.map(&:node) - example.expected
end
memoize :unexpected
@ -76,7 +76,7 @@ module Mutant
#
# @return [Array<Parser::AST::Node>]
def missing
example.mutations - mutations.map(&:node)
example.expected - mutations.map(&:node)
end
memoize :missing

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :and do
source 'true and false'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :and_asgn do
source 'a &&= 1'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :array do
source '[true]'
singleton_mutations
@ -8,7 +8,7 @@ Mutant::Meta::Example.add do
mutation '[]'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :array do
source '[true, false]'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :begin do
source 'true; false'
# Mutation of each statement in block
@ -12,7 +12,7 @@ Mutant::Meta::Example.add do
mutation 'false'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :begin do
source s(:begin, s(:true))
# Mutation of each statement in block

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :block do
source 'foo { a; b }'
singleton_mutations
@ -14,7 +14,7 @@ Mutant::Meta::Example.add do
mutation 'a; b'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :block do
source 'foo { |a, b| }'
singleton_mutations
@ -27,7 +27,7 @@ Mutant::Meta::Example.add do
mutation 'foo { || }'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :block do
source 'foo { |(a, b), c| }'
singleton_mutations
@ -44,7 +44,7 @@ Mutant::Meta::Example.add do
mutation 'foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :block do
source 'foo(a, b) {}'
singleton_mutations
@ -59,7 +59,7 @@ Mutant::Meta::Example.add do
mutation 'foo {}'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :block do
source 'foo { |(a)| }'
singleton_mutations
@ -70,7 +70,7 @@ Mutant::Meta::Example.add do
mutation 'foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :block do
source 'foo { bar(nil) }'
singleton_mutations
@ -84,7 +84,7 @@ Mutant::Meta::Example.add do
mutation 'bar(nil)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :block do
source 'foo { self << true }'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :block_pass do
source 'foo(&bar)'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :blockarg do
source 'foo { |&bar| }'
singleton_mutations

View file

@ -1,13 +0,0 @@
Mutant::Meta::Example.add do
source 'true'
mutation 'nil'
mutation 'false'
end
Mutant::Meta::Example.add do
source 'false'
mutation 'nil'
mutation 'true'
end

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :break do
source 'break true'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :case do
source <<-RUBY
case
when true
@ -29,7 +29,7 @@ Mutant::Meta::Example.add do
RUBY
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :case do
source <<-RUBY
case condition
when A

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :casgn do
source 'A = true'
mutation 'A__MUTANT__ = true'
@ -7,7 +7,7 @@ Mutant::Meta::Example.add do
mutation 'remove_const :A'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :casgn do
source 'self::A = true'
mutation 'self::A__MUTANT__ = true'

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :cbase do
source '::A'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :const do
source 'A::B::C'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :csend do
source 'a&.b'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :cvar do
source '@@a'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :cvasgn do
source '@@a = true'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'Date.parse(nil)'
singleton_mutations
@ -17,7 +17,7 @@ Mutant::Meta::Example.add do
mutation 'Date.jisx0301(nil)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source '::Date.parse(nil)'
singleton_mutations
@ -37,7 +37,7 @@ Mutant::Meta::Example.add do
mutation '::Date.jisx0301(nil)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'Date.iso8601(nil)'
singleton_mutations
@ -46,7 +46,7 @@ Mutant::Meta::Example.add do
mutation 'Date'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'Foo::Date.parse(nil)'
singleton_mutations

View file

@ -1,11 +1,11 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo; end'
mutation 'def foo; raise; end'
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo(a, *b); nil; end'
mutation 'def foo(_a, *b); nil; end'
@ -18,7 +18,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo(a, *); nil; end'
mutation 'def foo(_a, *); nil; end'
@ -30,7 +30,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo; foo; rescue; end'
mutation 'def foo; raise; end'
@ -43,7 +43,7 @@ Mutant::Meta::Example.add do
mutation 'def foo; foo; end'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def a; foo; rescue; bar; else; baz; end'
# Mutate all bodies
@ -72,7 +72,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :a'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo; true; false; end'
# Mutation of each statement in block
@ -93,7 +93,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo(a, b); end'
# Deletion of each argument
@ -113,7 +113,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo(a, b = nil); true; end'
mutation 'def foo(_a, b = nil); true; end'
@ -130,7 +130,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo(_unused); end'
mutation 'def foo(_unused); raise; end'
@ -138,7 +138,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo(_unused = true); end'
mutation 'def foo(_unused = nil); end'
@ -149,7 +149,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo(a = 0, b = 0); end'
mutation 'def foo(a = 0, _b = 0); end'
mutation 'def foo(_a = 0, b = 0); end'
@ -171,7 +171,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def foo(a = true); end'
mutation 'def foo(a); end'
@ -184,7 +184,7 @@ Mutant::Meta::Example.add do
mutation 'remove_method :foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def self.foo; true; false; end'
# Body presence mutation
@ -203,7 +203,7 @@ Mutant::Meta::Example.add do
mutation 'def self.foo; raise; end'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :def do
source 'def self.foo(a, b); end'

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :defined? do
source 'defined?(foo)'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :dstr do
source '"foo#{bar}baz"'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :dsym do
source ':"foo#{bar}baz"'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :ensure do
source 'begin; rescue; ensure; true; end'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :false do
source 'false'
mutation 'nil'

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :float do
source '10.0'
singleton_mutations
@ -14,7 +14,7 @@ Mutant::Meta::Example.add do
mutation '-10.0'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :float do
source '0.0'
singleton_mutations
@ -24,7 +24,7 @@ Mutant::Meta::Example.add do
mutation '(-1.0 / 0.0)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :float do
source '-0.0'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :gvar do
source '$a'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :gvasgn do
source '$a = true'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :hash do
source '{true => true, false => false}'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :if do
source 'if condition; true; else false; end'
singleton_mutations
@ -33,7 +33,7 @@ Mutant::Meta::Example.add do
mutation 'if condition; true; else nil; end'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :if do
source 'if condition; true; end'
singleton_mutations
@ -46,7 +46,7 @@ Mutant::Meta::Example.add do
mutation 'true'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :if do
source 'unless condition; true; end'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :int do
source '10'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :ivar do
source '@foo'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :ivasgn do
source '@a = true'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :kwbegin do
source 'begin; true; end'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :lvar do
source 'a = nil; a'
mutation 'a = nil; nil'

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :lvasgn do
source 'a = true'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :masgn do
source 'a, b = c, d'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :match_current_line do
source 'true if /foo/'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :next do
source 'next true'
singleton_mutations

View file

@ -1,3 +1,3 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :nil do
source 'nil'
end

View file

@ -1,10 +1,10 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :nthref do
source '$1'
mutation '$2'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :nthref do
source '$2'
mutation '$3'

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :op_asgn do
source '@a.b += 1'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :or do
source 'true or false'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :or_asgn do
source 'a ||= 1'
singleton_mutations
@ -10,7 +10,7 @@ Mutant::Meta::Example.add do
mutation 'a ||= 2'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :or_asgn do
source '@a ||= 1'
singleton_mutations
@ -21,13 +21,13 @@ Mutant::Meta::Example.add do
mutation '@a ||= 2'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :or_asgn do
source 'Foo ||= nil'
singleton_mutations
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :or_asgn do
source '@a ||= self.bar'
singleton_mutations
@ -36,7 +36,7 @@ Mutant::Meta::Example.add do
mutation '@a ||= bar'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :or_asgn do
source 'foo[:bar] ||= 1'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :irange do
source '1..100'
singleton_mutations
@ -20,7 +20,7 @@ Mutant::Meta::Example.add do
mutation '1..-100'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :erange do
source '1...100'
singleton_mutations

View file

@ -1,3 +1,3 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :redo do
source 'redo'
end

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :regexp do
source '/foo/'
singleton_mutations
@ -6,7 +6,7 @@ Mutant::Meta::Example.add do
mutation '/a\A/' # match nothing
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :regexp do
source '/#{foo.bar}n/'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :rescue do
source 'begin; rescue ExceptionA, ExceptionB => error; true; end'
singleton_mutations
@ -11,7 +11,7 @@ Mutant::Meta::Example.add do
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :rescue do
source 'begin; rescue SomeException => error; true; end'
singleton_mutations
@ -22,7 +22,7 @@ Mutant::Meta::Example.add do
mutation 'begin; true; end'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :rescue do
source 'begin; rescue => error; true end'
singleton_mutations
@ -32,7 +32,7 @@ Mutant::Meta::Example.add do
mutation 'begin; true; end'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :rescue do
source 'begin; rescue; true end'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :restarg do
source 'foo(*bar)'
singleton_mutations

View file

@ -1,10 +1,10 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :return do
source 'return'
singleton_mutations
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :return do
source 'return foo'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :self do
source 'self'
mutation 'nil'

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'a > b'
singleton_mutations
@ -14,7 +14,7 @@ Mutant::Meta::Example.add do
mutation 'b'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'A.const_get(:B)'
singleton_mutations
@ -28,7 +28,7 @@ Mutant::Meta::Example.add do
mutation 'self.const_get(:B)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'A.const_get(bar)'
singleton_mutations
@ -40,7 +40,7 @@ Mutant::Meta::Example.add do
mutation 'self.const_get(bar)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'method(bar)'
singleton_mutations
@ -51,7 +51,7 @@ Mutant::Meta::Example.add do
mutation 'method(self)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'a >= b'
singleton_mutations
@ -67,7 +67,7 @@ Mutant::Meta::Example.add do
mutation 'b'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'a <= b'
singleton_mutations
@ -83,7 +83,7 @@ Mutant::Meta::Example.add do
mutation 'b'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'a < b'
singleton_mutations
@ -99,21 +99,21 @@ Mutant::Meta::Example.add do
mutation 'b'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'reverse_each'
singleton_mutations
mutation 'each'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'reverse_merge'
singleton_mutations
mutation 'merge'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'reverse_map'
singleton_mutations
@ -121,14 +121,14 @@ Mutant::Meta::Example.add do
mutation 'each'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'map'
singleton_mutations
mutation 'each'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.to_s'
singleton_mutations
@ -137,7 +137,7 @@ Mutant::Meta::Example.add do
mutation 'foo.to_str'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.to_a'
singleton_mutations
@ -147,7 +147,7 @@ Mutant::Meta::Example.add do
mutation 'foo.to_set'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.to_i'
singleton_mutations
@ -157,7 +157,7 @@ Mutant::Meta::Example.add do
mutation 'Integer(foo)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.to_h'
singleton_mutations
@ -166,7 +166,7 @@ Mutant::Meta::Example.add do
mutation 'foo.to_hash'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo == bar'
singleton_mutations
@ -180,7 +180,7 @@ Mutant::Meta::Example.add do
mutation 'foo.equal?(bar)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.is_a?(bar)'
singleton_mutations
@ -193,7 +193,7 @@ Mutant::Meta::Example.add do
mutation 'foo.instance_of?(bar)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.is_a?(bar)'
singleton_mutations
@ -206,7 +206,7 @@ Mutant::Meta::Example.add do
mutation 'foo.instance_of?(bar)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.kind_of?(bar)'
singleton_mutations
@ -219,7 +219,7 @@ Mutant::Meta::Example.add do
mutation 'foo.instance_of?(bar)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.gsub(a, b)'
singleton_mutations
@ -235,7 +235,7 @@ Mutant::Meta::Example.add do
mutation 'self.gsub(a, b)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.values_at(a, b)'
singleton_mutations
@ -251,7 +251,7 @@ Mutant::Meta::Example.add do
mutation 'foo.values_at'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.dig(a, b)'
singleton_mutations
@ -267,7 +267,7 @@ Mutant::Meta::Example.add do
mutation 'foo.dig'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.dig(a)'
singleton_mutations
@ -280,7 +280,7 @@ Mutant::Meta::Example.add do
mutation 'a'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.dig'
singleton_mutations
@ -288,7 +288,7 @@ Mutant::Meta::Example.add do
mutation 'self.dig'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.__send__(bar)'
singleton_mutations
@ -301,7 +301,7 @@ Mutant::Meta::Example.add do
mutation 'foo.__send__(self)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.send(bar)'
singleton_mutations
@ -315,7 +315,7 @@ Mutant::Meta::Example.add do
mutation 'foo.send(self)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'self.bar = baz'
singleton_mutations
@ -326,7 +326,7 @@ Mutant::Meta::Example.add do
# This one could probably be removed
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.bar = baz'
singleton_mutations
@ -339,7 +339,7 @@ Mutant::Meta::Example.add do
# This one could probably be removed
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo[bar] = baz'
singleton_mutations
@ -353,7 +353,7 @@ Mutant::Meta::Example.add do
mutation 'baz'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo(*bar)'
singleton_mutations
@ -365,20 +365,20 @@ Mutant::Meta::Example.add do
mutation 'foo(*self)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo(&bar)'
singleton_mutations
mutation 'foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo'
singleton_mutations
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'self.foo'
singleton_mutations
@ -386,14 +386,14 @@ Mutant::Meta::Example.add do
end
Unparser::Constants::KEYWORDS.each do |keyword|
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source "self.#{keyword}"
singleton_mutations
end
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo.bar'
singleton_mutations
@ -401,7 +401,7 @@ Mutant::Meta::Example.add do
mutation 'self.bar'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'self.class.foo'
singleton_mutations
@ -409,14 +409,14 @@ Mutant::Meta::Example.add do
mutation 'self.foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo(nil)'
singleton_mutations
mutation 'foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'self.foo(nil)'
singleton_mutations
@ -424,7 +424,7 @@ Mutant::Meta::Example.add do
mutation 'foo(nil)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'self.fetch(nil)'
singleton_mutations
@ -434,7 +434,7 @@ Mutant::Meta::Example.add do
end
Unparser::Constants::KEYWORDS.each do |keyword|
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source "foo.#{keyword}(nil)"
singleton_mutations
@ -444,7 +444,7 @@ Unparser::Constants::KEYWORDS.each do |keyword|
end
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo(nil, nil)'
singleton_mutations
@ -452,7 +452,7 @@ Mutant::Meta::Example.add do
mutation 'foo(nil)'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source '(left - right) / foo'
singleton_mutations
@ -470,7 +470,7 @@ Mutant::Meta::Example.add do
mutation 'self / foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo[1]'
singleton_mutations
@ -488,7 +488,7 @@ Mutant::Meta::Example.add do
mutation 'foo[self]'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'self.foo[]'
singleton_mutations
@ -500,7 +500,7 @@ Mutant::Meta::Example.add do
mutation 'foo[]'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'self[foo]'
singleton_mutations
@ -513,7 +513,7 @@ Mutant::Meta::Example.add do
mutation 'foo'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'foo[*bar]'
singleton_mutations
@ -531,7 +531,7 @@ Mutant::Meta::Example.add do
end
(Mutant::AST::Types::BINARY_METHOD_OPERATORS - %i[<= >= < > == != eql?]).each do |operator|
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source "true #{operator} false"
singleton_mutations
@ -544,7 +544,7 @@ end
end
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :send do
source 'a != b'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :str do
source '"foo"'
singleton_mutations

View file

@ -1,17 +1,17 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :super do
source 'super'
singleton_mutations
mutation 'super()'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :super do
source 'super()'
singleton_mutations
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :super do
source 'super(foo, bar)'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :sym do
source ':foo'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :true do
source 'true'
mutation 'nil'

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :until do
source 'until true; foo; bar; end'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :while do
source 'while true; foo; bar; end'
singleton_mutations
@ -14,7 +14,7 @@ Mutant::Meta::Example.add do
mutation 'while true; raise; end'
end
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :while do
source 'while true; end'
singleton_mutations

View file

@ -1,4 +1,4 @@
Mutant::Meta::Example.add do
Mutant::Meta::Example.add :yield do
source 'yield true'
singleton_mutations

View file

@ -1,13 +1,19 @@
RSpec.describe Mutant::Meta::Example::DSL do
describe '.call' do
subject { described_class.call(file, block) }
subject { described_class.call(file, type, block) }
let(:file) { 'foo.rb' }
let(:node) { s(:false) }
let(:type) { node.type }
let(:expected) { [] }
let(:expected_example) do
Mutant::Meta::Example.new(file, node, expected)
Mutant::Meta::Example.new(
file: file,
node: node,
node_type: type,
expected: expected
)
end
def self.expect_example(&block)

View file

@ -3,9 +3,10 @@ RSpec.describe Mutant::Meta::Example::Verification do
let(:example) do
Mutant::Meta::Example.new(
'foo.rb',
s(:true),
expected_nodes
file: 'foo.rb',
node: s(:true),
node_type: :true,
expected: expected_nodes
)
end

View file

@ -1,9 +1,10 @@
RSpec.describe Mutant::Meta::Example do
let(:object) do
described_class.new(
file,
node,
mutation_nodes
file: file,
node: node,
node_type: node.type,
expected: mutation_nodes
)
end