Repository navigation
Read a currency symbol outside the parentheses in Parse [patch] - #207
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
The parenthesis check ran before the currency symbol was stripped, so "$(45)", "(45)$" and "$ (45)" under Currency threw where decimal, double, long and BigInteger give -45. A currency symbol, with the spaces it may have beside it, is now removed first when what remains is wholly enclosed in parentheses. It counts as the number's one symbol, so "$($45)" and "$(45)$" still fail. Fixes #204 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4B4xxTAPzAHBD4zKk
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #204
What changed
StripAffixesrecognised parentheses only when they wrapped the whole trimmed string, and it checked for them before stripping the currency symbol. A symbol outside the parentheses therefore left(as the first character:"$(45)","$(1,234.50)","(45)$"and"$ (45)"underCurrency, and"¤(45)"underAny, all threw.decimal,double,longandBigIntegergive -45 for each of them.The new
StripCurrencySymbolOutsideParenthesesruns before the parenthesis check underAllowParentheses. It removes one leading or trailing currency symbol, along with the spacesSpacesBesideCurrencySymbolallows beside it, but only when the rest is wholly enclosed in parentheses. It marks the symbol as read, so the inner pass can't accept a second one, and"$($45)"and"$(45)$"still fail. A leading outer symbol counts ashasLeadingCurrencySymbol, so the separator choice for"$(1,234.50)"matches the inside-the-parentheses case.Tests
Every row is checked against
decimalwith the same text, style and format.TestParseAcceptsWhatDecimalAcceptsgains the issue's table: the five outside-symbol inputs, plus"(¤45)"and"(45¤)"for comparison. The five outside-symbol rows fail without the fix.TestParseRejectsWhatDecimalRejectsgains"$($45)","$(45)$"and"$(45".Generated by Claude Code