From 0804121719e4bde856723e19e8ff8bf6f9c2d55d Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 8 May 2014 14:43:06 -0700 Subject: Fix the stdlib functions that fail tests --- lib/puppet/parser/functions/floor.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/puppet/parser/functions/floor.rb') diff --git a/lib/puppet/parser/functions/floor.rb b/lib/puppet/parser/functions/floor.rb index a401923..9a6f014 100644 --- a/lib/puppet/parser/functions/floor.rb +++ b/lib/puppet/parser/functions/floor.rb @@ -8,7 +8,12 @@ module Puppet::Parser::Functions raise(Puppet::ParseError, "floor(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if arguments.size != 1 - arg = arguments[0] + begin + arg = Float(arguments[0]) + rescue TypeError, ArgumentError => e + raise(Puppet::ParseError, "floor(): Wrong argument type " + + "given (#{arguments[0]} for Numeric)") + end raise(Puppet::ParseError, "floor(): Wrong argument type " + "given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false -- cgit v1.2.3