-
Notifications
You must be signed in to change notification settings - Fork 0
WAK-1758: Lakh ton is not working correctly #22
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
Conversation
tests/ParserTest.php
Outdated
| public function test_parses_dash_joined_unit_directly_if_registered() | ||
| { | ||
| $this->registry->register('watt-hour', new Unit( | ||
| // Watt |
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.
| // Watt | |
| // Watt |
tomhooijenga
left a comment
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.
What happens when my unit-with-a-dash is part of some bigger unit? Like watt-hour/kg?
Cases:
|
src/Parser.php
Outdated
| 'value' => $match['unit'], | ||
| 'power' => (int)($match['power'] ?? 1), | ||
| ]; | ||
| // If the unit contains a dash, check if it's a registered unit as a whole |
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.
Out of interest, are there any units that actually have a dash but aren't compounds? Because that would completely ruin us right?
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.
It shouldn't be possible, but I guess we should be able to handle it. We do test for gram-liter and handle them individually for example
| ) | ||
| ); | ||
|
|
||
| static::registerSiUnit( |
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 should pull master.
|
|
||
| return new Unit(...array_merge([], ...$parts)); | ||
| } | ||
|
|
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.
Can we keep it?
… as single unit, otherwise divide tokens
92e9bda to
d9a31cb
Compare
11317e5 to
7b0b58d
Compare
…s-not-working-correctly
Cases:
watt-hour)gram-literinto [gram,liter]/or*)watt-hour/kgor for examplegram-liter/hourwatt-hour/kgis tokenized into [watt-hour,/,kilogram] sincewatt-houris a registered single unitgram-liter/houris tokenized into [gram,liter,/,hour] sincegram-literis not a registered single unit and needs to be processed bygramandliter