]>
Commit | Line | Data |
---|---|---|
bac41a7b A |
1 | -- .../asn1specs/err_test.asn1 |
2 | -- | |
3 | -- This module exercises snacc's semantic error checking of ASN.1 types. | |
4 | -- Every line that has the "error" comment should cause snacc to produce | |
5 | -- at least one error message | |
6 | -- | |
7 | -- Mike Sample 92/07 | |
8 | -- | |
a66d0d4a | 9 | -- $Header: /cvs/root/Security/SecuritySNACCRuntime/asn1specs/Attic/err-test.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $ |
bac41a7b A |
10 | -- $Log: err-test.asn1,v $ |
11 | -- Revision 1.1.1.1 2001/05/18 23:14:05 mb | |
12 | -- Move from private repository to open source repository | |
13 | -- | |
14 | -- Revision 1.1.1.1 1999/03/16 18:05:55 aram | |
15 | -- Originals from SMIME Free Library. | |
16 | -- | |
17 | -- Revision 1.3 1995/07/25 19:53:16 rj | |
18 | -- changed `_' to `-' in file names. | |
19 | -- | |
20 | -- Revision 1.2 1994/08/28 09:54:17 rj | |
21 | -- comment leader fixed. | |
22 | -- | |
23 | -- Revision 1.1 1994/08/28 09:51:13 rj | |
24 | -- first check-in. | |
25 | ||
26 | ERROR-TEST DEFINITIONS ::= | |
27 | BEGIN | |
28 | ||
29 | ||
30 | -- first check that CHOICEs and SETs without distinct tags | |
31 | -- cause error msgs | |
32 | ||
33 | AChoice ::= CHOICE -- error | |
34 | { | |
35 | f1 [0] INTEGER, -- these two have the same | |
36 | f2 [0] INTEGER, -- tags | |
37 | f3 INTEGER, -- the tag of f3 | |
38 | f4 AChoice3 -- conflicts with one of AChoice3's elmt tags | |
39 | } | |
40 | ||
41 | ASet ::= SET -- error | |
42 | { | |
43 | f1 [0] INTEGER, -- same [0] tags | |
44 | f2 [0] INTEGER | |
45 | } | |
46 | ||
47 | ||
48 | T1 ::= INTEGER | |
49 | T2 ::= BOOLEAN | |
50 | ||
51 | AChoice2 ::= CHOICE -- error | |
52 | { | |
53 | T1, | |
54 | INTEGER | |
55 | } | |
56 | ||
57 | ASet2 ::= SET -- error | |
58 | { | |
59 | T2, | |
60 | BOOLEAN | |
61 | } | |
62 | ||
63 | AChoice3 ::= CHOICE | |
64 | { | |
65 | T1, | |
66 | T2 | |
67 | } | |
68 | ||
69 | ||
70 | -- | |
71 | -- now check that Sequence have distinct tags | |
72 | -- on one or consective optional elmts and following (if any) | |
73 | -- non-optional elmt | |
74 | -- | |
75 | ||
76 | ASequence ::= SEQUENCE -- no errors | |
77 | { | |
78 | f1 [0] INTEGER, | |
79 | f2 [0] BOOLEAN | |
80 | } | |
81 | ||
82 | ASequence1 ::= SEQUENCE | |
83 | { | |
84 | INTEGER OPTIONAL, | |
85 | INTEGER OPTIONAL, -- error, ambiguous values possible | |
86 | INTEGER, -- error | |
87 | INTEGER | |
88 | } | |
89 | ||
90 | ASequence3 ::= SEQUENCE | |
91 | { | |
92 | f1 [0] OBJECT IDENTIFIER OPTIONAL, | |
93 | f2 [1] INTEGER OPTIONAL, | |
94 | f3 [0] BOOLEAN, -- error | |
95 | f4 [2] OCTET STRING OPTIONAL, | |
96 | f5 [2] BIT STRING OPTIONAL, -- error | |
97 | f6 [3] ASequence OPTIONAL, | |
98 | f7 [3] INTEGER, -- error | |
99 | f8 [4] BOOLEAN OPTIONAL, | |
100 | f9 [4] INTEGER OPTIONAL -- error | |
101 | } | |
102 | ||
103 | ||
104 | ||
105 | -- | |
106 | -- now check that duplicate APPLICATION tag errors are reported | |
107 | -- | |
108 | Foo1 ::= [APPLICATION 0] INTEGER | |
109 | Foo2 ::= [APPLICATION 1] INTEGER | |
110 | ||
111 | Bar1 ::= [APPLICATION 0] IMPLICIT INTEGER -- error | |
112 | Bar2 ::= [APPLICATION 1] IMPLICIT INTEGER -- error | |
113 | ||
114 | -- | |
115 | -- check that field name errors are reported | |
116 | -- | |
117 | ||
118 | AChoice4 ::= CHOICE | |
119 | { | |
120 | f1 INTEGER, | |
121 | f2 BOOLEAN, | |
122 | [0] AChoice4 | |
123 | } | |
124 | ||
125 | ASet3 ::= SET | |
126 | { | |
127 | f1 [0] INTEGER, | |
128 | f2 [1] INTEGER, | |
129 | f3 [2] BOOLEAN, | |
130 | f3 [3] BOOLEAN, -- error, field name conflict | |
131 | [4] AChoice4 -- error, field name conflict too | |
132 | } | |
133 | ||
134 | ||
135 | -- | |
136 | -- now check some recursive type related errors | |
137 | -- | |
138 | ||
139 | A2 ::= A2 -- error | |
140 | ||
141 | A1 ::= B1 -- error | |
142 | B1 ::= A1 -- error | |
143 | ||
144 | C1 ::= D1 -- error | |
145 | D1 ::= E1 -- error | |
146 | E1 ::= F1 -- error | |
147 | F1 ::= C1 -- error | |
148 | ||
149 | RecSeq ::= SEQUENCE | |
150 | { | |
151 | INTEGER, | |
152 | BOOLEAN, | |
153 | RecSeq, -- warning, infinitely large values? | |
154 | RecSeq OPTIONAL -- this should be ok 'cause it's optional | |
155 | } | |
156 | ||
157 | ||
158 | -- | |
159 | -- now check some named bit and named number related errors | |
160 | -- | |
161 | aVal INTEGER ::= -4 | |
162 | ||
163 | Enum1 ::= ENUMERATED { zero(0), one(1), two(2), one(0) } -- 2 errors | |
164 | ||
165 | Int1 ::= INTEGER { zero(0), one(1), two(2), yoyo(2), one(7), foo(aVal) } -- 2 errors | |
166 | ||
167 | Bits1 ::= BIT STRING { zero(0), one(1), two(2), one(4), foo(-2), pogo(0), | |
168 | gogo(aVal) } -- 4 errors | |
169 | ||
170 | ||
171 | ||
172 | -- | |
173 | -- now check that implicitly tagged CHOICE, ANY and ANY DEFINED BY | |
174 | -- cause error msgs | |
175 | -- | |
176 | BChoice1 ::= [APPLICATION 5] IMPLICIT CHOICE -- error | |
177 | { | |
178 | INTEGER, | |
179 | BOOLEAN | |
180 | } | |
181 | ||
182 | BChoice2 ::= CHOICE -- no error | |
183 | { | |
184 | INTEGER, | |
185 | BOOLEAN | |
186 | } | |
187 | ||
188 | BChoice3 ::= [APPLICATION 6] CHOICE -- no error | |
189 | { | |
190 | INTEGER, | |
191 | BOOLEAN | |
192 | } | |
193 | ||
194 | BSeq ::= SEQUENCE | |
195 | { | |
196 | INTEGER, | |
197 | BOOLEAN, | |
198 | [0] IMPLICIT BChoice2, -- error | |
199 | [1] IMPLICIT BChoice3, -- no error | |
200 | [2] IMPLICIT CHOICE {INTEGER, BOOLEAN} -- error | |
201 | } | |
202 | ||
203 | ||
204 | -- | |
205 | -- now test that errors are reported for multiply defined | |
206 | -- types and valus | |
207 | -- | |
208 | ||
209 | TypeCopy1 ::= INTEGER | |
210 | TypeCopy1 ::= BOOLEAN | |
211 | TypeCopy1 ::= INTEGER | |
212 | ||
213 | valCopy1 INTEGER ::= 1 | |
214 | valCopy1 BOOLEAN ::= TRUE | |
215 | valCopy1 INTEGER ::= 1 | |
216 | ||
217 | ||
218 | -- | |
219 | -- test some OBJECT IDENTIFER value errors | |
220 | -- | |
221 | ||
222 | oid1 OBJECT IDENTIFIER ::= { oid1 ms(1) 1 } -- error: recursive value | |
223 | oid2 OBJECT IDENTIFIER ::= { oid1 ms(1) 2 } | |
224 | ||
225 | -- error: can only ref other oid values from first arc | |
226 | oid3 OBJECT IDENTIFIER ::= { ms(1) oid2 2 } | |
227 | ||
228 | boolVal BOOLEAN ::= TRUE | |
229 | intVal1 INTEGER ::= 1 | |
230 | intVal2 INTEGER ::= -1 | |
231 | oid4 OBJECT IDENTIFIER ::= { oid2 intVal1 intVal2 boolVal 1} | |
232 | ||
233 | oid5 OBJECT IDENTIFIER ::= { 1 2 -4} | |
234 | ||
235 | oid6 OBJECT IDENTIFIER ::= { oid7 1} | |
236 | oid7 OBJECT IDENTIFIER ::= { oid6 1 } | |
237 | END |