#4324 streamline behaviour of Timestamp.== and Timestamp.eql?

Fixes #7002
This commit is contained in:
Armin Braun 2017-05-01 11:58:01 +02:00
parent 822d7fe506
commit 11d34204f5
2 changed files with 10 additions and 0 deletions

View file

@ -13,6 +13,10 @@ module LogStash
self.time <=> other.time
end
def eql?(other)
self.== other
end
# TODO (colin) implement in Java
def +(other)
self.time + other

View file

@ -20,6 +20,12 @@ describe LogStash::Timestamp do
expect(t.time.to_i).to eq(now.to_i)
end
it "should have consistent behaviour across == and .eql?" do
its_xmas = Time.utc(2015, 12, 25, 0, 0, 0)
expect(LogStash::Timestamp.new(its_xmas)).to eql(LogStash::Timestamp.new(its_xmas))
expect(LogStash::Timestamp.new(its_xmas)).to be ==(LogStash::Timestamp.new(its_xmas))
end
it "should raise exception on invalid format" do
expect{LogStash::Timestamp.new("foobar")}.to raise_error
end