File tree Expand file tree Collapse file tree 6 files changed +22
-3
lines changed
lib/puppet/parser/functions
spec/unit/puppet/parser/functions Expand file tree Collapse file tree 6 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module Puppet::Parser::Functions
15
15
16
16
value = arguments [ 0 ]
17
17
18
- if value != value . to_f . to_s then
18
+ if value != value . to_f . to_s and ! value . is_a? Float then
19
19
return false
20
20
else
21
21
return true
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module Puppet::Parser::Functions
15
15
16
16
value = arguments [ 0 ]
17
17
18
- if value != value . to_i . to_s then
18
+ if value != value . to_i . to_s and ! value . is_a? Fixnum then
19
19
return false
20
20
else
21
21
return true
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module Puppet::Parser::Functions
15
15
16
16
value = arguments [ 0 ]
17
17
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
19
19
return true
20
20
else
21
21
return false
Original file line number Diff line number Diff line change 26
26
result = scope . function_is_float ( [ "3" ] )
27
27
result . should ( eq ( false ) )
28
28
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
29
33
end
Original file line number Diff line number Diff line change 26
26
result = scope . function_is_integer ( [ "asdf" ] )
27
27
result . should ( eq ( false ) )
28
28
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
29
34
end
Original file line number Diff line number Diff line change 22
22
result . should ( eq ( true ) )
23
23
end
24
24
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
+
25
35
it "should return false if a string" do
26
36
result = scope . function_is_numeric ( [ "asdf" ] )
27
37
result . should ( eq ( false ) )
You can’t perform that action at this time.
0 commit comments