summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/parser/functions/is_numeric_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/puppet/parser/functions/is_numeric_spec.rb')
-rw-r--r--spec/unit/puppet/parser/functions/is_numeric_spec.rb80
1 files changed, 80 insertions, 0 deletions
diff --git a/spec/unit/puppet/parser/functions/is_numeric_spec.rb b/spec/unit/puppet/parser/functions/is_numeric_spec.rb
index d7440fb..1df1497 100644
--- a/spec/unit/puppet/parser/functions/is_numeric_spec.rb
+++ b/spec/unit/puppet/parser/functions/is_numeric_spec.rb
@@ -36,4 +36,84 @@ describe "the is_numeric function" do
result = scope.function_is_numeric(["asdf"])
result.should(eq(false))
end
+
+ it "should return false if an array" do
+ result = scope.function_is_numeric([["asdf"]])
+ result.should(eq(false))
+ end
+
+ it "should return false if an array of integers" do
+ result = scope.function_is_numeric([[1,2,3,4]])
+ result.should(eq(false))
+ end
+
+ it "should return false if a hash" do
+ result = scope.function_is_numeric([{"asdf" => false}])
+ result.should(eq(false))
+ end
+
+ it "should return false if a hash with numbers in it" do
+ result = scope.function_is_numeric([{1 => 2}])
+ result.should(eq(false))
+ end
+
+ it "should return false if a boolean" do
+ result = scope.function_is_numeric([true])
+ result.should(eq(false))
+ end
+
+ it "should return true if a negative float with exponent" do
+ result = scope.function_is_numeric(["-342.2315e-12"])
+ result.should(eq(true))
+ end
+
+ it "should return false if a negative integer with whitespaces before/after the dash" do
+ result = scope.function_is_numeric([" - 751"])
+ result.should(eq(false))
+ end
+
+# it "should return true if a hexadecimal" do
+# result = scope.function_is_numeric(["0x52F8c"])
+# result.should(eq(true))
+# end
+#
+# it "should return true if a hexadecimal with uppercase 0X prefix" do
+# result = scope.function_is_numeric(["0X52F8c"])
+# result.should(eq(true))
+# end
+#
+# it "should return false if a hexadecimal without a prefix" do
+# result = scope.function_is_numeric(["52F8c"])
+# result.should(eq(false))
+# end
+#
+# it "should return true if a octal" do
+# result = scope.function_is_numeric(["0751"])
+# result.should(eq(true))
+# end
+#
+# it "should return true if a negative hexadecimal" do
+# result = scope.function_is_numeric(["-0x52F8c"])
+# result.should(eq(true))
+# end
+#
+# it "should return true if a negative octal" do
+# result = scope.function_is_numeric(["-0751"])
+# result.should(eq(true))
+# end
+#
+# it "should return false if a negative octal with whitespaces before/after the dash" do
+# result = scope.function_is_numeric([" - 0751"])
+# result.should(eq(false))
+# end
+#
+# it "should return false if a bad hexadecimal" do
+# result = scope.function_is_numeric(["0x23d7g"])
+# result.should(eq(false))
+# end
+#
+# it "should return false if a bad octal" do
+# result = scope.function_is_numeric(["0287"])
+# result.should(eq(false))
+# end
end