/vendor/gems/facets-2.4.5/test/more/test_infinity.rb
Ruby | 40 lines | 28 code | 11 blank | 1 comment | 0 complexity | 7db958a9d05d1397992c7eaf86cf8994 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
- # Test facets/infinity.rb
- require 'facets/infinity.rb'
- require 'test/unit'
- class GeneralTest < Test::Unit::TestCase
- def test_pos
- assert_equal((1.0/0), INFINITY.to_f)
- assert_equal(1, INFINITY<=>5)
- assert_equal(1, INFINITY<=>"a")
- assert_equal("PosInf", INFINITY.to_s)
- end
- def test_neg
- assert_equal((-1.0/0), -INFINITY.to_f)
- assert_equal(-1, -INFINITY<=>5)
- assert_equal(-1, -INFINITY<=>"a")
- assert_equal("NegInf", (-INFINITY).to_s)
- end
- def test_ord
- assert_equal((-1.0/0), -INFINITY.to_f)
- assert_equal(-1, 5<=>INFINITY)
- assert_equal(1, 5<=>-INFINITY)
- end
- def test_eq
- assert_equal(Inf, Inf)
- assert_equal(-Inf, -Inf)
- assert_equal(PosInf, PosInf)
- assert_equal(NegInf, NegInf)
- assert_not_equal(NaN, NaN)
- end
- end