(#2) - Added is_float and is_integer functionality.

This commit is contained in:
Ken Barber 2011-07-28 15:38:19 +01:00
parent fde64f37c9
commit a55930368a
4 changed files with 20 additions and 4 deletions

View file

@ -12,6 +12,14 @@ module Puppet::Parser::Functions
"given #{arguments.size} for 1")
end
value = arguments[0]
if value != value.to_f.to_s then
return false
else
return true
end
end
end

View file

@ -12,6 +12,14 @@ module Puppet::Parser::Functions
"given #{arguments.size} for 1")
end
value = arguments[0]
if value != value.to_i.to_s then
return false
else
return true
end
end
end

View file

@ -19,7 +19,7 @@ describe "the is_float function" do
end
it "should return true if a float" do
result = @scope.function_is_float([0.12])
result = @scope.function_is_float(["0.12"])
result.should(eq(true))
end
@ -29,7 +29,7 @@ describe "the is_float function" do
end
it "should return false if not an integer" do
result = @scope.function_is_float([3])
result = @scope.function_is_float(["3"])
result.should(eq(false))
end

View file

@ -19,12 +19,12 @@ describe "the is_integer function" do
end
it "should return true if an integer" do
result = @scope.function_is_integer([3])
result = @scope.function_is_integer(["3"])
result.should(eq(true))
end
it "should return false if a float" do
result = @scope.function_is_integer([3.2])
result = @scope.function_is_integer(["3.2"])
result.should(eq(false))
end