Skip to content

Commit 388cfa5

Browse files
author
Jeff McCune
committed
Merge branch '4.x'
* 4.x: Add test/validation for is_float if created from an arithmetical operation Add test/validation for is_integer if created from an arithmetical operation Add test/validation for is_numeric if created from an arithmetical operation
2 parents 2df66c0 + fb7ae21 commit 388cfa5

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

lib/puppet/parser/functions/is_float.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Puppet::Parser::Functions
1515

1616
value = arguments[0]
1717

18-
if value != value.to_f.to_s then
18+
if value != value.to_f.to_s and !value.is_a? Float then
1919
return false
2020
else
2121
return true

lib/puppet/parser/functions/is_integer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Puppet::Parser::Functions
1515

1616
value = arguments[0]
1717

18-
if value != value.to_i.to_s then
18+
if value != value.to_i.to_s and !value.is_a? Fixnum then
1919
return false
2020
else
2121
return true

lib/puppet/parser/functions/is_numeric.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Puppet::Parser::Functions
1515

1616
value = arguments[0]
1717

18-
if value == value.to_f.to_s or value == value.to_i.to_s then
18+
if value == value.to_f.to_s or value == value.to_i.to_s or value.is_a? Numeric then
1919
return true
2020
else
2121
return false

spec/unit/puppet/parser/functions/is_float_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@
2626
result = scope.function_is_float(["3"])
2727
result.should(eq(false))
2828
end
29+
it "should return true if a float is created from an arithmetical operation" do
30+
result = scope.function_is_float([3.2*2])
31+
result.should(eq(true))
32+
end
2933
end

spec/unit/puppet/parser/functions/is_integer_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@
2626
result = scope.function_is_integer(["asdf"])
2727
result.should(eq(false))
2828
end
29+
30+
it "should return true if an integer is created from an arithmetical operation" do
31+
result = scope.function_is_integer([3*2])
32+
result.should(eq(true))
33+
end
2934
end

spec/unit/puppet/parser/functions/is_numeric_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
result.should(eq(true))
2323
end
2424

25+
it "should return true if an integer is created from an arithmetical operation" do
26+
result = scope.function_is_numeric([3*2])
27+
result.should(eq(true))
28+
end
29+
30+
it "should return true if a float is created from an arithmetical operation" do
31+
result = scope.function_is_numeric([3.2*2])
32+
result.should(eq(true))
33+
end
34+
2535
it "should return false if a string" do
2636
result = scope.function_is_numeric(["asdf"])
2737
result.should(eq(false))

0 commit comments

Comments
 (0)