Merge branch '3.2.x' into 3.x
* 3.2.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
This commit is contained in:
commit
d7aea0f0be
6 changed files with 22 additions and 3 deletions
|
@ -15,7 +15,7 @@ Returns true if the variable passed to this function is a float.
|
|||
|
||||
value = arguments[0]
|
||||
|
||||
if value != value.to_f.to_s then
|
||||
if value != value.to_f.to_s and !value.is_a? Float then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
|
|
|
@ -15,7 +15,7 @@ Returns true if the variable returned to this string is an integer.
|
|||
|
||||
value = arguments[0]
|
||||
|
||||
if value != value.to_i.to_s then
|
||||
if value != value.to_i.to_s and !value.is_a? Fixnum then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
|
|
|
@ -15,7 +15,7 @@ Returns true if the variable passed to this function is a number.
|
|||
|
||||
value = arguments[0]
|
||||
|
||||
if value == value.to_f.to_s or value == value.to_i.to_s then
|
||||
if value == value.to_f.to_s or value == value.to_i.to_s or value.is_a? Numeric then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
|
|
|
@ -26,4 +26,8 @@ describe "the is_float function" do
|
|||
result = scope.function_is_float(["3"])
|
||||
result.should(eq(false))
|
||||
end
|
||||
it "should return true if a float is created from an arithmetical operation" do
|
||||
result = scope.function_is_float([3.2*2])
|
||||
result.should(eq(true))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,4 +26,9 @@ describe "the is_integer function" do
|
|||
result = scope.function_is_integer(["asdf"])
|
||||
result.should(eq(false))
|
||||
end
|
||||
|
||||
it "should return true if an integer is created from an arithmetical operation" do
|
||||
result = scope.function_is_integer([3*2])
|
||||
result.should(eq(true))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,16 @@ describe "the is_numeric function" do
|
|||
result.should(eq(true))
|
||||
end
|
||||
|
||||
it "should return true if an integer is created from an arithmetical operation" do
|
||||
result = scope.function_is_numeric([3*2])
|
||||
result.should(eq(true))
|
||||
end
|
||||
|
||||
it "should return true if a float is created from an arithmetical operation" do
|
||||
result = scope.function_is_numeric([3.2*2])
|
||||
result.should(eq(true))
|
||||
end
|
||||
|
||||
it "should return false if a string" do
|
||||
result = scope.function_is_numeric(["asdf"])
|
||||
result.should(eq(false))
|
||||
|
|
Loading…
Reference in a new issue