summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephen <stephen@puppetlabs.com>2013-01-03 14:05:29 +0000
committerJeff McCune <jeff@puppetlabs.com>2013-01-03 13:37:55 -0800
commita773281760469f2b104c89b2bfb760c0e3013422 (patch)
tree12d5f80efdcf54f1d3e1731b20777d3b1097c43c
parentb86f5dc1293ad431581afbb8f294560f3cf34d43 (diff)
Add test/validation for is_float if created from an arithmetical operation
-rw-r--r--lib/puppet/parser/functions/is_float.rb2
-rw-r--r--spec/unit/puppet/parser/functions/is_float_spec.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/is_float.rb b/lib/puppet/parser/functions/is_float.rb
index 2fc05ba..911f3c2 100644
--- a/lib/puppet/parser/functions/is_float.rb
+++ b/lib/puppet/parser/functions/is_float.rb
@@ -15,7 +15,7 @@ Returns true if the variable passed to this function is a float.
value = arguments[0]
- if value != value.to_f.to_s then
+ if value != value.to_f.to_s and !value.is_a? Float then
return false
else
return true
diff --git a/spec/unit/puppet/parser/functions/is_float_spec.rb b/spec/unit/puppet/parser/functions/is_float_spec.rb
index 2f527d9..b7d73b0 100644
--- a/spec/unit/puppet/parser/functions/is_float_spec.rb
+++ b/spec/unit/puppet/parser/functions/is_float_spec.rb
@@ -26,4 +26,8 @@ describe "the is_float function" do
result = scope.function_is_float(["3"])
result.should(eq(false))
end
+ it "should return true if a float is created from an arithmetical operation" do
+ result = scope.function_is_float([3.2*2])
+ result.should(eq(true))
+ end
end