]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Add test/validation for is_float if created from an arithmetical operation
authorstephen <stephen@puppetlabs.com>
Thu, 3 Jan 2013 14:05:29 +0000 (14:05 +0000)
committerJeff McCune <jeff@puppetlabs.com>
Thu, 3 Jan 2013 21:37:55 +0000 (13:37 -0800)
lib/puppet/parser/functions/is_float.rb
spec/unit/puppet/parser/functions/is_float_spec.rb

index 2fc05ba9c684b2736c25666bb37d1110b747fbee..911f3c2dcdcc6e94f1e864c08c3720e88a02087c 100644 (file)
@@ -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
index 2f527d9323183d7744dce6151648f9102e1a3639..b7d73b04a2559901c926a221e1853927db6f3f48 100644 (file)
@@ -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