Merge pull request #75 from SeekingMeaning/0BSD
[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
f849a7b8 17T{ 987 to my-value my-value }T{ 987 }T
8e9db35f
PB
18: test.value ( -- ok )
19 100 -> my-value
20 my-value 100 =
21 47 +-> my-value
22 my-value 147 = AND
23;
24T{ test.value }T{ TRUE }T
25
f849a7b8
PB
26\ test compile time behavior of a VALUE
27567 value VAL3 immediate
28: VD3 val3 literal ;
29T{ vd3 }T{ 567 }T
30
8e9db35f
PB
31\ test locals in a word
32: test.locs { aa bb | cc -- ok }
33 cc 0=
34 aa bb + -> cc
35 aa bb + cc = AND
36 aa -> cc
37 bb +-> cc
38 aa bb + cc = AND
39;
40
41T{ 200 59 test.locs }T{ TRUE }T
42
43.( Test warning when no locals defined.) cr
44: loc.nonames { -- } 1234 ;
45T{ loc.nonames }T{ 1234 }T
46
47\ try to put EOLs and comments in variable list
48: calc.area {
49 width \ horizontal dimension
50 height \ vertical dimension
51 -- area , calculate area of a rectangle }
52 width height *
53;
54
55T{ 5 20 calc.area }T{ 100 }T
56
57}test
58