Skip to content
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

Is number fix3191 #3192

Merged
merged 3 commits into from
Nov 20, 2021
Merged

Is number fix3191 #3192

merged 3 commits into from
Nov 20, 2021

Conversation

Phergus
Copy link
Contributor

@Phergus Phergus commented Nov 19, 2021

Identify the Bug or Feature request

Resolves #3191

Description of the Change

As part of the test, whitespace padding is removed as is the first leading '+' character if present.

Possible Drawbacks

Macros written after MT 1.7 and using isNumber() may produce different results now.

Documentation Notes

isNumber() trims whitespace from the passed in string and strips off the first leading '+' character if present before evaluating whether or not the string contains a valid number.

Release Notes

  • Macro function isNumber() will now evaluate strings with leading/trailing whitespace or single leading + characters returning true for numeric strings.

This change is Reviewable

Trim whitespace off of strings before evaluation.
Handle leading '+' character for numbers.
@Azhrei
Copy link
Member

Azhrei commented Nov 19, 2021

The docs for Integer.parseInt() indicate that a single leading minus sign or plus sign will be handled properly. If that's true, then stripping off a plus sign would allow a number such as ++5 to be treated as positive 5 and +-5 to be treated as negative 5.

Be sure to add tests for strings such as those.

(I'm basing this on the docs for NumberUtils.isParseable() and its references.)

@Phergus
Copy link
Contributor Author

Phergus commented Nov 19, 2021

@Azhrei passing +5 to NumberUtils.isParseable() returns false so, with the code as submitted, passing ++5 will return false after the first '+' is stripped off. Doesn't make sense to me to expect strings with an arbitrary number of '+' characters to be treated as numbers. The code for isParseable() explicitly handles a leading minus sign but returns false with 2 or more.

Copy link
Collaborator

@kwvanderlinde kwvanderlinde left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @cwisniew)

@Phergus Phergus merged commit dd50ec0 into RPTools:develop Nov 20, 2021
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.

[Bug]: isNumber() failing on padded strings
3 participants