Simplify VALUE
[pforth] / fth / t_locals.fth
CommitLineData
8e9db35f
PB
1\ @(#) t_locals.fth 97/01/28 1.1
2\ Test PForth LOCAL variables.
3\
4\ Copyright 1996 3DO, Phil Burk
5
6include? }T{ t_tools.fth
7
8anew task-t_locals.fth
9decimal
10
11test{
12
13\ test value and locals
14T{ 333 value my-value my-value }T{ 333 }T
15T{ 1000 -> my-value my-value }T{ 1000 }T
16T{ 35 +-> my-value my-value }T{ 1035 }T
17: test.value ( -- ok )
18 100 -> my-value
19 my-value 100 =
20 47 +-> my-value
21 my-value 147 = AND
22;
23T{ test.value }T{ TRUE }T
24
25\ test locals in a word
26: test.locs { aa bb | cc -- ok }
27 cc 0=
28 aa bb + -> cc
29 aa bb + cc = AND
30 aa -> cc
31 bb +-> cc
32 aa bb + cc = AND
33;
34
35T{ 200 59 test.locs }T{ TRUE }T
36
37.( Test warning when no locals defined.) cr
38: loc.nonames { -- } 1234 ;
39T{ loc.nonames }T{ 1234 }T
40
41\ try to put EOLs and comments in variable list
42: calc.area {
43 width \ horizontal dimension
44 height \ vertical dimension
45 -- area , calculate area of a rectangle }
46 width height *
47;
48
49T{ 5 20 calc.area }T{ 100 }T
50
51}test
52