Add test/validation for is_numeric if created from an arithmetical operation

This commit is contained in:
stephen 2013-01-03 13:53:03 +00:00 committed by Jeff McCune
parent e1f2a93288
commit 190b9438c5
2 changed files with 11 additions and 1 deletions

View file

@ -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

View file

@ -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))