summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-09-26 22:59:50 +0200
committerBrice Figureau <brice@daysofwonder.com>2008-09-30 17:08:52 +0200
commit850e0baf0fbe321f14d4b9d913ce7dea39c9aa27 (patch)
tree0206d5855e46ae89d495fce9394c269a6ab47560 /spec/unit/parser
parent9cdecfecce84b9e0a88b5ea86b3136a1025ac9d9 (diff)
downloadpuppet-850e0baf0fbe321f14d4b9d913ce7dea39c9aa27.tar.gz
puppet-850e0baf0fbe321f14d4b9d913ce7dea39c9aa27.tar.xz
puppet-850e0baf0fbe321f14d4b9d913ce7dea39c9aa27.zip
Add not operator to AST
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/ast/not.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/unit/parser/ast/not.rb b/spec/unit/parser/ast/not.rb
new file mode 100755
index 000000000..0fe2deddd
--- /dev/null
+++ b/spec/unit/parser/ast/not.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe Puppet::Parser::AST::Not do
+ before :each do
+ @scope = Puppet::Parser::Scope.new()
+ @true_ast = Puppet::Parser::AST::Boolean.new( :value => true)
+ @false_ast = Puppet::Parser::AST::Boolean.new( :value => false)
+ end
+
+ it "should evaluate its child expression" do
+ val = stub "val"
+ val.expects(:safeevaluate).with(@scope)
+
+ operator = Puppet::Parser::AST::Not.new :value => val
+ operator.evaluate(@scope)
+ end
+
+ it "should return true for ! false" do
+ operator = Puppet::Parser::AST::Not.new :value => @false_ast
+ operator.evaluate(@scope).should == true
+ end
+
+ it "should return false for ! true" do
+ operator = Puppet::Parser::AST::Not.new :value => @true_ast
+ operator.evaluate(@scope).should == false
+ end
+
+end