FitNesse. SuiteAcceptanceTests. SuiteWidgetTests.
TestExpression [add child]

 Scenario Libraries

Expressions using the mark up

Syntax:

 ${= expression =} 


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

Operators supported

Comment Spaces between items are optional
Operator Argument Description
arg
constant or variable Examples: 3 12.4 4E+8 ${VALUE} ${some.var}
expr
expression
Any valid combination of arguments and optional operations and parentheses
+
expr + expr
Addition
-
-expr
Unary negation
-
expr - expr
Subtraction
*
expr * expr
Multiplication
/
expr / expr
Division
^
expr ^ expr
Exponentiation
sin
sin expr
Radian Sine of expr
cos
cos expr
Radian Cosine of expr
tan
cos expr
Radian Tangent of expr
( )
( expr )
Parenthetical grouping of an expression


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

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



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

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



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

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



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

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



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

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