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

[Bug]: isNumber() failing on padded strings #3191

Closed
Phergus opened this issue Nov 19, 2021 · 2 comments · Fixed by #3192
Closed

[Bug]: isNumber() failing on padded strings #3191

Phergus opened this issue Nov 19, 2021 · 2 comments · Fixed by #3192
Assignees
Labels

Comments

@Phergus
Copy link
Contributor

Phergus commented Nov 19, 2021

Describe the Bug

Doing isNumber(" 5") returns false.

To Reproduce

  1. Run isNumber(" 5") from chat or a macro. Note the space in front of 5.
  2. Returns 0.

Expected Behaviour

Should return 1 for true as was the behavior in MT 1.7.0 and prior.

Screenshots

No response

MapTool Info

1.9.0 to 1.11.0-alpha.5

Desktop

Windows 10

Additional Context

Known working in 1.7.0. Not working in 1.9.0 to 1.11.0-alpha.5.

@Phergus Phergus added the bug label Nov 19, 2021
@Phergus Phergus self-assigned this Nov 19, 2021
@Phergus
Copy link
Contributor Author

Phergus commented Nov 19, 2021

Under MT 1.9.0 - 1.11.0-alpha.5

<br>
[h: a = " 5 "]
a: [isNumber(a)]<br>
[h: b = "-5 "]
b: [isNumber(b)]<br>
[h: c = "+5 "]
c: [isNumber(c)]<br>
[h: d = " +5 "]
d: [isNumber(d)]<br>
value: [r: number(d)]<br>
[h: e = " -5 "]
e: [isNumber(e)]<br>
[h: f = " -5 "]
f: [isNumber(f)]<br>
value: [r: number(f)]

produces:

a: « isNumber(a) = isNumber( 5 ) = 0 » 
b: « isNumber(b) = isNumber(-5 ) = 0 » 
c: « isNumber(c) = isNumber(+5 ) = 0 » 
d: « isNumber(d) = isNumber( +5 ) = 0 » 
value: 5.0 
e: « isNumber(e) = isNumber( -5 ) = 0 » 
f: « isNumber(f) = isNumber( -5 ) = 0 » 
value: -5.0

@Phergus
Copy link
Contributor Author

Phergus commented Nov 19, 2021

With fix from PR #3192:

a: « isNumber(a) = isNumber( 5 ) = 1 »
b: « isNumber(b) = isNumber(-5 ) = 1 »
c: « isNumber(c) = isNumber(+5 ) = 1 »
d: « isNumber(d) = isNumber( +5 ) = 1 »
value: 5.0 
e: « isNumber(e) = isNumber( -5 ) = 1 »
f: « isNumber(f) = isNumber( -5 ) = 1 »
value: -5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant