Skip to content

Raise error on negative usec param to Time.new.#5371

Merged
headius merged 2 commits intojruby:masterfrom
headius:negative_usec_error
Oct 15, 2018
Merged

Raise error on negative usec param to Time.new.#5371
headius merged 2 commits intojruby:masterfrom
headius:negative_usec_error

Conversation

@headius
Copy link
Member

@headius headius commented Oct 15, 2018

Fixes #5370.

I'll add specs momentarily.

@headius headius added this to the JRuby 9.2.1.0 milestone Oct 15, 2018
Copy link

@til til left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix.

Maybe also add a spec to protect against a regression of this specific bug? (No idea how likely that is though).

  # [Bug #5370]
  it "raises ArgumentError if the seconds argument is negative fraction of second" do
    lambda { Time.new(2000, 1, 1, 0, 0, -0.1) }.should raise_error(ArgumentError)
  end

lambda { Time.new(2000, 1, 1, 0, 0, -1) }.should raise_error(ArgumentError)
end

it "raises ArgumentError if the utf_offset argument is greater than or equal to 10e9" do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*utc_offset

@headius
Copy link
Member Author

headius commented Oct 15, 2018

@til I think the -1 spec is just as good as the -0.1 spec, since it's just a simple test for negative seconds. The fact that it's a fractional amount does not appear to change the logic.

@headius headius force-pushed the negative_usec_error branch from aa8dd44 to 2375ff7 Compare October 15, 2018 18:21
@headius
Copy link
Member Author

headius commented Oct 15, 2018

Force pushed with corrected utf/utc line

@headius headius merged commit 117e9be into jruby:master Oct 15, 2018
@headius headius deleted the negative_usec_error branch October 15, 2018 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants