Updated README with better build info
[debian/pforth] / fth / t_locals.fth
1 \ @(#) t_locals.fth 97/01/28 1.1
2 \ Test PForth LOCAL variables.
3 \
4 \ Copyright 1996 3DO, Phil Burk
5
6 include? }T{  t_tools.fth
7
8 anew task-t_locals.fth
9 decimal
10
11 test{
12
13 \ test value and locals
14 T{ 333 value  my-value   my-value }T{  333 }T
15 T{ 1000 -> my-value   my-value }T{ 1000 }T
16 T{ 35 +-> my-value   my-value }T{ 1035 }T
17 T{ 987 to my-value   my-value }T{ 987 }T
18 : test.value  ( -- ok )
19     100 -> my-value
20     my-value 100 =
21     47 +-> my-value
22     my-value 147 = AND
23 ;
24 T{ test.value }T{ TRUE }T
25
26 \ test compile time behavior of a VALUE
27 567 value VAL3 immediate
28 : VD3 val3 literal ;
29 T{ vd3 }T{ 567 }T
30
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
41 T{ 200 59 test.locs }T{  TRUE }T
42
43 .( Test warning when no locals defined.) cr
44 : loc.nonames { -- } 1234 ;
45 T{ 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
55 T{ 5 20 calc.area }T{ 100 }T
56
57 }test
58