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
label_min_length=1
label_max_length=63
+ # Only allow string types
+ return false unless domain.is_a?(String)
+
# Allow ".", it is the top level domain
return true if domain == '.'
value = arguments[0]
+ # Only allow Numeric or String types
+ return false unless value.is_a?(Numeric) or value.is_a?(String)
+
if value != value.to_f.to_s and !value.is_a? Float then
return false
else
"given #{arguments.size} for 1")
end
+ # Only allow String types
+ return false unless arguments[0].is_a?(String)
+
function = Puppet::Parser::Functions.function(arguments[0].to_sym)
function.is_a?(String) and not function.empty?
end
notice(inline_template('getparam is <%= @o.inspect %>'))
EOS
- apply_manifest(pp, :expect_changes => true) do |r|
+ apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/getparam is true/)
end
end
pp = <<-EOS
$a = ['aaa.com','bbb','ccc']
$o = is_float($a)
- notice(inline_template('is_floats is <%= @o.inspect %>'))
+ notice(inline_template('is_float is <%= @o.inspect %>'))
EOS
apply_manifest(pp, :catch_failures => true) do |r|
pp = <<-EOS
$a = true
$o = is_float($a)
- notice(inline_template('is_floats is <%= @o.inspect %>'))
+ notice(inline_template('is_float is <%= @o.inspect %>'))
EOS
apply_manifest(pp, :catch_failures => true) do |r|
EOS
apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/is_floats is false/)
+ expect(r.stdout).to match(/is_float is false/)
end
end
end
EOS
apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/is_string is true/)
+ expect(r.stdout).to match(/is_string is false/)
end
end
it 'is_strings floats' do