mutant icon indicating copy to clipboard operation
mutant copied to clipboard

Add mutation `Enumerable#grep_v` -> `Enumerable#grep`

Open backus opened this issue 10 years ago • 5 comments
trafficstars

In ruby 2.3:

> %w[John Jack Jim Bob Greg Joe].grep_v(/^J/)
 => ["Bob", "Greg"]
> [1, 1.0, '1', 'one'].grep_v(Numeric)
 => ["1", "one"]

Mutating to Enumerable#grep is then a clear orthogonal mutation

backus avatar Nov 12 '15 19:11 backus

Mutating to Enumerable#grep is then a clear orthogonal mutation

I wounder if this mutation will ever yield an alive? We already mutate to the absence of grep (not explicitly, but we simply kill send nodes and emit the receiver).

The only case where this mutation will yield an alive is when the already existing "to absence" mutation will yield an alive?

mbj avatar Nov 15 '15 22:11 mbj

I think you're right here. Might not make sense to make this a mutation. One possible case might be if a test is asserting that the output array is a subset of the input array. Doesn't seem too likely to pop up though so I'm ambivalent about whether this would be useful

backus avatar Nov 20 '15 19:11 backus

Yeah, if the test is that weak this mutation would yield an alive. In doubt lets add it.

Once my service is up we can log which operators yielded alives the last N month, and kill the ones that never yielded an alive.

mbj avatar Nov 20 '15 19:11 mbj

In doubt lets add it.

@mbj Do you still feel this way? If so, I'm happy to add it.

dgollahon avatar Jan 02 '21 16:01 dgollahon

Likewise, we could do #select -> #reject.

dgollahon avatar Jan 03 '21 01:01 dgollahon