content.txt 6.85 KB
!1 Expressions using the ${= =} mark up
!3 Syntax:
'''{{{ $!--!{= expression =} }}}'''

An expression may be a combination of constants, variables, and opertors.  All internal calculations use the Java ''double'' numeric type.

!3 Operators supported
|Comment       |!note Spaces between items are optional                                                              |
|'''Operator'''|'''Argument'''            |'''Description'''                                                         |
|!c ''arg''    |''constant or variable''  |Examples: 3  12.4  4E+8 $!--!{VALUE} $!--!{some.var}                      |
|!c ''expr''   |!c ''expression''         |Any valid combination of arguments and optional operations and parentheses|
|!c '''+'''    |!c ''expr'' + ''expr''    |Addition                                                                  |
|!c '''-'''    |!c -''expr''              |Unary negation                                                            |
|!c '''-'''    |!c ''expr'' - ''expr''    |Subtraction                                                               |
|!c '''!-*-!'''|!c ''expr'' !-*-! ''expr''|Multiplication                                                            |
|!c '''/'''    |!c ''expr'' / ''expr''    |Division                                                                  |
|!c '''^'''    |!c ''expr'' ^ ''expr''    |Exponentiation                                                            |
|!c '''sin'''  |!c sin ''expr''           |Radian Sine of ''expr''                                                   |
|!c '''cos'''  |!c cos ''expr''           |Radian Cosine of ''expr''                                                 |
|!c '''tan ''' |!c cos ''expr''           |Radian Tangent of ''expr''                                                |
|!c '''( )'''  |!c ( ''expr'' )           |Parenthetical grouping of an expression                                   |
#-----------------------------------------------------------------
-----
!3 Test Blank Expressions
''' Build blank expression page '''
!|script|
|start|Page Builder           |
|line|!- ~1a:${==}~   -!|
|line|!- ~1b:${= =}~  -!|
|line|!- ~1c:${=  =}~ -!|
|page|ExpressionPage    |

''' Render it '''
!|Response Requester|
|uri           |valid?|
|ExpressionPage|true  |

!**> Contents
!|Response Examiner|
|type    |string?|
|contents|       |

!|Response Examiner|
|type    |wrapped html?|
|contents|             |

***!

''' Verify results '''
!|Response Examiner|
|type    |pattern|matches?|
|contents|~1a:~  |true    |
|contents|~1b:~  |true    |
|contents|~1c:~  |true    |

-----
!3 Test Single Argument Expressions
''' Build expression page '''
!|script|
|start|Page Builder                      |
|line|!- ~2a:${=3=}~   -!          |
|line|!- ~2b:${= 4.2 =}~  -!       |
|line|!- ~2c:${= 2E+1 =}~ -!       |
|line|!- ~2d:${=  2.3E+42  =}~ -!  |
|line|!- ~2e:${=  4.2E + 24  =}~ -!|
|page|ExpressionPage               |

''' Render it '''
!|Response Requester|
|uri           |valid?|
|ExpressionPage|true  |

!**> Contents
!|Response Examiner|
|type    |string?|
|contents|       |

!|Response Examiner|
|type    |wrapped html?|
|contents|             |

***!

''' Verify results '''
!|Response Examiner|
|type    |pattern     |matches?|
|contents|~2a:3~      |true    |
|contents|~2b:4.2~    |true    |
|contents|~2c:20~     |true    |
|contents|~2d:2.3E+42~|true    |
|contents|~2e:4.2E+24~|true    |

#-----------------------------------------------------------------
-----
!3 Test spaces around experssions
''' Build expression page '''
!|script|
|start|Page Builder               |
|line|!- ~3a:${=1+1=}~ -!   |
|line|!- ~3b:${=2 + 2=}~ -! |
|line|!- ~3c:${= 3 + 3=}~ -!|
|line|!- ~3d:${=4 + 4 =}~ -!|
|line|!- ~3e:${=5 +5 =}~ -! |
|page|ExpressionPage        |

