Change Devid to David in copyright statements.
[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 : test.value  ( -- ok )
18     100 -> my-value
19     my-value 100 =
20     47 +-> my-value
21     my-value 147 = AND
22 ;
23 T{ 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
35 T{ 200 59 test.locs }T{  TRUE }T
36
37 .( Test warning when no locals defined.) cr
38 : loc.nonames { -- } 1234 ;
39 T{ 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
49 T{ 5 20 calc.area }T{ 100 }T
50
51 }test
52