Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Unit parsing truncates invalid portions of the unit #41

Closed
jasonhutchens opened this Issue · 0 comments

2 participants

@jasonhutchens

We're seeing inconsistent behaviour with Unit(...) when passing in invalid units:

ree-1.8.7-2011.03 :010 > Unit("1 foos/second").base
ArgumentError: '1 foos/second' Unit not recognized
    from .../.bundle/ruby/1.8/gems/ruby-units-1.4.0/lib/ruby_units/unit.rb:1463:in `parse'
    from .../.bundle/ruby/1.8/gems/ruby-units-1.4.0/lib/ruby_units/unit.rb:363:in `initialize'
    from .../.bundle/ruby/1.8/gems/ruby-units-1.4.0/lib/ruby_units/unit.rb:347:in `initialize'
    from .../.bundle/ruby/1.8/gems/ruby-units-1.4.0/lib/ruby_units/array.rb:7:in `new'
    from .../.bundle/ruby/1.8/gems/ruby-units-1.4.0/lib/ruby_units/array.rb:7:in `to_unit'
    from .../.bundle/ruby/1.8/gems/ruby-units-1.4.0/lib/ruby_units/object.rb:9:in `Unit'
    from (irb):10
ree-1.8.7-2011.03 :011 > Unit("1 second/foo").base
 => 1 s 

It would make more sense for Unit("1 second/foo").base to also throw an ArgumentError.

@olbrich olbrich closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.