-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix QuantityType#eql? raising exception on incompatible QuantityType unit #400
Conversation
52a5423
to
12cac5c
Compare
508516f
to
8b092be
Compare
I've restored eql? and added a unit compatibility check to avoid the exception from core's compare_to |
eda0315
to
7b25386
Compare
eae3c33
to
90ec40e
Compare
spec/openhab/dsl_spec.rb
Outdated
@@ -483,7 +483,7 @@ | |||
expect(2 * w).to eql 10 | "W" | |||
expect((2 * kw).to_i).to eq 10_000 | |||
expect(2 * w == 10).to be true | |||
expect(5 / w).to eql 1 | "W" | |||
expect(5 / w).to eql 1 | "/W" | |||
expect((2 * w / 2)).to eql w |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add a not_to eql case for when it's false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a good not_to eql check to add, so I added a check against kw
. Do you have a better idea?
…unit Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
90ec40e
to
a6c07fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's exactly what I had in mind
There was a bug in our spec which core was happily allowing:
(1 | "1/W").compare_to(1 | "W")
used to return0
.openHAB 5.0 now throws an exception when comparing invertible unit.
Relevant PR