Skip to content
This repository was archived by the owner on Aug 23, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/mutest/mutator/node/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Send < self
fetch: %i[key?],
first: %i[last],
flat_map: %i[map],
grep_v: %i[grep],
grep: %i[grep_v],
gsub: %i[sub],
is_a?: %i[instance_of?],
kind_of?: %i[instance_of?],
Expand All @@ -33,12 +35,12 @@ class Send < self
match: %i[match?],
method: %i[public_method],
pop: %i[last],
reject: %i[select],
reverse_each: %i[each],
reverse_map: %i[map each],
reverse_merge: %i[merge],
sample: %i[first last],
grep: %i[grep_v],
grep_v: %i[grep],
select: %i[reject],
send: %i[public_send __send__],
shift: %i[first],
to_a: %i[to_ary to_set],
Expand Down
14 changes: 14 additions & 0 deletions meta/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -810,3 +810,17 @@
mutation 'a.grep_v(self)'
mutation 'a.grep(b)'
end

Mutest::Meta::Example.add :send do
source 'select'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be checking for a block being passed to this method (and reject). We don't need to check for a receiver since it is common to use this if you include Enumerable

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM you can call it without a block. Personally I would still usually put a block here so it is clear. There is a Kernel#select method too which is TOTALLY different and a common gotcha for ruby devs at some point

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha.

I guess my other thought though is that we're unconditionally replacing select with reject so this made sense as the unit test. Yeah, the expected use case is enumerable_thing.select(a) or enumerable_thing.select { ... } but we're not restricting it to those cases.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it just makes it more clear that is the intention. Either way it still ends up being clear. A comment would also achieve the same goal

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're just worried about the intention I think that would be best resolved by actual annotations about why we do each mutation. Not disagreeing, really, i just think our explaining mechanism is the bigger problem rather than how the test is precisely formulated.


singleton_mutations
mutation 'reject'
end

Mutest::Meta::Example.add :send do
source 'reject'

singleton_mutations
mutation 'select'
end