summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/parser/functions
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/puppet/parser/functions')
-rw-r--r--spec/unit/puppet/parser/functions/num2bool_spec.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/spec/unit/puppet/parser/functions/num2bool_spec.rb b/spec/unit/puppet/parser/functions/num2bool_spec.rb
index 5ce981e..038881f 100644
--- a/spec/unit/puppet/parser/functions/num2bool_spec.rb
+++ b/spec/unit/puppet/parser/functions/num2bool_spec.rb
@@ -16,6 +16,10 @@ describe "the num2bool function" do
lambda { scope.function_num2bool(["foo","bar"]) }.should( raise_error(Puppet::ParseError))
end
+ it "should raise a ParseError if passed something non-numeric" do
+ lambda { scope.function_num2bool(["xyzzy"]) }.should( raise_error(Puppet::ParseError))
+ end
+
it "should return true if passed string 1" do
result = scope.function_num2bool(["1"])
result.should(be_true)
@@ -26,6 +30,16 @@ describe "the num2bool function" do
result.should(be_true)
end
+ it "should return true if passed array with string 1" do
+ result = scope.function_num2bool([["1"]])
+ result.should(be_true)
+ end
+
+ it "should return true if passed array with number 1" do
+ result = scope.function_num2bool([[1]])
+ result.should(be_true)
+ end
+
it "should return false if passed string 0" do
result = scope.function_num2bool(["0"])
result.should(be_false)
@@ -36,6 +50,16 @@ describe "the num2bool function" do
result.should(be_false)
end
+ it "should return false if passed array with string 0" do
+ result = scope.function_num2bool([["0"]])
+ result.should(be_false)
+ end
+
+ it "should return false if passed array with number 0" do
+ result = scope.function_num2bool([[0]])
+ result.should(be_false)
+ end
+
it "should return false if passed string -1" do
result = scope.function_num2bool(["-1"])
result.should(be_false)
@@ -46,8 +70,14 @@ describe "the num2bool function" do
result.should(be_false)
end
- it "should return false if passed something non-numeric" do
- result = scope.function_num2bool(["xyzzy"])
+ it "should return false if passed array with string -1" do
+ result = scope.function_num2bool([["-1"]])
result.should(be_false)
end
+
+ it "should return false if passed array with number -1" do
+ result = scope.function_num2bool([[-1]])
+ result.should(be_false)
+ end
+
end