Commit 3af1a68
committed
Fix ordinal() suffix for negative integers
ordinal() selected the suffix using value % 10 and value % 100, but
Python's modulo on negative numbers is non-negative (e.g. -1 % 10 == 9),
so negative inputs got the wrong suffix: ordinal(-1) returned '-1th'
instead of '-1st', ordinal(-21) returned '-21th' instead of '-21st', etc.
The docstring states it works for any integer, so compute the suffix
from abs(value). Add regression tests for negative ordinals.1 parent 0a06a3d commit 3af1a68
2 files changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
28 | 38 | | |
29 | 39 | | |
30 | 40 | | |
| |||
0 commit comments