Sha256: c97a289aeac1bf5b8b911c6916e5f13befdc262f752d1419a34029084991c109

Contents?: true

Size: 1.09 KB

Versions: 52

Compression:

Stored size: 1.09 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/methods', __FILE__)

describe "Time#<=>" do
  it "returns 1 if the first argument is a point in time after the second argument" do
    (Time.now <=> Time.at(0)).should == 1
    (Time.at(0, 100) <=> Time.at(0, 0)).should == 1
    (Time.at(1202778512, 100) <=> Time.at(1202778512, 99)).should == 1
  end

  it "returns 0 if time is the same as other" do
    (Time.at(1202778513) <=> Time.at(1202778513)).should == 0
    (Time.at(100, 100) <=> Time.at(100, 100)).should == 0
  end

  it "returns -1 if the first argument is a point in time before the second argument" do
    (Time.at(0) <=> Time.now).should == -1
    (Time.at(0, 0) <=> Time.at(0, 100)).should == -1
    (Time.at(100, 100) <=> Time.at(101, 100)).should == -1
  end

  # see [ruby-core:15333]
  it "returns nil when Time is compared to Numeric" do
    (Time.at(100) <=> 100).should == nil
    (Time.at(100) <=> 100.0).should == nil
  end

  it "returns nil when Time is compared to some Object" do
    (Time.at(100) <=> Object.new).should == nil
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/time/comparison_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/time/comparison_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/time/comparison_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/time/comparison_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/time/comparison_spec.rb