Module:Strip to numbers/testcases
Appearance
(Redirected from Module:StripToNumbers/testcases)
This is the template test cases page for the sandbox of Module:Strip to numbers. to update the examples. If there are many examples of a complicated template, later ones may break due to limits in MediaWiki; see the HTML comment "NewPP limit report" in the rendered page. You can also use Special:ExpandTemplates to examine the results of template uses. You can test how this page looks in the different skins and parsers with these links: |
Strip units from CSS values (why I want this)
[edit]- Input:
-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:Strip_to_numbers at line 8: Input did not contain valid numeric data.
Find numbers in a bunch of stuff
[edit]- Input:
SDks]df9s>dfjklasdfk9kasdfkasdkie0kmc'@(aks
- Result: 9
- Input:
"12.3x4"
- Result: 12.3
Halve number found in stuff
[edit]- Input:
foobarbaz50%blahblahblah
- Result: 25
- Input:
-66.6666666666666666666666666666
- Result: -33.333333333333
- Input:
chickenbutt
- Result: Lua error in Module:Strip_to_numbers at line 8: Input did not contain valid numeric data.
Nastier input tests
[edit]- 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 =
. Can it be escaped? (see below: use |1=
)
- Input:
{{=}}70%
- Result: 70
- Input:
style{{=}}"font-size: 70% ;"
- Result: 70
- Input:
<span style{{=}}"font-size: 70%;">
- Result: 70
- Input:
<span style<nowiki>=</nowiki>"font-size: 70%;">
- Result: 70
Yes, though only with {{=}}
; it chokes on <nowiki>...</nowiki>
. Though this points out the relative uselessness of trying to use this on strings this complicated, since -70
is the opposite of the desired output, 70
. It needs to be able to discern with -
is directly associated with a numeral (or perhaps a .
, since while -.7
is crappy style, it's still a technically valid way to write -0.7
.
Try: |1=
- Input:
1=70%
- Result: 70
- Input:
<span class="nowrap"><span data-sort-value="7001123000000000000♠"></span>12.3</span>
(produced by {{val|12.3}}) - Result: 7.001123e+18
After upgrade to match more narrowly
[edit]- Input:
style{{=}}"margin-left: 10% ;"
- Result: 10
- Input:
style{{=}}"margin-left: -10% ;"
- Result: -10
- Input:
Weasels - 12. Chickens - 72.
- Result: 12