It's a constant of the Float
class:
assert_equal [Float::INFINITY, 1], z
If you're using a version before 1.9.2, try:
assert_equal [1.0 / 0, 1], z
Question
I am trying to create a Minitest test that tests for an instance of Infinity
being returned in an array. However I am getting an uninitialized constant error. How do I check for Infinity
in an array?
This is the test:
def test_lgamma
x = 0
z = Math.lgamma(x)
puts z
assert_equal [Infinity, 1], z
end
This is the error:
NameError: uninitialized constant Tests::Infinity
.../CORE_MATH.rb:131:in `test_lgamma'
La solution
It's a constant of the Float
class:
assert_equal [Float::INFINITY, 1], z
If you're using a version before 1.9.2, try:
assert_equal [1.0 / 0, 1], z