@c Created Wed Mar 31 15:13:01 2010 by ./../gri2texi from tst_rpn.gri.gri
@example
show "doc/tst_suite/tst_rpn.gri     ..." ...
rpnfunction same - abs 1e-5 >		@emph{#  Are numbers virtually same?}
# Simple arithmetic
.a. = 0
assert @{rpn .a. !@}			  " failed test 1.1"
.a. += 1
assert .a.				  " failed test 1.2"
.a. += 1
assert @{rpn .a. 2 same@}			  " failed test 1.3"
.a. *= 2
assert @{rpn .a. 4 same@}			  " failed test 1.4"
.a. /= 4
assert @{rpn .a. 1 same@}			  " failed test 1.5"
assert @{rpn 2 1 - 1 same@}                 " failed test 1.6"
assert @{rpn 2 1 + 3 same@}                 " failed test 1.7"
assert @{rpn 3 2 * 6 same@}                 " failed test 1.8"
assert @{rpn 4 2 / 2 same@}                 " failed test 1.9"


# Conversions (lower-case ok on input, but output is upper-case)
assert @{rpn "aa" hex2dec  170 ==@}         " failed test 2.1"
assert @{rpn "AB" hex2dec  171 ==@}         " failed test 2.2"
assert @{rpn  63  dec2hex "3F" ==@}         " failed test 2.3"
assert @{rpn 193  dec2hex "C1" ==@}         " failed test 2.4"

# Logic
assert @{rpn 1 0 or@}                       " failed test 3.1"
assert @{rpn 0 1 or@}                       " failed test 3.2"
assert @{rpn 1 0 |@}                        " failed test 3.3"
assert @{rpn 0 1 |@}                        " failed test 3.4"
assert @{rpn 1 0 and not@}                  " failed test 3.5"
assert @{rpn 1 0 & !@}                      " failed test 3.6"

# Logs, powers
.a. _= 10
assert @{rpn .a. 0 same@}			  " failed test 4.1"
.a. = 2
.a. ^= 8
assert @{rpn .a. 256 same@}		  " failed test 4.2"
assert @{rpn -2 4 power 16 ==@}             " failed test 4.3"
assert @{rpn -2 3 power -8 ==@}             " failed test 4.4"
assert @{rpn -2 2 power  4 ==@}             " failed test 4.5"
assert @{rpn  2 3 power  8 ==@}             " failed test 4.6"


# String operations
\a = @{rpn "file" ".dat" strcat@}
assert @{rpn "\a" "file.dat" ==@}		  " failed test 5.1"
\sentence = "This sentence has five words"
\w1 = word 0 of "\sentence "
assert @{rpn "\w1" "This" ==@}		  " failed test 5.2"
\w2 = word 1 of "\sentence "
assert @{rpn "\w2" "sentence" ==@}	  " failed test 5.3"
assert @{rpn 0 4 "hello" substr "hell" ==@} " failed test 5.4"
# Q: will the below work on all OS?????
# NB. better to switch with something more universal
\six = system "date | wc | awk '@{print $2@}'"
assert @{rpn \six 6 ==@}			  " failed test 6.1"

# Statistical operations
read columns x
1 
3
2
9
3

assert @{rpn x mean     3.6      same@}     " failed test 7.1"
assert @{rpn x stddev   3.1305   same@}     " failed test 7.2"
assert @{rpn x skewness 0.882432 same@}     " failed test 7.3"
assert @{rpn x kurtosis 1.88008  same@}     " failed test 7.4"

# ----------- FILL IN LATER -----------------
# Math functions (e.g. sin, ...)
# Stack operations  push, pop, and exch.
assert @{rpn 45 cos 0.7071 same@}           " failed test 8.1"
assert @{rpn 45 sin 0.7071 same@}           " failed test 8.2"
assert @{rpn 45 tan 1      same@}           " failed test 8.3"
# Missing-values
set missing value -99
read .x. .y.
1 -99
assert @{rpn .y. ismissing@}                " failed test 9.1"
assert @{rpn .y. -99 ==   @}                " failed test 9.2"
assert @{rpn .y. -99 !=  !@}                " failed test 9.3"
assert @{rpn .y.   0 !=   @}                " failed test 9.4"
# some boolean tests need not check that both values exist
assert @{rpn .y.   0  &  !@}                " failed test 9.5"
assert @{rpn  0   .y. &  !@}                " failed test 9.6"
assert @{rpn .y.   1  &   @}                " failed test 9.7"
assert @{rpn .y.   1  |   @}                " failed test 9.8"
assert @{rpn  1   .y. |   @}                " failed test 9.9"
@strong{@strong{if}} @{rpn .y. -99 !=@}
    show                                  " failed test 9.10"
end @strong{if}
	    
show " passed"
@end example
