summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/floor.rb
diff options
context:
space:
mode:
authorHunter Haugen <hunter@puppetlabs.com>2014-05-08 14:43:06 -0700
committerHunter Haugen <hunter@puppetlabs.com>2014-05-08 14:55:23 -0700
commit0804121719e4bde856723e19e8ff8bf6f9c2d55d (patch)
treed4faff54b5acadcc430675e992897f32b7409a72 /lib/puppet/parser/functions/floor.rb
parente2297a1ea6b711ca930a21adc56aefe7c602826f (diff)
Fix the stdlib functions that fail tests
Diffstat (limited to 'lib/puppet/parser/functions/floor.rb')
-rw-r--r--lib/puppet/parser/functions/floor.rb7
1 files changed, 6 insertions, 1 deletions
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