-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mutation operators preset
light
and full
* Defaults to `light`, giving up to educate the world about the issues with `#==`, at least by default.
- Loading branch information
Showing
22 changed files
with
258 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mutant | ||
# Represent a mutated node with its subject | ||
class Mutation | ||
class Operators | ||
include Equalizer.new | ||
|
||
class Full < self | ||
NAME = :full | ||
|
||
SELECTOR_REPLACEMENTS = { | ||
:< => %i[== eql? equal?], | ||
:<= => %i[< == eql? equal?], | ||
:== => %i[eql? equal?], | ||
:=== => %i[is_a?], | ||
:=~ => %i[match?], | ||
:> => %i[== eql? equal?], | ||
:>= => %i[> == eql? equal?], | ||
__send__: %i[public_send], | ||
all?: %i[any?], | ||
any?: %i[all?], | ||
at: %i[fetch key?], | ||
fetch: %i[key?], | ||
flat_map: %i[map], | ||
gsub: %i[sub], | ||
is_a?: %i[instance_of?], | ||
kind_of?: %i[instance_of?], | ||
map: %i[each], | ||
match: %i[match?], | ||
method: %i[public_method], | ||
reverse_each: %i[each], | ||
reverse_map: %i[map each], | ||
reverse_merge: %i[merge], | ||
send: %i[public_send __send__], | ||
to_a: %i[to_ary], | ||
to_h: %i[to_hash], | ||
to_i: %i[to_int], | ||
to_s: %i[to_str], | ||
values_at: %i[fetch_values] | ||
}.freeze.tap { |hash| hash.values(&:freeze) } | ||
end | ||
|
||
class Light < self | ||
NAME = :light | ||
|
||
SELECTOR_REPLACEMENTS = Full::SELECTOR_REPLACEMENTS | ||
.dup | ||
.tap do |replacements| | ||
replacements.delete(:==) | ||
replacements.delete(:eql?) | ||
end | ||
.freeze | ||
end | ||
|
||
def self.operators_name | ||
self::NAME | ||
end | ||
|
||
def selector_replacements | ||
self.class::SELECTOR_REPLACEMENTS | ||
end | ||
|
||
def self.parse(value) | ||
klass = [Light, Full].detect { |candidate| candidate.operators_name.to_s.eql?(value) } | ||
|
||
if klass | ||
Either::Right.new(klass.new) | ||
else | ||
Either::Left.new("Unknown operators: #{value}") | ||
end | ||
end | ||
|
||
TRANSFORM = | ||
Transform::Sequence.new( | ||
steps: [ | ||
Transform::STRING, | ||
Transform::Block.capture('parse operator', &method(:parse)) | ||
] | ||
) | ||
end # Operators | ||
end # Mutation | ||
end # Mutant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
|
||
module Mutant | ||
# Current mutant version | ||
VERSION = '0.11.21' | ||
VERSION = '0.11.22' | ||
end # Mutant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.