PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/more/test_infinity.rb

https://bitbucket.org/mediashelf/fedora-migrator
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
  1. # Test facets/infinity.rb
  2. require 'facets/infinity.rb'
  3. require 'test/unit'
  4. class GeneralTest < Test::Unit::TestCase
  5. def test_pos
  6. assert_equal((1.0/0), INFINITY.to_f)
  7. assert_equal(1, INFINITY<=>5)
  8. assert_equal(1, INFINITY<=>"a")
  9. assert_equal("PosInf", INFINITY.to_s)
  10. end
  11. def test_neg
  12. assert_equal((-1.0/0), -INFINITY.to_f)
  13. assert_equal(-1, -INFINITY<=>5)
  14. assert_equal(-1, -INFINITY<=>"a")
  15. assert_equal("NegInf", (-INFINITY).to_s)
  16. end
  17. def test_ord
  18. assert_equal((-1.0/0), -INFINITY.to_f)
  19. assert_equal(-1, 5<=>INFINITY)
  20. assert_equal(1, 5<=>-INFINITY)
  21. end
  22. def test_eq
  23. assert_equal(Inf, Inf)
  24. assert_equal(-Inf, -Inf)
  25. assert_equal(PosInf, PosInf)
  26. assert_equal(NegInf, NegInf)
  27. assert_not_equal(NaN, NaN)
  28. end
  29. end