File: eval.hsc

package info (click to toggle)
hsc 0.916-2
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 2,584 kB
  • ctags: 2,277
  • sloc: ansic: 17,375; makefile: 396
file content (136 lines) | stat: -rw-r--r-- 4,423 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD><TITLE>check operators</TITLE></HEAD><BODY>

<**************************************
 *                                    *
 * test string constants              *
 *                                    *
 **************************************>
<$define susi:string>
<$let susi=susi><(susi)>
<$let susi="susi-double"><(susi)>
<$let susi='susi-single'><(susi)>
<$let susi=("susi-double-in-brackets")><(susi)>
<$let susi=(susi)><(susi)>

<**************************************
 *                                    *
 * test string operators              *
 *                                    *
 **************************************>

<**************************************
 * checkIn                            *
 **************************************>
<$macro checkIn little:string/r big:string/r>
<$if cond=(little IN big)>IN<$else>-NOT IN</$if>
</$macro>

<checkin little="sepp" big="hugo resi sepp">
<checkin little="SepP" big="hugo resi sepp">
<checkin little="hinz" big="hugo resi sepp">

<**************************************
 * checkConcat                        *
 **************************************>
<$macro CheckConcat v1:string/r v2:string/r vu:string/r>
<$define vc:string=(v1+v2)><$stripws type=prev>
[<(v1)>] + [<(v2)>] = [<(vc)>] = [<(vu)>]
<$if cond=(vu<>vc)><$stripws type=prev> ERROR!</$if>
</$macro>

<CheckConcat v1="" v2="" vu="">
<CheckConcat v1='' v2='' vu=''>
<CheckConcat v1="hugo " v2="ist doof" vu="hugo ist doof">
<CheckConcat v1=("hugo "+"ist ") v2="doof" vu="hugo ist doof">

<$let susi="susi">
<$let susi=(susi+" and sepp")><(susi)>
<$let susi=("hugo, "+susi)><(susi)>

<**************************************
 *                                    *
 * test boolean operators             *
 *                                    *
 **************************************>

<**************************************
 * printBool:                         *
 * insert boolean value as "0" or "1" *
 **************************************>
<$macro printBool v:bool><$if cond=(v)>1<$else>0</$if></$macro>

<**************************************
 * check boolean function, 2 operands *
 *                                    *
 * inputs:                            *
 *   v1, v2...boolean operands        *
 *   vc.......result (computed)       *
 *   vu.......result (user suggestion)*
 **************************************>
<$macro checkBool2 v1:bool v2:bool op:string vu:bool>
<$define vc:bool>
<("<$let vc=(v1 "+op+" v2)>")><$stripws type=prev>
<printBool v=(v1)>*<printBool v=(v2)>=<printBool v=(vc)>=<printBool v=(vu)>
<$if cond=(vc xor vu)><$stripws type=prev>  ERROR!</$if>
</$macro>

CheckBool2: error handling
<checkBool2 v1 v2 op=and>

<**************************************
 * check AND,OR,XOR with 2 operands   *
 **************************************>
Check AND (2):
<checkBool2       op=and   >
<checkBool2    v2 op=and   >
<checkBool2 v1    op=and   >
<checkBool2 v1 v2 op=and vu>

Check OR (2):
<checkBool2       op=or   >
<checkBool2    v2 op=or vu>
<checkBool2 v1    op=or vu>
<checkBool2 v1 v2 op=or vu>

Check XOR (2):
<checkBool2       op=xor   >
<checkBool2    v2 op=xor vu>
<checkBool2 v1    op=xor vu>
<checkBool2 v1 v2 op=xor   >

<**************************************
 *                                    *
 * test numeric operators             *
 *                                    *
 **************************************>

<**************************************
 * check numeric function, 2 operands *
 *                                    *
 * inputs:                            *
 *   v1, v2...numeric operands        *
 *   vc.......result (computed)       *
 *   vu.......result (user suggestion)*
 **************************************>
<$macro checkNumeric2 v1:num/r v2:num/r op:string vu:num/r>
<$define vc:num>
<("<$let vc=(v1 "+op+" v2)>")><$stripws type=prev>
<(v1)> <(op)> <(v2)> = <(vc)> = <(vu)>
<$if cond=(vc<>vu)><$stripws type=prev>  ERROR!</$if>
</$macro>

CheckNumeric2: error handling
<checkNumeric2 v1=1 v2=2 op="+" vu=17>

<**************************************
 * check numeric with 2 operands      *
 **************************************>
Check "+" (2):
<checkNumeric2 v1="1"  v2="2"  op="+" vu="3">
<checkNumeric2 v1="1"  v2="-2" op="+" vu="-1">
<checkNumeric2 v1="-1" v2="2"  op="+" vu="1">
<checkNumeric2 v1="-1" v2="-2" op="+" vu="-3">

</BODY></HTML>