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

index 8ee34f6992b2a5129050638f0cd500ecc33af99e..6b29e988e30665fddc87f3a8360dd067d606217a 100644 (file)
@@ -15,7 +15,7 @@ Returns true if the variable returned to this string is an integer.
 
     value = arguments[0]
 
-    if value != value.to_i.to_s then
+    if value != value.to_i.to_s and !value.is_a? Fixnum then
       return false
     else
       return true
index 5afbba4a086111e7cdb54e1f104f3c4dc7ab707f..4335795028fdaf5ef0f16c41a8cabc38270f713a 100644 (file)
@@ -26,4 +26,9 @@ describe "the is_integer function" do
     result = scope.function_is_integer(["asdf"])
     result.should(eq(false))
   end
+
+  it "should return true if an integer is created from an arithmetical operation" do
+    result = scope.function_is_integer([3*2])
+    result.should(eq(true))
+  end
 end