''' Render it '''
!|Response Requester|
|uri           |valid?|
|ExpressionPage|true  |

!**> Contents
!|Response Examiner|
|type    |string?|
|contents|       |

!|Response Examiner|
|type    |wrapped html?|
|contents|             |

***!

''' Verify results '''
!|Response Examiner|
|type    |pattern|matches?|
|contents|~3a:2~ |true    |
|contents|~3b:4~ |true    |
|contents|~3c:6~ |true    |
|contents|~3d:8~ |true    |
|contents|~3e:10~|true    |

#-----------------------------------------------------------------
-----
!3 Test each operator
''' Build expression page '''
!|script|
|start|Page Builder                                   |
|line|!- ~4plus:${= 1 + 2 =}~     -!            |
|line|!- ~4minus:${= 2 - 3 =}~    -!            |
|line|!- ~4unary:${= -12 =}~      -!            |
|line|!- ~4mult:${= 3 * 4 =}~     -!            |
|line|!- ~4div:${= 4 / 5 =}~      -!            |
|line|!- ~4exp:${=%2d: 5 ^ 6 =}~  -!            |
|line|!- ~4sin1:${=%5.4f: sin0.39269875   =}~ -!|
|line|!- ~4sin2:${=%5.4f: sin 0.39269875  =}~ -!|
|line|!- ~4sin3:${=%5.4f: sin(0.39269875) =}~ -!|
|line|!- ~4sin4:${=%5.4f: sin(3.14159/8)  =}~ -!|
|line|!- ~4sin5:${=%5.4f: sin (3.14159/8) =}~ -!|
|line|!- ~4cos:${=%5.4f: cos(3.14159 / 8) =}~ -!|
|line|!- ~4tan:${=%5.4f: tan(3.14159 / 8) =}~ -!|
|page|ExpressionPage                            |

''' Render it '''
!|Response Requester|
|uri           |valid?|
|ExpressionPage|true  |

!**> Contents
!|Response Examiner|
|type    |string?|
|contents|       |

!|Response Examiner|
|type    |wrapped html?|
|contents|             |

***!

''' Verify results '''
!|Response Examiner|
|type    |pattern       |matches?|
|contents|~4plus:3~     |true    |
|contents|~4minus:-1~   |true    |
|contents|~4unary:-12~  |true    |
|contents|~4mult:12~    |true    |
|contents|~4div:0.8~    |true    |
|contents|~4exp:15625~  |true    |
|contents|~4sin1:0.3827~|true    |
|contents|~4sin2:0.3827~|true    |
|contents|~4sin3:0.3827~|true    |
|contents|~4sin4:0.3827~|true    |
|contents|~4sin5:0.3827~|true    |
|contents|~4cos:0.9239~ |true    |
|contents|~4tan:0.4142~ |true    |

#-----------------------------------------------------------------
-----
!3 Test parentheses
''' Build expression page '''
!|script|
|start|Page Builder                                        |
|line|!- ~5a:${= 2 * 3 + 4 / 2 - 3             =}~ -!|
|line|!- ~5b:${= 2 * ( 3 + 4 ) / 2 - 3         =}~ -!|
|line|!- ~5c:${= 2 * ( 3 + 4 ) / ( 2 - 3 )     =}~ -!|
|line|!- ~5d:${= 2 * ( 3 + ( 4 / ( 2 - 3 ) ) ) =}~ -!|
|page|ExpressionPage                                 |

''' Render it '''
!|Response Requester|
|uri           |valid?|
|ExpressionPage|true  |

!**> Contents
!|Response Examiner|
|type    |string?|
|contents|       |

!|Response Examiner|
|type    |wrapped html?|
|contents|             |

***!

''' Verify results '''
!|Response Examiner|
|type    |pattern |matches?|
|contents|~5a:5~  |true    |
|contents|~5b:4~  |true    |
|contents|~5c:-14~|true    |
|contents|~5d:-2~ |true    |

#-----------------------------------------------------------------
#-----------------------------------------------------------------
#-----------------------------------------------------------------