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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Master (Unreleased)]

### Added

- Block-pass mutations (`foo(&method(:bar))` -> `foo(&public_method(:bar))`) [[#54](https://github.com/backus/mutest/pull/54/files) ([@dgollahon][])]

## [0.0.6] - 2017-03-04

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion lib/mutest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def self.ci?
require 'mutest/mutator/node/named_value/variable_assignment'
require 'mutest/mutator/node/next'
require 'mutest/mutator/node/break'
require 'mutest/mutator/node/noop'
require 'mutest/mutator/node/block_pass'
require 'mutest/mutator/node/or_asgn'
require 'mutest/mutator/node/and_asgn'
require 'mutest/mutator/node/defined'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
module Mutest
class Mutator
class Node
# Mutation emitter to handle noop nodes
class Noop < self
handle(:block_pass, :cbase)
class BlockPass < self
handle(:block_pass)

children :arg

private

# Emit mutations
#
# @return [undefined]
def dispatch
# noop
emit_arg_mutations
end
end # Noop
end # BlockPass
end # Node
end # Mutator
end # Mutest
1 change: 1 addition & 0 deletions lib/mutest/mutator/node/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Node
# Generic mutator
class Generic < self
unsupported_nodes = %i[
cbase
ensure
redo
retry
Expand Down
10 changes: 9 additions & 1 deletion meta/block_pass.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Mutest::Meta::Example.add :block_pass do
source 'foo(&bar)'
source 'foo(&method(:bar))'

singleton_mutations
mutation 'foo'
mutation 'foo(&nil)'
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.

Any way we can avoid emitting these mutations? They are invalid.

Copy link
Copy Markdown
Owner Author

@dgollahon dgollahon Mar 19, 2017

Choose a reason for hiding this comment

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

They are not invalid. I had a check for them, but I tried it, and you can actually do &nil. It's a no-op so we could choose not to do it if we wanted. We could also skip &self but that works for objects that define #to_proc so possibly reasonable to have?.

[1].map(&nil).to_a # => [1]

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.

Oh cool. Alrighty then

mutation 'foo(&self)'
mutation 'foo(&method)'
mutation 'foo(&method(nil))'
mutation 'foo(&method(self))'
mutation 'foo(&method(:bar__mutest__))'
mutation 'foo(&public_method(:bar))'
mutation 'foo(&:bar)'
end
2 changes: 2 additions & 0 deletions meta/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@

singleton_mutations
mutation 'foo'
mutation 'foo(&nil)'
mutation 'foo(&self)'
end

Mutest::Meta::Example.add :send do
Expand Down