Add Mutant::NodeHelpers#n_not
This commit is contained in:
parent
28ffff59d0
commit
ddc0b79ed6
2 changed files with 24 additions and 0 deletions
|
@ -27,5 +27,17 @@ module Mutant
|
|||
N_NIL = s(:nil)
|
||||
N_EMPTY = s(:empty)
|
||||
|
||||
# Build a negated boolean node
|
||||
#
|
||||
# @param [Parser::AST::Node] node
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def n_not(node)
|
||||
s(:send, node, :!)
|
||||
end
|
||||
|
||||
end # NodeHelpers
|
||||
end # Mutant
|
||||
|
|
12
spec/unit/mutant/node_helpers/n_not_spec.rb
Normal file
12
spec/unit/mutant/node_helpers/n_not_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::NodeHelpers, '#n_not' do
|
||||
subject { object.n_not(node) }
|
||||
|
||||
let(:object) { Object.new.extend(described_class) }
|
||||
let(:node) { described_class::N_TRUE }
|
||||
|
||||
it 'returns the negated node' do
|
||||
expect(subject).to eq(parse('not true'))
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue