You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
472 B
25 lines
472 B
# A stresstest for the expression evaluation engine
|
|
|
|
alias(exprtest)
|
|
{
|
|
%txt = "Testing expression:" $0;
|
|
|
|
%ret = ${ eval "return \$(" $0 ")"; }
|
|
if(%ret != $1)
|
|
{
|
|
%txt .= " ... Failed (return value" %ret "!=" $1")";
|
|
echo %txt
|
|
} else {
|
|
%txt .= " ... Success (return value $1)";
|
|
echo %txt
|
|
}
|
|
}
|
|
|
|
exprtest "5 - 0 - 1" 4
|
|
exprtest "5 - (0 - 1)" 6
|
|
exprtest "2+3-5+3+1-2-3-8+5*3-2" 4
|
|
exprtest "2*2 + 2*2 - 2*2" 4
|
|
exprtest "-1" -1
|
|
exprtest "--1--1" 2
|
|
exprtest "-1+1" -2
|