Add Mutant::NodeHelpers#n_not

This commit is contained in:
Dan Kubb 2013-07-24 10:53:37 -07:00
parent 28ffff59d0
commit ddc0b79ed6
2 changed files with 24 additions and 0 deletions

View file

@ -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

View 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