Root/b2/test/hierrul

1#!/bin/bash
2. ./Common
3
4#
5# Note: the hierarchy dump differs in some details from the input format.
6# Its main purpose is to aid with debugging, not to produce a syntactically
7# valid representation of the currently loaded hierarchy.
8#
9
10###############################################################################
11
12tst "hierarchy: name rule" -dh <<EOF
13Animal=* {
14    Cat: { X=* };
15    Dog: { Y=* };
16};
17EOF
18
19expect <<EOF
20Animal=* {
21    Cat: { X=* }
22    Dog: { Y=* }
23}
24EOF
25
26#------------------------------------------------------------------------------
27
28tst "hierarchy: name set rule" -dh <<EOF
29<predation> = mouse<cat<dog;
30p = <predation> {
31    mouse: { X=* };
32    cat: { Y=* };
33    dog: { Z=* };
34};
35EOF
36
37expect <<EOF
38p=<predation> {
39    mouse: { X=* }
40    cat: { Y=* }
41    dog: { Z=* }
42}
43EOF
44
45#------------------------------------------------------------------------------
46
47tst_fail "hierarchy: name set rule (invalid value)" <<EOF
48<predation> = mouse<cat<dog;
49p = <predation> {
50    mouse: { X=* };
51    cat: { Y=* };
52    boat: { Z=* };
53};
54EOF
55
56expect <<EOF
57h:6: invalid value in selection
58EOF
59
60#------------------------------------------------------------------------------
61
62tst "hierarchy: name set rule (duplicate entry)" -dh <<EOF
63<predation> = mouse<cat<dog;
64p = <predation> {
65    mouse: { X=* };
66    cat: { Y=* };
67    cat: { Z=* };
68};
69EOF
70
71expect <<EOF
72h:6: warning: unreachable condition
73p=<predation> {
74    mouse: { X=* }
75    cat: { Y=* }
76    cat: { Z=* }
77}
78EOF
79
80#------------------------------------------------------------------------------
81
82tst "hierarchy: absolute value rule (with unit)" -dh <<EOF
83<predation> = mouse<cat<dog;
84N=#R {
85    10R: { X=* };
86    10k: { Y=* };
87    1.2R: { Z=* };
88};
89EOF
90
91expect <<EOF
92N=#R {
93    10R: { X=* }
94    10000R: { Y=* }
95    1.2R: { Z=* }
96}
97EOF
98
99#------------------------------------------------------------------------------
100
101tst "hierarchy: absolute value rule (without unit)" -dh <<EOF
102<predation> = mouse<cat<dog;
103N=## {
104    2: { X=* };
105    5k: { Y=* };
106    3.1: { Z=* };
107};
108EOF
109
110expect <<EOF
111N=## {
112    2: { X=* }
113    5000: { Y=* }
114    3.1: { Z=* }
115}
116EOF
117
118#------------------------------------------------------------------------------
119
120tst_fail "hierarchy: absolute value rule (different unit)" <<EOF
121<predation> = mouse<cat<dog;
122N=#R {
123    1.0A: { X=* };
124};
125EOF
126
127expect <<EOF
128h:4: invalid value in selection
129EOF
130
131#------------------------------------------------------------------------------
132
133tst_fail "hierarchy: absolute value rule (letter-as-decimal syntax)" <<EOF
134<predation> = mouse<cat<dog;
135N=#R {
136    1k2: { X=* };
137};
138EOF
139
140expect <<EOF
141h:4: invalid value in selection
142EOF
143
144#------------------------------------------------------------------------------
145
146tst "hierarchy: relative value rule (percent)" -dh <<EOF
147{ V=#R }
148TOL=%V {
149    1%: { X=* };
150    1.2%: { Y=* };
151};
152EOF
153
154expect <<EOF
155{ V=#R }
156TOL=%R {
157    -1/+1%: { X=* }
158    -1.2/+1.2%: { Y=* }
159}
160EOF
161
162#------------------------------------------------------------------------------
163
164tst "hierarchy: relative value rule (absolute, with unit)" -dh <<EOF
165{ V=#R }
166TOL=%V {
167    1R: { X=* };
168    1kR: { Y=* };
169};
170EOF
171
172expect <<EOF
173{ V=#R }
174TOL=%R {
175    -1/+1R: { X=* }
176    -1000/+1000R: { Y=* }
177}
178EOF
179
180#------------------------------------------------------------------------------
181
182tst "hierarchy: relative value rule (absolute, without unit)" -dh <<EOF
183{ V=## }
184TOL=%V {
185    1: { X=* };
186    1k: { Y=* };
187};
188EOF
189
190expect <<EOF
191{ V=## }
192TOL=%# {
193    -1/+1: { X=* }
194    -1000/+1000: { Y=* }
195}
196EOF
197
198#------------------------------------------------------------------------------
199
200tst "hierarchy: relative value rule (plus/minus percent)" -dh <<EOF
201{ V=#R }
202TOL=%V {
203    +10/-20%: { X=* };
204};
205EOF
206
207expect <<EOF
208{ V=#R }
209TOL=%R {
210    -20/+10%: { X=* }
211}
212EOF
213
214#------------------------------------------------------------------------------
215
216tst "hierarchy: relative value rule (minus/plus percent)" -dh <<EOF
217{ V=#R }
218TOL=%V {
219    -10/+20%: { X=* };
220};
221EOF
222
223expect <<EOF
224{ V=#R }
225TOL=%R {
226    -10/+20%: { X=* }
227}
228EOF
229
230#------------------------------------------------------------------------------
231
232tst "hierarchy: relative value rule (implicit minus/plus percent)" -dh <<EOF
233{ V=#R }
234TOL=%V {
235    10/20%: { X=* };
236};
237EOF
238
239expect <<EOF
240{ V=#R }
241TOL=%R {
242    -10/+20%: { X=* }
243}
244EOF
245
246#------------------------------------------------------------------------------
247
248tst "hierarchy: relative value rule (plus/minus absolute)" -dh <<EOF
249{ V=#R }
250TOL=%V {
251    +10/-20R: { X=* };
252};
253EOF
254
255expect <<EOF
256{ V=#R }
257TOL=%R {
258    -20/+10R: { X=* }
259}
260EOF
261
262#------------------------------------------------------------------------------
263
264tst "hierarchy: relative value rule (minus/plus absolute)" -dh <<EOF
265{ V=#R }
266TOL=%V {
267    -5/+10R: { X=* };
268};
269EOF
270
271expect <<EOF
272{ V=#R }
273TOL=%R {
274    -5/+10R: { X=* }
275}
276EOF
277
278#------------------------------------------------------------------------------
279
280tst "hierarchy: relative value rule (implicit minus/plus absolute)" -dh <<EOF
281{ V=#R }
282TOL=%V {
283    0/10R: { X=* };
284};
285EOF
286
287expect <<EOF
288{ V=#R }
289TOL=%R {
290    -0/+10R: { X=* }
291}
292EOF
293
294#------------------------------------------------------------------------------
295
296tst_fail "hierarchy: relative value rule (unknown field)" <<EOF
297{ V=#R }
298TOL=%X {
299    10%: { Y=* };
300};
301EOF
302
303expect <<EOF
304h:2: unknown field "X"
305EOF
306
307###############################################################################
308

Archive Download this file

Branches:
master



interactive