Test-If
| This page is for any potential contributors, editors, and admins of the FSDeveloper Wiki. It is not about developing for flightsim. |
Hi Folks
Could we please install the ParserFunctions MediaWiki extension ? See - http://meta.wikimedia.org/wiki/ParserFunctions
Many thanks ATB Paul
Ignore the rest of this page as it won't work without ParserFunctions
Some results from parser function parameters:
If Tests
If tests look to be working ok.
ifeq
{{#ifeq:{{lc:AbC}}|abc|yes}} should evaluate to 'yes'
Result = yes
{{#ifeq:banana|abc|true|false}} should evaluate to 'false'
Result = false
{{#ifeq:yellow|yellow|true|false}} should evaluate to 'true'
Result = true
ifexpr
{{#ifexpr: 10 > 9 | yes | no}} should evaluate to 'yes'
Result = yes.
{{#ifexpr: 9 > 10 | yes | no}} should evaluate to 'no'
Result = no.
| Operator | Operation | Example | Result |
|---|---|---|---|
| none | {{ #expr: 123456789012345 }} | 1.2345678901234E+14 | |
| {{ #expr: 0.000001 }} | 1.0E-6 | ||
| Arithmetic | |||
| + | Unary positive sign | {{ #expr: +30 * +7 }} | 210 |
| - | Unary negative sign | {{ #expr: -30 * -7 }} | 210 |
| * | Multiplication | {{ #expr: 30 * 7 }} | 210 |
| / div |
Division | {{ #expr: 30 / 7 }} {{ #expr: 30 div 7 }} |
4.2857142857143 4.2857142857143 |
| + | Addition | {{ #expr: 30 + 7 }} | 37 |
| - | Subtraction | {{ #expr: 30 - 7 }} | 23 |
| Logic | |||
| not | Unary NOT logical NOT |
{{ #expr: not 0 * 7 }} {{ #expr: not 30 + 7 }} |
7 7 |
| and | Logical AND |
{{ #expr: 4 < 5 and 4 mod 2 }} |
0 |
| or | Logical OR |
{{ #expr: 4 < 5 or 4 mod 2 }} |
1 |
| Comparison | |||
| = | Equality (numerical & logical) | {{ #expr: 30 = 7 }} | 0 |
| <> != |
Inequality, logical exclusive or | {{ #expr: 30 <> 7 }} {{ #expr: 1 != 0 }} |
1 1 |
| < | Less than |
{{ #expr: 30 < 7 }} |
0 |
| > | Greater than |
{{ #expr: 30 > 7 }} |
1 |
| <= | Less than or equal to |
{{ #expr: 30 <= 7 }} |
0 |
| >= | Greater than or equal to |
{{ #expr: 30 >= 7 }} |
1 |
| Other | |||
| ( ) | Grouping operators | {{ #expr: (30 + 7) * 7 }} | 259 |
| mod | "Modulo" truncates the numbers to whole numbers, divides the left number by the right, and returns the remainder that could not be divided. Note: div and mod are different from all programming languages. |
{{ #expr: 30 mod 7 }} {{ #expr: -8 mod -3 }} {{ #expr: 8 mod 2.7 }} |
2 -2 0 |
| round | Rounds off the number on the left to the power of 1/10 given on the right. | {{ #expr: 30 / 7 round 4 }} {{ #expr: 30 / 7 round 1 }} {{ #expr: 1911 round -2 }} {{ #expr: -2.5 round 0 }} |
4.2857 4.3 1900 -3 |
To Investigate
May require other template(s). Though AFAIK I don't need these. ;-)
{{#len:string}} for string = 123456789 should evaluate to '9' Result = {{#len:123456789}}
{{#pos:string|target|offset}} should evaluate to '10' Result = {{#pos:blah blah target in string|target|offset}}
Table Row Test
I'll need to remove my workaround attempts.
Prefix Data not passed
| Test | Parameters | Result |
| #if: | row_1_v {{{row_1_v}}} equals | true |
| #if: | row_2_v {{{row_2_v}}} equals | true |
| #ifeq: | row_1_v {{{row_1_v}}} equals | row_1_v {{{row_1_v}}} |
| #ifeq: | row_1_v {{{row_1_v}}} does not equal | row_2_v {{{row_2_v}}} |
Suffix Data not passed