1 -- .../asn1specs/err_test.asn1
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
9 -- $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/asn1specs/err-test.asn1,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $
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
14 -- Revision 1.1.1.1 1999/03/16 18:05:55 aram
15 -- Originals from SMIME Free Library.
17 -- Revision 1.3 1995/07/25 19:53:16 rj
18 -- changed `_' to `-' in file names.
20 -- Revision 1.2 1994/08/28 09:54:17 rj
21 -- comment leader fixed.
23 -- Revision 1.1 1994/08/28 09:51:13 rj
26 ERROR-TEST DEFINITIONS ::=
30 -- first check that CHOICEs and SETs without distinct tags
33 AChoice ::= CHOICE -- error
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
43 f1 [0] INTEGER, -- same [0] tags
51 AChoice2 ::= CHOICE -- error
57 ASet2 ::= SET -- error
71 -- now check that Sequence have distinct tags
72 -- on one or consective optional elmts and following (if any)
76 ASequence ::= SEQUENCE -- no errors
82 ASequence1 ::= SEQUENCE
85 INTEGER OPTIONAL, -- error, ambiguous values possible
90 ASequence3 ::= SEQUENCE
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
106 -- now check that duplicate APPLICATION tag errors are reported
108 Foo1 ::= [APPLICATION 0] INTEGER
109 Foo2 ::= [APPLICATION 1] INTEGER
111 Bar1 ::= [APPLICATION 0] IMPLICIT INTEGER -- error
112 Bar2 ::= [APPLICATION 1] IMPLICIT INTEGER -- error
115 -- check that field name errors are reported
130 f3 [3] BOOLEAN, -- error, field name conflict
131 [4] AChoice4 -- error, field name conflict too
136 -- now check some recursive type related errors
153 RecSeq, -- warning, infinitely large values?
154 RecSeq OPTIONAL -- this should be ok 'cause it's optional
159 -- now check some named bit and named number related errors
163 Enum1 ::= ENUMERATED { zero(0), one(1), two(2), one(0) } -- 2 errors
165 Int1 ::= INTEGER { zero(0), one(1), two(2), yoyo(2), one(7), foo(aVal) } -- 2 errors
167 Bits1 ::= BIT STRING { zero(0), one(1), two(2), one(4), foo(-2), pogo(0),
168 gogo(aVal) } -- 4 errors
173 -- now check that implicitly tagged CHOICE, ANY and ANY DEFINED BY
176 BChoice1 ::= [APPLICATION 5] IMPLICIT CHOICE -- error
182 BChoice2 ::= CHOICE -- no error
188 BChoice3 ::= [APPLICATION 6] CHOICE -- no error
198 [0] IMPLICIT BChoice2, -- error
199 [1] IMPLICIT BChoice3, -- no error
200 [2] IMPLICIT CHOICE {INTEGER, BOOLEAN} -- error
205 -- now test that errors are reported for multiply defined
209 TypeCopy1 ::= INTEGER
210 TypeCopy1 ::= BOOLEAN
211 TypeCopy1 ::= INTEGER
213 valCopy1 INTEGER ::= 1
214 valCopy1 BOOLEAN ::= TRUE
215 valCopy1 INTEGER ::= 1
219 -- test some OBJECT IDENTIFER value errors
222 oid1 OBJECT IDENTIFIER ::= { oid1 ms(1) 1 } -- error: recursive value
223 oid2 OBJECT IDENTIFIER ::= { oid1 ms(1) 2 }
225 -- error: can only ref other oid values from first arc
226 oid3 OBJECT IDENTIFIER ::= { ms(1) oid2 2 }
228 boolVal BOOLEAN ::= TRUE
229 intVal1 INTEGER ::= 1
230 intVal2 INTEGER ::= -1
231 oid4 OBJECT IDENTIFIER ::= { oid2 intVal1 intVal2 boolVal 1}
233 oid5 OBJECT IDENTIFIER ::= { 1 2 -4}
235 oid6 OBJECT IDENTIFIER ::= { oid7 1}
236 oid7 OBJECT IDENTIFIER ::= { oid6 1 }