Initial structure for the perform_math_operation function.
This commit is contained in:
@@ -2,3 +2,8 @@ Early termination
|
||||
-----------------
|
||||
|
||||
If the math helper has a body then it stops rendering conditionals after the first conditional that returns true. Rendering an else block does not cause early termination, but else blocks are rendered.
|
||||
|
||||
Non-number values
|
||||
-----------------
|
||||
|
||||
If the math operation involves non-numbers, NaN is returned.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
{
|
||||
"number_7": 7,
|
||||
"string_7": "7",
|
||||
"string_cat": "cat"
|
||||
"string_cat": "cat",
|
||||
"add_operation": "add",
|
||||
"a_operation": "a"
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ Bodiless math{~n}
|
||||
{@math key=number_7 method="add" operand="4" /}{~n}
|
||||
{@math key=string_7 method="add" operand="4" /}{~n}
|
||||
{@math key=string_cat method="add" operand="4" /}{~n}
|
||||
{@math key=string_cat method="add" operand="foo" /}{~n}
|
||||
|
||||
Math with body: dot reference{~n}
|
||||
============================={~n}
|
||||
@@ -44,15 +45,67 @@ Math with body: standalone else block{~n}
|
||||
Math with body: early termination{~n}
|
||||
============================={~n}
|
||||
{@math key="7" method="add" operand="4"}
|
||||
{@eq value=11}math result is 11{:else}math result is not 11{/eq}{~n}
|
||||
{@eq value=11}math result is 11{:else}math result is not 11{/eq}{~n}
|
||||
{@eq value=11}math result is 11{~n}{:else}math result is not 11{~n}{/eq}
|
||||
{@eq value=11}math result is 11{~n}{:else}math result is not 11{~n}{/eq}
|
||||
{/math}
|
||||
|
||||
Math with body: early termination else block{~n}
|
||||
============================================{~n}
|
||||
{@math key="7" method="add" operand="4"}
|
||||
{@eq value=12}math result is 12{:else}math result is not 12{/eq}{~n}
|
||||
{@eq value=11}math result is 11{:else}math result is not 11{/eq}{~n}
|
||||
{@eq value=12}math result is 12{:else}math result is not 12{/eq}{~n}
|
||||
{@eq value=12}math result is 12{~n}{:else}math result is not 12{~n}{/eq}
|
||||
{@eq value=11}math result is 11{~n}{:else}math result is not 11{~n}{/eq}
|
||||
{@eq value=12}math result is 12{~n}{:else}math result is not 12{~n}{/eq}
|
||||
{/math}
|
||||
|
||||
|
||||
Math with body: any{~n}
|
||||
==================={~n}
|
||||
{@math key="7" method="add" operand="4"}
|
||||
{@eq value=10}math result is 10{~n}{:else}math result is not 10{~n}{/eq}
|
||||
{@eq value=11}math result is 11{~n}{:else}math result is not 11{~n}{/eq}
|
||||
{@eq value=12}math result is 12{~n}{:else}math result is not 12{~n}{/eq}
|
||||
{@any}We found the value{~n}{/any}
|
||||
{@none}We did not find the value{~n}{/none}
|
||||
{/math}
|
||||
|
||||
Math with body: none{~n}
|
||||
===================={~n}
|
||||
{@math key="7" method="add" operand="4"}
|
||||
{@eq value=10}math result is 10{~n}{:else}math result is not 10{~n}{/eq}
|
||||
{@eq value=12}math result is 12{~n}{:else}math result is not 12{~n}{/eq}
|
||||
{@any}We found the value{~n}{/any}
|
||||
{@none}We did not find the value{~n}{/none}
|
||||
{/math}
|
||||
|
||||
Math where method is a reference{~n}
|
||||
================================{~n}
|
||||
{@math key="7" method=add_operation operand="4" /}{~n}
|
||||
|
||||
Math where method is a template{~n}
|
||||
==============================={~n}
|
||||
{@math key="7" method="{a_operation}dd" operand="4" /}{~n}
|
||||
|
||||
Math where key is a template{~n}
|
||||
============================{~n}
|
||||
{@math key="{string_7}1" method="add" operand="4" /}{~n}
|
||||
|
||||
Math where method is absent{~n}
|
||||
============================{~n}
|
||||
{@math key="7" operand="4" /}{~n}
|
||||
|
||||
Math where method is missing{~n}
|
||||
============================{~n}
|
||||
{@math key="7" method=foobar operand="4" /}{~n}
|
||||
|
||||
Math with unknown method{~n}
|
||||
========================{~n}
|
||||
{@math key="7" method="twirl" operand="4" /}{~n}
|
||||
|
||||
Math with body where method is absent{~n}
|
||||
===================================={~n}
|
||||
{@math key="7" operand="4"}
|
||||
{@eq value=12}math result is 12{~n}{:else}math result is not 12{~n}{/eq}
|
||||
{@any}We found the value{~n}{/any}
|
||||
{@none}We did not find the value{~n}{/none}
|
||||
plain text not inside a tag{~n}
|
||||
{/math}
|
||||
|
||||
Reference in New Issue
Block a user