Class TimeExTest
In: lib/core_ex/time.rb
Parent: Test::Unit::TestCase

Methods

Public Instance methods

[Source]

# File lib/core_ex/time.rb, line 40
    def setup
      @t1, @t2 = Time.at(1125583814.373), Time.at(1125583801.445)
    end

[Source]

# File lib/core_ex/time.rb, line 48
    def test_minus
      d1 = @t1 - @t2
      assert_kind_of(DTime, d1)
      assert_kind_of(Time, Time.now - d1)
      assert_kind_of(Time, Time.now - 1.4)
      assert_kind_of(Time, Time.now - 4)
      assert_equal(@t1, @t1 - 0)
      assert_equal(@t1, @t1 - 0.0)
      assert_equal(0, (@t1 - @t1).to_f)
    end

[Source]

# File lib/core_ex/time.rb, line 59
    def test_minus_2
      t = Time.utc(1937, 1, 1, 11, 40, 27, 870000)
      s = "1937-01-01T12:00:27.87+00:20"
      assert_equal(0, (t - Time.iso8601(s)).to_f)
    end

[Source]

# File lib/core_ex/time.rb, line 44
    def test_mixed
      assert ::Time.include?(CoreEx::Time)
    end

[Source]

# File lib/core_ex/time.rb, line 65
    def test_plus
      d1 = @t1 - @t2
      assert_raise(TypeError) { @t1 + @t2 }
      assert_kind_of(Time, @t1 + d1)
      assert_kind_of(Time, @t2 + d1)
      assert_in_delta(@t1.utc.to_f, (@t2 + d1).to_f, 1e-06)
    end

[Validate]