Difference between revisions of "Category talk:StripToNumbers/testcases"
Jump to navigation
Jump to search
blackwiki>SMcCandlish (tests) |
blackwiki>SMcCandlish (grrr) |
||
| Line 25: | Line 25: | ||
* Input: chickenbutt | * Input: chickenbutt | ||
* Result: {{#invoke:StripToNumbers | halve | chickenbutt }} | * Result: {{#invoke:StripToNumbers | halve | chickenbutt }} | ||
| + | |||
| + | ==Nastier input tests== | ||
| + | |||
| + | * Input: style="font-size: 70% ;" | ||
| + | * Result: {{#invoke:StripToNumbers | main | style="font-size: 70% ;"}} | ||
| + | * Input: 'style="font-size: 70% ;"' | ||
| + | * Result: {{#invoke:StripToNumbers | main | 'style="font-size: 70% ;"'}} | ||
| + | * Input: `style="font-size: 70% ;"` | ||
| + | * Result: {{#invoke:StripToNumbers | main | `style="font-size: 70% ;"`}} | ||
| + | * Input: =70% | ||
| + | * Result: {{#invoke:StripToNumbers | main | =70% }} | ||
| + | Yeah, it dies on contact with <code>=</code>. | ||
Revision as of 09:34, 18 July 2015
Contents
Strip units from CSS values (why I want this)
- Input (will choke because of multiple
.characters: -12em, 34px, 56.7%, "89", 0 - Result: -12
- Input (will choke because of multiple
.characters: -12em, 34px, 56.7%, "8.9", 0 - Result: -12
- Input (will choke because of multiple
-characters: -12em, 34px, 57%, "-8.9", 0 - Result: -12
- Input: inherit
- Result: Lua error in Module:StripToNumbers at line 8: Input did not contain valid numeric data.
Find numbers in a bunch of stuff
- Input: SDks]df9s>dfjklasdfk9kasdfkasdkie0kmc'@(aks
- Result: 9
- Input: "12.3x4"
- Result: 12.3
Halve number found in stuff
- Input: foobarbaz50%blahblahblah
- Result: 25
- Input: -66.6666666666666666666666666666
- Result: -33.333333333333
- Input: chickenbutt
- Result: Lua error in Module:StripToNumbers at line 8: Input did not contain valid numeric data.
Nastier input tests
- Input: style="font-size: 70% ;"
- Result: Lua error: bad argument #1 to 'unstrip' (string expected, got nil).
- Input: 'style="font-size: 70% ;"'
- Result: Lua error: bad argument #1 to 'unstrip' (string expected, got nil).
- Input: `style="font-size: 70% ;"`
- Result: Lua error: bad argument #1 to 'unstrip' (string expected, got nil).
- Input: =70%
- Result: Lua error: bad argument #1 to 'unstrip' (string expected, got nil).
Yeah, it dies on contact with =.