Skip to content

Commit

Permalink
Add emit of naked guard body
Browse files Browse the repository at this point in the history
[fixes #280]
  • Loading branch information
mbj committed Dec 21, 2014
1 parent 89c8fc3 commit 7f47ac4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/mutant/mutator/node/if.rb
Expand Up @@ -47,6 +47,7 @@ def mutate_condition
def mutate_if_branch
emit_type(condition, else_branch, nil) if else_branch
return unless if_branch
emit(if_branch)
emit_if_branch_mutations
emit_type(condition, if_branch, nil)
end
Expand All @@ -59,6 +60,7 @@ def mutate_if_branch
#
def mutate_else_branch
return unless else_branch
emit(else_branch)
emit_else_branch_mutations
emit_type(condition, nil, else_branch)
end
Expand Down
8 changes: 8 additions & 0 deletions meta/if.rb
Expand Up @@ -14,6 +14,12 @@
# Deleted else branch
mutation 'if condition; true end'

# Promote if branch
mutation 'true'

# Promote else branch
mutation 'false'

# Deleted if branch resulting in unless rendering
mutation 'unless condition; false; end'

Expand All @@ -39,6 +45,7 @@
mutation 'if true; true; end'
mutation 'if false; true; end'
mutation 'if nil; true; end'
mutation 'true'
end

Mutant::Meta::Example.add do
Expand All @@ -52,4 +59,5 @@
mutation 'unless condition; false; end'
mutation 'unless condition; nil; end'
mutation 'if condition; true; end'
mutation 'true'
end
1 change: 1 addition & 0 deletions meta/match_current_line.rb
Expand Up @@ -11,4 +11,5 @@
mutation 'true if false'
mutation 'true if nil'
mutation 'true if /a\A/'
mutation 'true'
end

0 comments on commit 7f47ac4

Please sign in to comment.