Skip to content

Fix test with negative numbers

Michael Aaron Murphy requested to merge AgustinCB:fix-586 into master

Created by: AgustinCB

Problem: the test builtin is falsely passing when one of the numbers is negative.

Solution: Two problems were addressed:

  • It was assuming that negative numbers were flag strings: Solved by checking that the second character is alphabetic.
  • It was parsing to usize. Solved by parsing to isize.

Changes introduced by this pull request:

Other than what commented in the solution, added tests for this cases.

TODOs: In the issue was commented the possibility of using decimal and parsing to d128. I didn't feel comfortable adding that overhead without a deeper discussion, so I just made the minimal fix to solve the problem.

Also... is is_alphabetic a good match? I felt tempted to use is_ascii_alphabetic instead, but it's still experimental and it wasn't considered a Pattern, so the compiler complained. is_alphabetical cover more cases than we do right now, so maybe is worth to use our own is_ascii_alphabetic?

Fixes: #586 (closed)

State: Ready

Merge request reports