Initial revision


git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@2 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/tests/00-empty-OK.asn1 b/tests/00-empty-OK.asn1
new file mode 100644
index 0000000..532d4fb
--- /dev/null
+++ b/tests/00-empty-OK.asn1
@@ -0,0 +1 @@
+ModuleTestEmpty DEFINITIONS ::= BEGIN END
diff --git a/tests/01-empty-OK.asn1 b/tests/01-empty-OK.asn1
new file mode 100644
index 0000000..04d9ba7
--- /dev/null
+++ b/tests/01-empty-OK.asn1
@@ -0,0 +1,14 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .1
+
+ModuleTestEmpty
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 1 }
+	DEFINITIONS ::=
+BEGIN
+
+END
diff --git a/tests/02-garbage-NP.asn1 b/tests/02-garbage-NP.asn1
new file mode 100644
index 0000000..410c7bc
--- /dev/null
+++ b/tests/02-garbage-NP.asn1
@@ -0,0 +1,17 @@
+
+-- NP: Non-parseable.
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .2
+
+ModuleTestGarbage
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 2 }
+	DEFINITIONS ::=
+BEGIN
+
+	-- must fail on the next line --
+	some garbage
+
+END
diff --git a/tests/03-enum-OK.asn1 b/tests/03-enum-OK.asn1
new file mode 100644
index 0000000..567df26
--- /dev/null
+++ b/tests/03-enum-OK.asn1
@@ -0,0 +1,22 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .3
+
+ModuleTestEnum1
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 3 }
+	DEFINITIONS ::=
+BEGIN
+
+	Enum1 ::= ENUMERATED
+		{ red,	-- will be 0 --
+		green,	-- will be 1 --
+		blue(4),
+		alpha,
+		... -- extensible --
+		}
+
+END
diff --git a/tests/04-enum-SE.asn1 b/tests/04-enum-SE.asn1
new file mode 100644
index 0000000..e9a37c4
--- /dev/null
+++ b/tests/04-enum-SE.asn1
@@ -0,0 +1,19 @@
+
+-- SE: Semantic error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .4
+
+ModuleTestEnum2
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 4 }
+	DEFINITIONS ::=
+BEGIN
+
+	enum1 Enum1 ::= blue
+
+	Enum1 ::= ENUMERATED { red, green, ...,
+		blue(1) -- collides with green -- }
+
+END
diff --git a/tests/05-enum-SE.asn1 b/tests/05-enum-SE.asn1
new file mode 100644
index 0000000..083724d
--- /dev/null
+++ b/tests/05-enum-SE.asn1
@@ -0,0 +1,21 @@
+
+-- SE: Semantic error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .5
+
+ModuleTestEnum3
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 5 }
+	DEFINITIONS ::=
+BEGIN
+
+	enum1 Enum1 ::= red
+
+	Enum1 ::= ENUMERATED { red(5), green(4), ..., blue(6),
+		-- second extension marker is not allowed --
+		...,
+		white(7) }
+
+END
diff --git a/tests/06-enum-SE.asn1 b/tests/06-enum-SE.asn1
new file mode 100644
index 0000000..ad304af
--- /dev/null
+++ b/tests/06-enum-SE.asn1
@@ -0,0 +1,20 @@
+
+-- SE: Semantic error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .6
+
+ModuleTestEnum4
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 6 }
+	DEFINITIONS ::=
+BEGIN
+
+	enum1 Enum1 ::= red
+
+	Enum1 ::= ENUMERATED { red(5), ...,
+		green(7), blue(6)	-- order is not maintained after ...
+		}
+
+END
diff --git a/tests/07-int-OK.asn1 b/tests/07-int-OK.asn1
new file mode 100644
index 0000000..bf59627
--- /dev/null
+++ b/tests/07-int-OK.asn1
@@ -0,0 +1,26 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .7
+
+ModuleTestInt1
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 7 }
+	DEFINITIONS ::=
+BEGIN
+
+	int123456 INTEGER ::= 123456
+
+	Interval ::= INTEGER (1..int123456)
+
+	SameInterval INTEGER ::= { 1 | 2 | 3 | 4 | 5 | 6 }
+
+	Reason ::= INTEGER {
+			no-reason(0),
+			negative-reason(-10),
+			some-large-value(1324324)
+		}
+
+END
diff --git a/tests/08-int-SE.asn1 b/tests/08-int-SE.asn1
new file mode 100644
index 0000000..8ff97fd
--- /dev/null
+++ b/tests/08-int-SE.asn1
@@ -0,0 +1,19 @@
+
+-- OK: Semantic Error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .8
+
+ModuleTestInt2
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 8 }
+	DEFINITIONS ::=
+BEGIN
+
+	Reason ::= INTEGER {
+			value1(0),
+			value1(2)	-- identifiers must be distinct --
+		}
+
+END
diff --git a/tests/09-int-SE.asn1 b/tests/09-int-SE.asn1
new file mode 100644
index 0000000..c696e19
--- /dev/null
+++ b/tests/09-int-SE.asn1
@@ -0,0 +1,20 @@
+
+-- OK: Semantic Error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .9
+
+ModuleTestInt3
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 9 }
+	DEFINITIONS ::=
+BEGIN
+
+	Reason ::= INTEGER {
+			value1(1),
+			value5(5),
+			value2-1(1)	-- integers must be distinct --
+		}
+
+END
diff --git a/tests/10-int-OK.asn1 b/tests/10-int-OK.asn1
new file mode 100644
index 0000000..c17265f
--- /dev/null
+++ b/tests/10-int-OK.asn1
@@ -0,0 +1,29 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .10
+
+ModuleTestInt4
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 10 }
+	DEFINITIONS ::=
+BEGIN
+
+	alpha INTEGER ::= 1
+	Type1 ::= INTEGER { alpha(2) }
+	Type2 ::= INTEGER { alpha(3), beta(alpha) }
+	gamma Type2 ::= beta	-- equals 1 --
+	delta Type2 ::= alpha	-- equals 3 --
+
+	/*
+	 *  The following are for post-fix checking by the check_fixer.
+	 * It will be able to pick-up these values if the file is parseable,
+	 * even if it contains some semantic errors.
+	 */
+
+	check-gamma INTEGER ::= 1	-- check "gamma"'s value
+	check-delta INTEGER ::= 3	-- check "delta"'s value
+
+END
diff --git a/tests/11-int-SE.asn1 b/tests/11-int-SE.asn1
new file mode 100644
index 0000000..57978d7
--- /dev/null
+++ b/tests/11-int-SE.asn1
@@ -0,0 +1,18 @@
+
+-- OK: Semantic Error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .11
+
+ModuleTestInt5
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 11 }
+	DEFINITIONS ::=
+BEGIN
+
+	-- recursive definition loop
+	alpha INTEGER ::= beta
+	beta INTEGER ::= alpha
+
+END
diff --git a/tests/12-int-SE.asn1 b/tests/12-int-SE.asn1
new file mode 100644
index 0000000..90939b6
--- /dev/null
+++ b/tests/12-int-SE.asn1
@@ -0,0 +1,17 @@
+
+-- OK: Semantic Error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .12
+
+ModuleTestInt6
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 12 }
+	DEFINITIONS ::=
+BEGIN
+
+	-- unresolved reference
+	alpha INTEGER ::= beta
+
+END
diff --git a/tests/13-resolver-OK.asn1 b/tests/13-resolver-OK.asn1
new file mode 100644
index 0000000..5237b01
--- /dev/null
+++ b/tests/13-resolver-OK.asn1
@@ -0,0 +1,47 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .13 1
+-- .13 2
+
+ModuleTestResolver1
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 13 1 }
+	DEFINITIONS ::=
+BEGIN
+	IMPORTS IntegerType, beta FROM
+		Renamed
+		{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+			spelio(9363) software(1) asn1c(5) test(1) 13 2 };
+
+	-- external reference
+	alpha IntegerType ::= beta
+	alpha2 Renamed.IntegerType ::= beta
+
+	-- 
+	-- The following are for post-fix checking by the check_fixer.
+	-- It will be able to pick-up these values if the file is parseable,
+	-- even if it contains some semantic errors.
+	-- 
+
+	check-alpha INTEGER ::= 123
+	check-alpha2 INTEGER ::= 123
+
+END
+
+ModuleTestResolver2
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 13 2 }
+	DEFINITIONS ::=
+BEGIN
+	EXPORTS beta, IntegerType ;
+
+	beta HiddenType ::= 123
+
+	HiddenType ::= INTEGER
+
+	IntegerType ::= INTEGER
+
+END
diff --git a/tests/14-resolver-OK.asn1 b/tests/14-resolver-OK.asn1
new file mode 100644
index 0000000..48fb0cc
--- /dev/null
+++ b/tests/14-resolver-OK.asn1
@@ -0,0 +1,45 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .14 1
+-- .14 2
+
+ModuleTestResolver2
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 14 1 }
+	DEFINITIONS ::=
+BEGIN
+	IMPORTS Enumeration, beta FROM
+		OtherModuleRenamed
+		{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+			spelio(9363) software(1) asn1c(5) test(1) 14 2 };
+
+	-- external reference
+	alpha Enumeration ::= beta
+
+	-- 
+	-- The following are for post-fix checking by the check_fixer.
+	-- It will be able to pick-up these values if the file is parseable,
+	-- even if it contains some semantic errors.
+	-- 
+
+	check-alpha INTEGER ::= 2
+
+END
+
+ModuleTestResolver3
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 14 2 }
+	DEFINITIONS ::=
+BEGIN
+	EXPORTS Enumeration, beta ;
+
+	beta HiddenEnum ::= b
+
+	HiddenEnum ::= ENUMERATED { a(1), b(2) }
+
+	Enumeration ::= ENUMERATED { a(1), b(2) }	-- the same type --
+
+END
diff --git a/tests/15-resolver-SE.asn1 b/tests/15-resolver-SE.asn1
new file mode 100644
index 0000000..f4255c8
--- /dev/null
+++ b/tests/15-resolver-SE.asn1
@@ -0,0 +1,35 @@
+
+-- SE: Semantic error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .15 1
+-- .15 2
+
+ModuleTestResolver4
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 15 1 }
+	DEFINITIONS ::=
+BEGIN
+	IMPORTS Enumeration, beta FROM
+		OtherModuleRenamed
+		{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+			spelio(9363) software(1) asn1c(5) test(1) 15 2 };
+
+	-- external reference
+	alpha Enumeration ::= beta
+
+END
+
+ModuleTestResolver5
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 15 2 }
+	DEFINITIONS ::=
+BEGIN
+	EXPORTS;	-- Does not export anything!
+
+	beta Enumeration ::= b
+
+	Enumeration ::= ENUMERATED { a(1), b(2) }
+
+END
diff --git a/tests/16-constraint-OK.asn1 b/tests/16-constraint-OK.asn1
new file mode 100644
index 0000000..5625d7f
--- /dev/null
+++ b/tests/16-constraint-OK.asn1
@@ -0,0 +1,23 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .16
+
+ModuleTestConstraint
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 16 }
+	DEFINITIONS ::=
+BEGIN
+
+	-- external reference
+	Type1 ::= IA5String (SIZE(1..10,...))(FROM("a".."z"|"#"))
+	Type2 ::= IA5String (SIZE (MIN..4)|FROM ("abc"))
+	Type3 ::= BMPString (SIZE(1))
+	Type4 ::= INTEGER (1..MAX)
+	Type5 ::= BOOLEAN (TRUE|FALSE)
+
+	v1 Type1 ::= "#value wi
+		th ""double quotes"""
+END
diff --git a/tests/17-tags-OK.asn1 b/tests/17-tags-OK.asn1
new file mode 100644
index 0000000..40f9c07
--- /dev/null
+++ b/tests/17-tags-OK.asn1
@@ -0,0 +1,24 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .17
+
+ModuleTestTags
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 17 }
+	DEFINITIONS ::=
+BEGIN
+
+	T3 ::= [3] IMPLICIT T2
+	T1 ::= [1] INTEGER
+	T2 ::= [2] EXPLICIT T1
+
+	T4 ::= [APPLICATION 1] SET {
+			t1	[4] IMPLICIT T1,
+			t2	[5] T2,
+			t3	[6] T3
+		}
+
+END
diff --git a/tests/18-class-OK.asn1 b/tests/18-class-OK.asn1
new file mode 100644
index 0000000..edae856
--- /dev/null
+++ b/tests/18-class-OK.asn1
@@ -0,0 +1,36 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .18
+
+ModuleTestClass
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 18 }
+	DEFINITIONS ::=
+BEGIN
+
+	AlphaNumeric ::= IA5String (FROM ("A".."Z"|"a".."z"|"0".."9"))
+
+	FUNCTION ::= CLASS {
+		&code			INTEGER (0..MAX) UNIQUE,
+		&Alphabet		IA5String DEFAULT {AlphaNumeric},
+		&ArgType		,
+		&SupportedArguments	&ArgType OPTIONAL,
+		&ResultType		DEFAULT NULL,
+		&result-if-error	&ResultType DEFAULT NULL,
+		&associated-function	FUNCTION OPTIONAL
+	}
+
+	operator-plus FUNCTION ::= {
+		&ArgType		Pair,
+		&SupportedArguments	{ PosPair | NegPair }
+		&ResultType		INTEGER,
+		&result-if-error	0,
+		&code			1
+	}
+
+	FunctionCodeType ::= FUNCTION.&code
+
+END
diff --git a/tests/19-param-OK.asn1 b/tests/19-param-OK.asn1
new file mode 100644
index 0000000..37d7c44
--- /dev/null
+++ b/tests/19-param-OK.asn1
@@ -0,0 +1,30 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .19
+
+ModuleTestParam
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 19 }
+	DEFINITIONS ::=
+BEGIN
+
+	SIGNED { ToBeSigned } ::= SEQUENCE {
+		toBeSigned	ToBeSigned,
+		algorithm	OBJECT IDENTIFIER,
+		signature	BIT STRING
+	}
+
+	Certificate ::= SIGNED { SEQUENCE {
+		version		INTEGER,
+		signature	OBJECT IDENTIFIER,
+		issuer		Name
+	} }
+
+	Name ::= SEQUENCE OF RelativeDistinguishedName
+
+	RelativeDistinguishedName ::= SET SIZE (1..MAX) OF IA5String
+
+END
diff --git a/tests/20-constr-OK.asn1 b/tests/20-constr-OK.asn1
new file mode 100644
index 0000000..f2a97f0
--- /dev/null
+++ b/tests/20-constr-OK.asn1
@@ -0,0 +1,30 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .20
+
+ModuleTestConstr
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 20 }
+	DEFINITIONS IMPLICIT TAGS EXTENSIBILITY IMPLIED ::=
+BEGIN
+
+	ConstructedType1 ::= SEQUENCE {
+				a	[1] INTEGER,
+				b	[2] INTEGER,
+				...!ex1,
+				c	IA5String,
+				...,
+				d	UTF8String
+			}
+
+	ConstructedType2 ::= SET {
+				a	[1] INTEGER,
+				b	[2] INTEGER
+			}
+
+	ex1 INTEGER ::= 1
+
+END
diff --git a/tests/21-tags-OK.asn1 b/tests/21-tags-OK.asn1
new file mode 100644
index 0000000..3a46c32
--- /dev/null
+++ b/tests/21-tags-OK.asn1
@@ -0,0 +1,34 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .21 1
+-- .21 2
+
+ModuleTestTags1
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 21 1 }
+	DEFINITIONS EXPLICIT TAGS ::=
+BEGIN
+
+	T1 ::= CHOICE {
+			first	[0] INTEGER,
+			second	[1] INTEGER
+		}
+
+END
+
+ModuleTestTags2
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 21 2 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+	IMPORTS T1 FROM ModuleTestTags1;
+
+	T2 ::= SEQUENCE {
+			one	[0] T1,
+			two	[1] IA5String
+		}
+
+END
diff --git a/tests/22-tags-OK.asn1 b/tests/22-tags-OK.asn1
new file mode 100644
index 0000000..562e14b
--- /dev/null
+++ b/tests/22-tags-OK.asn1
@@ -0,0 +1,23 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .22
+
+ModuleTestTags3
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 22 }
+	DEFINITIONS AUTOMATIC TAGS ::=
+BEGIN
+
+	T1 ::= SEQUENCE {
+		a INTEGER,
+		b CHOICE {
+				i INTEGER,
+				n IA5String
+			},
+		c UTF8String
+	}
+
+END
diff --git a/tests/23-bits-OK.asn1 b/tests/23-bits-OK.asn1
new file mode 100644
index 0000000..f41b923
--- /dev/null
+++ b/tests/23-bits-OK.asn1
@@ -0,0 +1,22 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .23
+
+ModuleTestBitString
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 23 }
+	DEFINITIONS AUTOMATIC TAGS ::=
+BEGIN
+
+	v28 INTEGER ::= 28
+
+	BS1	::= BIT STRING { first(0), third(2), twenty-eight(v28) }
+
+	one-zero-one BS1 ::= { first, third }	-- Equivalent to '101'B
+
+	one0one BS1 ::= '1010000'B		-- Equivalent to '101'B
+
+END
diff --git a/tests/24-sequence-OK.asn1 b/tests/24-sequence-OK.asn1
new file mode 100644
index 0000000..851ebf0
--- /dev/null
+++ b/tests/24-sequence-OK.asn1
@@ -0,0 +1,21 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .24
+
+ModuleTestSequence
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 24 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	T ::= [5] EXPLICIT SEQUENCE {
+		a		INTEGER,
+		b [0]		INTEGER OPTIONAL,
+		c [1]		INTEGER DEFAULT 10,
+		d [5] EXPLICIT	INTEGER
+		}
+
+END
diff --git a/tests/25-misc-OK.asn1 b/tests/25-misc-OK.asn1
new file mode 100644
index 0000000..3a7eb91
--- /dev/null
+++ b/tests/25-misc-OK.asn1
@@ -0,0 +1,29 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .25
+
+ModuleTestMisc
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 25 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	T ::= SEQUENCE {
+		a	INTEGER,
+		b [2]	BOOLEAN,
+		c	NULL,
+		...,
+		d	ENUMERATED {
+				a(1), b(2)
+				},
+		e	OCTET STRING,
+		f 	OCTET STRING,
+		g	BIT STRING,
+		h	BIT STRING,
+		...
+	}
+
+END
diff --git a/tests/26-sequence-SE.asn1 b/tests/26-sequence-SE.asn1
new file mode 100644
index 0000000..8c5866a
--- /dev/null
+++ b/tests/26-sequence-SE.asn1
@@ -0,0 +1,20 @@
+
+-- SE: Semantic error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .26
+
+ModuleTestSequenceTagsDistinct
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 26 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	T ::= SEQUENCE {
+		a INTEGER,
+		b INTEGER	OPTIONAL,
+		c INTEGER
+	}
+
+END
diff --git a/tests/27-set-SE.asn1 b/tests/27-set-SE.asn1
new file mode 100644
index 0000000..91e5697
--- /dev/null
+++ b/tests/27-set-SE.asn1
@@ -0,0 +1,21 @@
+
+-- SE: Semantic error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .27
+
+ModuleTestSetTagsDistinct
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 27 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	T ::= SET {
+		a INTEGER,
+		b CHOICE {		-- Could we lookup tag past CHOICE?..
+			c INTEGER	-- Tags must be distinct here.
+		}
+	}
+
+END
diff --git a/tests/28-tags-SE.asn1 b/tests/28-tags-SE.asn1
new file mode 100644
index 0000000..b3af0e3
--- /dev/null
+++ b/tests/28-tags-SE.asn1
@@ -0,0 +1,26 @@
+
+-- SE: Semantic error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .28
+
+ModuleTestTagsDistinct
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 28 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	S ::= SET {
+		a INTEGER,
+		b CHOICE {
+			c IA5String,
+			...
+		},
+		d CHOICE {
+			e BOOLEAN,
+			...
+		}
+	}
+
+END
diff --git a/tests/29-tags-OK.asn1 b/tests/29-tags-OK.asn1
new file mode 100644
index 0000000..440f16c
--- /dev/null
+++ b/tests/29-tags-OK.asn1
@@ -0,0 +1,26 @@
+
+-- OK: Everything is fin
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .29
+
+ModuleTestTagsDistinct2
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 29 }
+	DEFINITIONS AUTOMATIC TAGS ::=
+BEGIN
+
+	S ::= SET {
+		a INTEGER,
+		b CHOICE {
+			c IA5String,
+			...
+		},
+		d CHOICE {
+			e BOOLEAN,
+			...
+		}
+	}
+
+END
diff --git a/tests/30-set-OK.asn1 b/tests/30-set-OK.asn1
new file mode 100644
index 0000000..2cd6a5a
--- /dev/null
+++ b/tests/30-set-OK.asn1
@@ -0,0 +1,21 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .30
+
+ModuleTestSetSimple
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 30 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	T ::= SET {
+		a [APPLICATION 3] INTEGER,
+		b IA5String,
+		...,
+		c [2] BOOLEAN
+	}
+
+END
diff --git a/tests/31-set-of-OK.asn1 b/tests/31-set-of-OK.asn1
new file mode 100644
index 0000000..cd108ba
--- /dev/null
+++ b/tests/31-set-of-OK.asn1
@@ -0,0 +1,21 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .31
+
+ModuleTestSetOfSimple
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 31 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	Forest ::= SET OF Tree
+
+	Tree ::= SEQUENCE {
+		height	INTEGER,
+		width	INTEGER
+	}
+
+END
diff --git a/tests/32-sequence-of-OK.asn1 b/tests/32-sequence-of-OK.asn1
new file mode 100644
index 0000000..ced163a
--- /dev/null
+++ b/tests/32-sequence-of-OK.asn1
@@ -0,0 +1,22 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .32
+
+ModuleTestSequenceSimple
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 32 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	Programming ::= SEQUENCE OF Fault
+
+	Fault ::= SET OF Error
+
+	Error ::= SEQUENCE {
+			...
+		}
+
+END
diff --git a/tests/33-misc-OK.asn1 b/tests/33-misc-OK.asn1
new file mode 100644
index 0000000..1018a40
--- /dev/null
+++ b/tests/33-misc-OK.asn1
@@ -0,0 +1,33 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .33
+
+ModuleTestMiscComplex
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 33 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	T ::= SEQUENCE {
+		a [1] INTEGER,
+		...,
+		b [2] EXPLICIT 	BitString,
+		c [8] IMPLICIT  Label,
+		d [10] IMPLICIT Int,
+		e [12] T2
+	}
+
+	BitString ::= [8] BIT STRING
+
+	Label	::= [9] EXPLICIT UTF8String
+
+	Label2	::= [1] Label
+
+	Int	::= [3] IMPLICIT INTEGER { a(1), b(2) }
+
+	T2	::= SEQUENCE { l Label2 }
+
+END
diff --git a/tests/34-class-OK.asn1 b/tests/34-class-OK.asn1
new file mode 100644
index 0000000..b2d4dff
--- /dev/null
+++ b/tests/34-class-OK.asn1
@@ -0,0 +1,51 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .34
+
+ModuleTestClassSimple
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 34 }
+	DEFINITIONS IMPLICIT TAGS ::=
+BEGIN
+
+	-- First CLASS
+
+	EXTENSION ::= CLASS {
+		&id	OBJECT IDENTIFIER UNIQUE,
+		&ExtnType
+	} WITH SYNTAX {
+		SYNTAX		&ExtnType
+		IDENTIFIED BY	&id
+	}
+
+	-- Basic CLASS extraction
+	Ext1	::= SEQUENCE {
+			extnId	EXTENSION.&id
+		}
+
+	-- Second CLASS
+
+	EXTENSION-ATTRIBUTE ::= CLASS {
+		&id	INTEGER (0..ub-extension-attributes) UNIQUE,
+		&Type
+	} WITH SYNTAX {&Type IDENTIFIED BY &id}
+
+	terminal-type EXTENSION-ATTRIBUTE ::= {TerminalType IDENTIFIED BY 23}
+
+	-- Advanced CLASS extraction
+
+	ExtensionAttribute ::= SEQUENCE {
+		extension-attribute-type [0] EXTENSION-ATTRIBUTE.&id
+				({ExtensionAttributeTable}),
+		extension-attribute-value [1] EXTENSION-ATTRIBUTE.&Type
+			({ExtensionAttributeTable} {@extension-attribute-type})
+	}
+
+	-- Variables referenced by subtype constraints
+
+	ub-extension-attributes INTEGER ::= 256
+
+END
diff --git a/tests/35-set-choice-OK.asn1 b/tests/35-set-choice-OK.asn1
new file mode 100644
index 0000000..3678021
--- /dev/null
+++ b/tests/35-set-choice-OK.asn1
@@ -0,0 +1,36 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .35
+
+ModuleTestSetAndUntaggedChoice
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 35 }
+	DEFINITIONS ::=
+BEGIN
+
+	T ::= SET {
+		a NumericString,
+		b CHOICE {			-- Untagged choice
+			b1  IA5String,
+			b2  ObjectDescriptor,
+			b3  Choice
+		},
+		c BOOLEAN,
+		...,
+		d OID
+	}
+
+	Choice ::= CHOICE {			-- One more level
+		ch-a OCTET STRING,
+		ch-b BIT STRING
+	}
+
+	OID ::= CHOICE {
+		oid OBJECT IDENTIFIER,
+		r-oid RELATIVE-OID
+	}
+
+END
diff --git a/tests/36-indirect-choice-SE.asn1 b/tests/36-indirect-choice-SE.asn1
new file mode 100644
index 0000000..8fcb07b
--- /dev/null
+++ b/tests/36-indirect-choice-SE.asn1
@@ -0,0 +1,25 @@
+
+-- SE: Semantic Error
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .36
+
+ModuleTestIndirectChoiceError
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 36 }
+	DEFINITIONS ::=
+BEGIN
+
+	T ::= CHOICE {
+		t-a  INTEGER,
+		t-b  OCTET STRING,
+		t-c  Choice
+	}
+
+	Choice ::= CHOICE {			-- One more level
+		c-a OCTET STRING,
+		c-b INTEGER
+	}
+
+END
diff --git a/tests/37-indirect-choice-OK.asn1 b/tests/37-indirect-choice-OK.asn1
new file mode 100644
index 0000000..b0361c4
--- /dev/null
+++ b/tests/37-indirect-choice-OK.asn1
@@ -0,0 +1,32 @@
+
+-- OK: Everything is Fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .37
+
+ModuleTestIndirectChoiceFine
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 37 }
+	DEFINITIONS ::=
+BEGIN
+
+	T ::= CHOICE {
+		t-a  INTEGER,
+		t-b  OCTET STRING,
+		t-c  [1] Choice1,
+		t-d  Choice2
+	}
+
+	Choice1 ::= CHOICE {
+		c-a OCTET STRING,
+		c-b INTEGER
+	}
+
+	Choice2 ::= [2] CHOICE {
+		c-a OCTET STRING,
+		c-b INTEGER,
+		c-d [3] Choice1
+	}
+
+END
diff --git a/tests/38-comments-OK.asn1 b/tests/38-comments-OK.asn1
new file mode 100644
index 0000000..f2f9aab
--- /dev/null
+++ b/tests/38-comments-OK.asn1
@@ -0,0 +1,33 @@
+
+-- OK: Everything is Fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .38
+
+ModuleNestedCTypeComments
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 38 }
+	DEFINITIONS ::=
+BEGIN
+
+	T ::= CHOICE {
+		t-a  INTEGER,
+		t-b  OCTET STRING
+/*		t-c  [1] Choice1, t-d  Choice2 */
+	}
+
+	-- this is a comment too -- This-Is-Not-A-Comment
+	::= INTEGER
+
+/*
+	ISO/IEC 8824-1 #11.6.4
+
+	blah blah blah
+	/* nested comment */
+	-- this is an insignificant coment
+	-- this is a comment too -- and this is a comment
+
+ */
+
+END
diff --git a/tests/39-sequence-of-OK.asn1 b/tests/39-sequence-of-OK.asn1
new file mode 100644
index 0000000..b8ac3f4
--- /dev/null
+++ b/tests/39-sequence-of-OK.asn1
@@ -0,0 +1,24 @@
+
+-- OK: Everything is Fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .39
+
+ModuleNestedSequenceOf
+	{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 39 }
+	DEFINITIONS ::=
+BEGIN
+
+	T ::= SEQUENCE {
+		int	INTEGER,
+		collection	SEQUENCE OF T2
+	}
+
+	T2 ::= SEQUENCE {
+		flag	BOOLEAN,
+		str	UTF8String
+	}
+
+END
diff --git a/tests/39-sequence-of-OK.asn1.-P b/tests/39-sequence-of-OK.asn1.-P
new file mode 100644
index 0000000..afadff7
--- /dev/null
+++ b/tests/39-sequence-of-OK.asn1.-P
@@ -0,0 +1,171 @@
+
+/*** <<< DEPS [T] >>> ***/
+
+/* Dependencies for T */
+#include <INTEGER.h>
+
+/* Dependencies for collection */
+#include <T2.h>
+#include <asn_SEQUENCE_OF.h>
+
+	#include <constr_SEQUENCE_OF.h>
+#include <constr_SEQUENCE.h>
+
+extern asn1_TYPE_descriptor_t asn1_DEF_T;
+
+/*** <<< TYPE-DECLS [T] >>> ***/
+
+
+typedef struct T {
+	INTEGER_t	 int;
+	struct collection {
+		A_SEQUENCE_OF(struct T2) list;
+		
+		/* Context for parsing across buffer boundaries */
+		ber_dec_ctx_t _ber_dec_ctx;
+	} collection;
+	
+	/* Context for parsing across buffer boundaries */
+	ber_dec_ctx_t _ber_dec_ctx;
+} T_t;
+
+/*** <<< STAT-DEFS [T] >>> ***/
+
+	static asn1_SET_OF_element_t asn1_DEF_collection_elements[] = {
+		{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
+			(void *)&asn1_DEF_T2 },
+	};
+	static ber_tlv_tag_t asn1_DEF_collection_tags[] = {
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+	};
+	static asn1_SET_OF_specifics_t asn1_DEF_collection_specs = {
+		sizeof(struct collection),
+		offsetof(struct collection, _ber_dec_ctx),
+		asn1_DEF_collection_elements
+	};
+	asn1_TYPE_descriptor_t asn1_DEF_collection = {
+		"collection",
+		SEQUENCE_OF_constraint,
+		SEQUENCE_OF_decode_ber,
+		SEQUENCE_OF_encode_der,
+		SEQUENCE_OF_print,
+		SEQUENCE_OF_free,
+		0,	/* Use generic outmost tag fetcher */
+		asn1_DEF_collection_tags,
+		sizeof(asn1_DEF_collection_tags)
+			/sizeof(asn1_DEF_collection_tags[0]),
+		0,	/* Tags to skip */
+		1,	/* Whether CONSTRUCTED */
+		&asn1_DEF_collection_specs	/* Additional specs */
+	};
+	
+#include <constr_SEQUENCE.h>
+
+static asn1_SEQUENCE_element_t asn1_DEF_T_elements[] = {
+	{ offsetof(struct T, int), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
+		0,
+		(void *)&asn1_DEF_INTEGER,
+		"int"
+		},
+	{ offsetof(struct T, collection), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
+		0,
+		(void *)&asn1_DEF_collection,
+		"collection"
+		},
+};
+static ber_tlv_tag_t asn1_DEF_T_tags[] = {
+	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+};
+static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = {
+	sizeof(struct T),
+	offsetof(struct T, _ber_dec_ctx),
+	asn1_DEF_T_elements,
+	2,	/* Elements count */
+	-1,	/* Start extensions */
+	-1	/* Stop extensions */
+};
+asn1_TYPE_descriptor_t asn1_DEF_T = {
+	"T",
+	SEQUENCE_constraint,
+	SEQUENCE_decode_ber,
+	SEQUENCE_encode_der,
+	SEQUENCE_print,
+	SEQUENCE_free,
+	0,	/* Use generic outmost tag fetcher */
+	asn1_DEF_T_tags,
+	sizeof(asn1_DEF_T_tags)
+		/sizeof(asn1_DEF_T_tags[0]),
+	0,	/* Tags to skip */
+	1,	/* Whether CONSTRUCTED */
+	&asn1_DEF_T_specs	/* Additional specs */
+};
+
+
+/*** <<< DEPS [T2] >>> ***/
+
+/* Dependencies for T2 */
+#include <BOOLEAN.h>
+#include <UTF8String.h>
+
+#include <constr_SEQUENCE.h>
+
+extern asn1_TYPE_descriptor_t asn1_DEF_T2;
+
+/*** <<< TYPE-DECLS [T2] >>> ***/
+
+
+typedef struct T2 {
+	BOOLEAN_t	 flag;
+	UTF8String_t	 str;
+	
+	/* Context for parsing across buffer boundaries */
+	ber_dec_ctx_t _ber_dec_ctx;
+} T2_t;
+
+/*** <<< STAT-DEFS [T2] >>> ***/
+
+#include <constr_SEQUENCE.h>
+
+static asn1_SEQUENCE_element_t asn1_DEF_T2_elements[] = {
+	{ offsetof(struct T2, flag), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
+		0,
+		(void *)&asn1_DEF_BOOLEAN,
+		"flag"
+		},
+	{ offsetof(struct T2, str), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
+		0,
+		(void *)&asn1_DEF_UTF8String,
+		"str"
+		},
+};
+static ber_tlv_tag_t asn1_DEF_T2_tags[] = {
+	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+};
+static asn1_SEQUENCE_specifics_t asn1_DEF_T2_specs = {
+	sizeof(struct T2),
+	offsetof(struct T2, _ber_dec_ctx),
+	asn1_DEF_T2_elements,
+	2,	/* Elements count */
+	-1,	/* Start extensions */
+	-1	/* Stop extensions */
+};
+asn1_TYPE_descriptor_t asn1_DEF_T2 = {
+	"T2",
+	SEQUENCE_constraint,
+	SEQUENCE_decode_ber,
+	SEQUENCE_encode_der,
+	SEQUENCE_print,
+	SEQUENCE_free,
+	0,	/* Use generic outmost tag fetcher */
+	asn1_DEF_T2_tags,
+	sizeof(asn1_DEF_T2_tags)
+		/sizeof(asn1_DEF_T2_tags[0]),
+	0,	/* Tags to skip */
+	1,	/* Whether CONSTRUCTED */
+	&asn1_DEF_T2_specs	/* Additional specs */
+};
+
diff --git a/tests/40-int-optional-SE.asn1 b/tests/40-int-optional-SE.asn1
new file mode 100644
index 0000000..abe1065
--- /dev/null
+++ b/tests/40-int-optional-SE.asn1
@@ -0,0 +1,27 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .40
+
+ModuleTestIntOptional
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 40 }
+	DEFINITIONS ::=
+BEGIN
+
+	T ::= CHOICE {
+		seq SEQUENCE {
+			string	UTF8String,
+			alpha	INTEGER OPTIONAL,
+			beta	INTEGER OPTIONAL
+		},
+		set SET {
+			string	UTF8String,
+			alpha	INTEGER OPTIONAL,
+			beta	INTEGER OPTIONAL
+		}
+	}
+
+END
diff --git a/tests/41-int-optional-OK.asn1 b/tests/41-int-optional-OK.asn1
new file mode 100644
index 0000000..3e091d7
--- /dev/null
+++ b/tests/41-int-optional-OK.asn1
@@ -0,0 +1,27 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .41
+
+ModuleTestIntOptional
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 41 }
+	DEFINITIONS AUTOMATIC TAGS ::=
+BEGIN
+
+	T ::= CHOICE {
+		seq SEQUENCE {
+			string	UTF8String,
+			alpha	INTEGER OPTIONAL,
+			beta	INTEGER OPTIONAL
+		},
+		set SET {
+			string	UTF8String,
+			alpha	INTEGER OPTIONAL,
+			beta	INTEGER OPTIONAL
+		}
+	}
+
+END
diff --git a/tests/42-real-life-OK.asn1 b/tests/42-real-life-OK.asn1
new file mode 100644
index 0000000..33802c2
--- /dev/null
+++ b/tests/42-real-life-OK.asn1
@@ -0,0 +1,67 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .42
+
+ModuleLAPStorage
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 42 }
+	DEFINITIONS EXTENSIBILITY IMPLIED ::=
+BEGIN
+
+	/*
+	 * A package representing a distinguished log line.
+	 * It contains
+	 *  - a digest of that line (actually, a normalized
+	 *    form with bells (\007) in place of variable components),
+	 *  - one or more sets of variable parts (presumably with different
+	 *    acceptability rules).
+	 */
+	LogLine ::= SEQUENCE {
+		line-digest	IA5String,	-- Log line normal form
+		varsets		SEQUENCE (1..MAX) OF VariablePartSet
+	}
+
+	/*
+	 * This package contains a set of variable components of a log line.
+	 * Each variable component may contain one or more "value samples",
+	 * or a range between two samples.
+	 */
+	VariablePartSet ::= SEQUENCE {
+		vparts		SEQUENCE (0..MAX) OF VariablePart, -- {123,321}
+		resolution	ActionItem
+	}
+
+	/*
+	 * A description of a single variable part.
+	 */
+	VariablePart ::= CHOICE {
+		-- A set of acceptable values
+		vset	SET (1..MAX) OF VisibleString,
+		-- A range of acceptable values
+		vrange	SEQUENCE {
+			from	VisibleString,
+			to	VisibleString
+		}
+	}
+
+	/*
+	 * What to do with the log line.
+	 */
+	ActionItem ::= SEQUENCE {
+		accept-as	ENUMERATED {
+			unknown,	-- Action yet unknown.
+			safe,		-- No action, just move on.
+			unsafe,		-- Unsafe message. Inform NOC.
+			...
+		},
+		notify	SEQUENCE {	-- How to notify NOC.
+			critical  BOOLEAN,		-- Emit critical message
+			email	  SET OF VisibleString,	-- Send emails
+			...
+		} OPTIONAL
+	}
+
+END
diff --git a/tests/42-real-life-OK.asn1.-PR b/tests/42-real-life-OK.asn1.-PR
new file mode 100644
index 0000000..bcac56c
--- /dev/null
+++ b/tests/42-real-life-OK.asn1.-PR
@@ -0,0 +1,569 @@
+
+/*** <<< DEPS [LogLine] >>> ***/
+
+/* Dependencies for LogLine */
+#include <IA5String.h>
+
+/* Dependencies for varsets */
+#include <VariablePartSet.h>
+#include <asn_SEQUENCE_OF.h>
+
+	#include <constr_SEQUENCE_OF.h>
+#include <constr_SEQUENCE.h>
+
+extern asn1_TYPE_descriptor_t asn1_DEF_LogLine;
+
+/*** <<< TYPE-DECLS [LogLine] >>> ***/
+
+
+typedef struct LogLine {
+	IA5String_t	 line_digest;
+	struct varsets {
+		A_SEQUENCE_OF(struct VariablePartSet) list;
+		
+		/* Context for parsing across buffer boundaries */
+		ber_dec_ctx_t _ber_dec_ctx;
+	} varsets;
+	/*
+	 * This type is extensible,
+	 * possible extensions are below.
+	 */
+	
+	/* Context for parsing across buffer boundaries */
+	ber_dec_ctx_t _ber_dec_ctx;
+} LogLine_t;
+
+/*** <<< STAT-DEFS [LogLine] >>> ***/
+
+	static asn1_SET_OF_element_t asn1_DEF_varsets_elements[] = {
+		{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
+			(void *)&asn1_DEF_VariablePartSet },
+	};
+	static ber_tlv_tag_t asn1_DEF_varsets_tags[] = {
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+	};
+	static asn1_SET_OF_specifics_t asn1_DEF_varsets_specs = {
+		sizeof(struct varsets),
+		offsetof(struct varsets, _ber_dec_ctx),
+		asn1_DEF_varsets_elements
+	};
+	asn1_TYPE_descriptor_t asn1_DEF_varsets = {
+		"varsets",
+		SEQUENCE_OF_constraint,
+		SEQUENCE_OF_decode_ber,
+		SEQUENCE_OF_encode_der,
+		SEQUENCE_OF_print,
+		SEQUENCE_OF_free,
+		0,	/* Use generic outmost tag fetcher */
+		asn1_DEF_varsets_tags,
+		sizeof(asn1_DEF_varsets_tags)
+			/sizeof(asn1_DEF_varsets_tags[0]),
+		0,	/* Tags to skip */
+		1,	/* Whether CONSTRUCTED */
+		&asn1_DEF_varsets_specs	/* Additional specs */
+	};
+	
+#include <constr_SEQUENCE.h>
+
+static asn1_SEQUENCE_element_t asn1_DEF_LogLine_elements[] = {
+	{ offsetof(struct LogLine, line_digest), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
+		0,
+		(void *)&asn1_DEF_IA5String,
+		"line-digest"
+		},
+	{ offsetof(struct LogLine, varsets), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
+		0,
+		(void *)&asn1_DEF_varsets,
+		"varsets"
+		},
+};
+static ber_tlv_tag_t asn1_DEF_LogLine_tags[] = {
+	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+};
+static asn1_SEQUENCE_specifics_t asn1_DEF_LogLine_specs = {
+	sizeof(struct LogLine),
+	offsetof(struct LogLine, _ber_dec_ctx),
+	asn1_DEF_LogLine_elements,
+	2,	/* Elements count */
+	1,	/* Start extensions */
+	3	/* Stop extensions */
+};
+asn1_TYPE_descriptor_t asn1_DEF_LogLine = {
+	"LogLine",
+	SEQUENCE_constraint,
+	SEQUENCE_decode_ber,
+	SEQUENCE_encode_der,
+	SEQUENCE_print,
+	SEQUENCE_free,
+	0,	/* Use generic outmost tag fetcher */
+	asn1_DEF_LogLine_tags,
+	sizeof(asn1_DEF_LogLine_tags)
+		/sizeof(asn1_DEF_LogLine_tags[0]),
+	0,	/* Tags to skip */
+	1,	/* Whether CONSTRUCTED */
+	&asn1_DEF_LogLine_specs	/* Additional specs */
+};
+
+
+/*** <<< DEPS [VariablePartSet] >>> ***/
+
+/* Dependencies for VariablePartSet */
+#include <ActionItem.h>
+
+/* Dependencies for vparts */
+#include <VariablePart.h>
+#include <asn_SEQUENCE_OF.h>
+
+	#include <constr_SEQUENCE_OF.h>
+#include <constr_SEQUENCE.h>
+
+extern asn1_TYPE_descriptor_t asn1_DEF_VariablePartSet;
+
+/*** <<< TYPE-DECLS [VariablePartSet] >>> ***/
+
+
+typedef struct VariablePartSet {
+	struct vparts {
+		A_SEQUENCE_OF(struct VariablePart) list;
+		
+		/* Context for parsing across buffer boundaries */
+		ber_dec_ctx_t _ber_dec_ctx;
+	} vparts;
+	ActionItem_t	 resolution;
+	/*
+	 * This type is extensible,
+	 * possible extensions are below.
+	 */
+	
+	/* Context for parsing across buffer boundaries */
+	ber_dec_ctx_t _ber_dec_ctx;
+} VariablePartSet_t;
+
+/*** <<< STAT-DEFS [VariablePartSet] >>> ***/
+
+	static asn1_SET_OF_element_t asn1_DEF_vparts_elements[] = {
+		{ -1 /* Ambiguous tag (CHOICE?) */,
+			(void *)&asn1_DEF_VariablePart },
+	};
+	static ber_tlv_tag_t asn1_DEF_vparts_tags[] = {
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+	};
+	static asn1_SET_OF_specifics_t asn1_DEF_vparts_specs = {
+		sizeof(struct vparts),
+		offsetof(struct vparts, _ber_dec_ctx),
+		asn1_DEF_vparts_elements
+	};
+	asn1_TYPE_descriptor_t asn1_DEF_vparts = {
+		"vparts",
+		SEQUENCE_OF_constraint,
+		SEQUENCE_OF_decode_ber,
+		SEQUENCE_OF_encode_der,
+		SEQUENCE_OF_print,
+		SEQUENCE_OF_free,
+		0,	/* Use generic outmost tag fetcher */
+		asn1_DEF_vparts_tags,
+		sizeof(asn1_DEF_vparts_tags)
+			/sizeof(asn1_DEF_vparts_tags[0]),
+		0,	/* Tags to skip */
+		1,	/* Whether CONSTRUCTED */
+		&asn1_DEF_vparts_specs	/* Additional specs */
+	};
+	
+#include <constr_SEQUENCE.h>
+
+static asn1_SEQUENCE_element_t asn1_DEF_VariablePartSet_elements[] = {
+	{ offsetof(struct VariablePartSet, vparts), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
+		0,
+		(void *)&asn1_DEF_vparts,
+		"vparts"
+		},
+	{ offsetof(struct VariablePartSet, resolution), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
+		0,
+		(void *)&asn1_DEF_ActionItem,
+		"resolution"
+		},
+};
+static ber_tlv_tag_t asn1_DEF_VariablePartSet_tags[] = {
+	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+};
+static asn1_SEQUENCE_specifics_t asn1_DEF_VariablePartSet_specs = {
+	sizeof(struct VariablePartSet),
+	offsetof(struct VariablePartSet, _ber_dec_ctx),
+	asn1_DEF_VariablePartSet_elements,
+	2,	/* Elements count */
+	1,	/* Start extensions */
+	3	/* Stop extensions */
+};
+asn1_TYPE_descriptor_t asn1_DEF_VariablePartSet = {
+	"VariablePartSet",
+	SEQUENCE_constraint,
+	SEQUENCE_decode_ber,
+	SEQUENCE_encode_der,
+	SEQUENCE_print,
+	SEQUENCE_free,
+	0,	/* Use generic outmost tag fetcher */
+	asn1_DEF_VariablePartSet_tags,
+	sizeof(asn1_DEF_VariablePartSet_tags)
+		/sizeof(asn1_DEF_VariablePartSet_tags[0]),
+	0,	/* Tags to skip */
+	1,	/* Whether CONSTRUCTED */
+	&asn1_DEF_VariablePartSet_specs	/* Additional specs */
+};
+
+
+/*** <<< DEPS [VariablePart] >>> ***/
+
+
+/* Dependencies for vset */
+#include <VisibleString.h>
+#include <asn_SET_OF.h>
+
+		#include <constr_SET_OF.h>
+		
+/* Dependencies for vrange */
+#include <VisibleString.h>
+#include <VisibleString.h>
+
+		#include <constr_SEQUENCE.h>
+		
+extern asn1_TYPE_descriptor_t asn1_DEF_VariablePart;
+
+/*** <<< TYPE-DECLS [VariablePart] >>> ***/
+
+
+typedef struct VariablePart {
+	enum {
+		VariablePart_PR_NOTHING,	/* No components present */
+		VariablePart_PR_vset,
+		VariablePart_PR_vrange,
+	} present;
+	union {
+		struct vset {
+			A_SET_OF(VisibleString_t) list;
+			
+			/* Context for parsing across buffer boundaries */
+			ber_dec_ctx_t _ber_dec_ctx;
+		} vset;
+		struct vrange {
+			VisibleString_t	 from;
+			VisibleString_t	 to;
+			/*
+			 * This type is extensible,
+			 * possible extensions are below.
+			 */
+			
+			/* Context for parsing across buffer boundaries */
+			ber_dec_ctx_t _ber_dec_ctx;
+		} vrange;
+		/*
+		 * This type is extensible,
+		 * possible extensions are below.
+		 */
+	} choice;
+	
+	/* Context for parsing across buffer boundaries */
+	ber_dec_ctx_t _ber_dec_ctx;
+} VariablePart_t;
+
+/*** <<< STAT-DEFS [VariablePart] >>> ***/
+
+		static asn1_SET_OF_element_t asn1_DEF_vset_elements[] = {
+			{ (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)),
+				(void *)&asn1_DEF_VisibleString },
+		};
+		static ber_tlv_tag_t asn1_DEF_vset_tags[] = {
+			(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
+		};
+		static asn1_SET_OF_specifics_t asn1_DEF_vset_specs = {
+			sizeof(struct vset),
+			offsetof(struct vset, _ber_dec_ctx),
+			asn1_DEF_vset_elements
+		};
+		asn1_TYPE_descriptor_t asn1_DEF_vset = {
+			"vset",
+			SET_OF_constraint,
+			SET_OF_decode_ber,
+			SET_OF_encode_der,
+			SET_OF_print,
+			SET_OF_free,
+			0,	/* Use generic outmost tag fetcher */
+			asn1_DEF_vset_tags,
+			sizeof(asn1_DEF_vset_tags)
+				/sizeof(asn1_DEF_vset_tags[0]),
+			0,	/* Tags to skip */
+			1,	/* Whether CONSTRUCTED */
+			&asn1_DEF_vset_specs	/* Additional specs */
+		};
+		
+		#include <constr_SEQUENCE.h>
+		
+		static asn1_SEQUENCE_element_t asn1_DEF_vrange_elements[] = {
+			{ offsetof(struct vrange, from), 0,
+				(ASN_TAG_CLASS_UNIVERSAL | (26 << 2)),
+				0,
+				(void *)&asn1_DEF_VisibleString,
+				"from"
+				},
+			{ offsetof(struct vrange, to), 0,
+				(ASN_TAG_CLASS_UNIVERSAL | (26 << 2)),
+				0,
+				(void *)&asn1_DEF_VisibleString,
+				"to"
+				},
+		};
+		static ber_tlv_tag_t asn1_DEF_vrange_tags[] = {
+			(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+		};
+		static asn1_SEQUENCE_specifics_t asn1_DEF_vrange_specs = {
+			sizeof(struct vrange),
+			offsetof(struct vrange, _ber_dec_ctx),
+			asn1_DEF_vrange_elements,
+			2,	/* Elements count */
+			1,	/* Start extensions */
+			3	/* Stop extensions */
+		};
+		asn1_TYPE_descriptor_t asn1_DEF_vrange = {
+			"vrange",
+			SEQUENCE_constraint,
+			SEQUENCE_decode_ber,
+			SEQUENCE_encode_der,
+			SEQUENCE_print,
+			SEQUENCE_free,
+			0,	/* Use generic outmost tag fetcher */
+			asn1_DEF_vrange_tags,
+			sizeof(asn1_DEF_vrange_tags)
+				/sizeof(asn1_DEF_vrange_tags[0]),
+			0,	/* Tags to skip */
+			1,	/* Whether CONSTRUCTED */
+			&asn1_DEF_vrange_specs	/* Additional specs */
+		};
+		
+#include <constr_CHOICE.h>
+
+static asn1_CHOICE_element_t asn1_DEF_VariablePart_elements[] = {
+	{ offsetof(struct VariablePart, choice.vset), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
+		0,
+		(void *)&asn1_DEF_vset,
+		"vset"
+		},
+	{ offsetof(struct VariablePart, choice.vrange), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
+		0,
+		(void *)&asn1_DEF_vrange,
+		"vrange"
+		},
+};
+static ber_tlv_tag_t asn1_DEF_VariablePart_tags[] = {
+	
+};
+static asn1_CHOICE_tag2member_t asn1_DEF_VariablePart_tag2el[] = {
+    { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1 }, /* vrange at 45 */
+    { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 0 }, /* vset at 42 */
+};
+static asn1_CHOICE_specifics_t asn1_DEF_VariablePart_specs = {
+	sizeof(struct VariablePart),
+	offsetof(struct VariablePart, _ber_dec_ctx),
+	offsetof(struct VariablePart, present),
+	sizeof(((struct VariablePart *)0)->present),
+	asn1_DEF_VariablePart_elements,
+	2,	/* Elements count */
+	asn1_DEF_VariablePart_tag2el,
+	2,	/* Count of tags in the map */
+	0	/* Whether extensible */
+};
+asn1_TYPE_descriptor_t asn1_DEF_VariablePart = {
+	"VariablePart",
+	CHOICE_constraint,
+	CHOICE_decode_ber,
+	CHOICE_encode_der,
+	CHOICE_print,
+	CHOICE_free,
+	CHOICE_outmost_tag,
+	asn1_DEF_VariablePart_tags,
+	sizeof(asn1_DEF_VariablePart_tags)
+		/sizeof(asn1_DEF_VariablePart_tags[0]),
+	0,	/* Tags to skip */
+	1,	/* Whether CONSTRUCTED */
+	&asn1_DEF_VariablePart_specs	/* Additional specs */
+};
+
+
+/*** <<< DEPS [ActionItem] >>> ***/
+
+/* Dependencies for ActionItem */
+#include <ENUMERATED.h>
+
+	typedef enum accept_as {
+		accept_as_unknown	= 0,
+		accept_as_safe	= 1,
+		accept_as_unsafe	= 2,
+		/*
+		 * Enumeration is extensible
+		 */
+	} accept_as_e;
+/* Dependencies for notify */
+#include <BOOLEAN.h>
+
+/* Dependencies for email */
+#include <VisibleString.h>
+#include <asn_SET_OF.h>
+
+		#include <constr_SET_OF.h>
+		
+	#include <constr_SEQUENCE.h>
+	
+#include <constr_SEQUENCE.h>
+
+extern asn1_TYPE_descriptor_t asn1_DEF_ActionItem;
+
+/*** <<< TYPE-DECLS [ActionItem] >>> ***/
+
+
+typedef struct ActionItem {
+	ENUMERATED_t	 accept_as;
+	struct notify {
+		BOOLEAN_t	 critical;
+		struct email {
+			A_SET_OF(VisibleString_t) list;
+			
+			/* Context for parsing across buffer boundaries */
+			ber_dec_ctx_t _ber_dec_ctx;
+		} email;
+		/*
+		 * This type is extensible,
+		 * possible extensions are below.
+		 */
+		
+		/* Context for parsing across buffer boundaries */
+		ber_dec_ctx_t _ber_dec_ctx;
+	} *notify;
+	/*
+	 * This type is extensible,
+	 * possible extensions are below.
+	 */
+	
+	/* Context for parsing across buffer boundaries */
+	ber_dec_ctx_t _ber_dec_ctx;
+} ActionItem_t;
+
+/*** <<< STAT-DEFS [ActionItem] >>> ***/
+
+		static asn1_SET_OF_element_t asn1_DEF_email_elements[] = {
+			{ (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)),
+				(void *)&asn1_DEF_VisibleString },
+		};
+		static ber_tlv_tag_t asn1_DEF_email_tags[] = {
+			(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
+		};
+		static asn1_SET_OF_specifics_t asn1_DEF_email_specs = {
+			sizeof(struct email),
+			offsetof(struct email, _ber_dec_ctx),
+			asn1_DEF_email_elements
+		};
+		asn1_TYPE_descriptor_t asn1_DEF_email = {
+			"email",
+			SET_OF_constraint,
+			SET_OF_decode_ber,
+			SET_OF_encode_der,
+			SET_OF_print,
+			SET_OF_free,
+			0,	/* Use generic outmost tag fetcher */
+			asn1_DEF_email_tags,
+			sizeof(asn1_DEF_email_tags)
+				/sizeof(asn1_DEF_email_tags[0]),
+			0,	/* Tags to skip */
+			1,	/* Whether CONSTRUCTED */
+			&asn1_DEF_email_specs	/* Additional specs */
+		};
+		
+	#include <constr_SEQUENCE.h>
+	
+	static asn1_SEQUENCE_element_t asn1_DEF_notify_elements[] = {
+		{ offsetof(struct notify, critical), 0,
+			(ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
+			0,
+			(void *)&asn1_DEF_BOOLEAN,
+			"critical"
+			},
+		{ offsetof(struct notify, email), 0,
+			(ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
+			0,
+			(void *)&asn1_DEF_email,
+			"email"
+			},
+	};
+	static ber_tlv_tag_t asn1_DEF_notify_tags[] = {
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+	};
+	static asn1_SEQUENCE_specifics_t asn1_DEF_notify_specs = {
+		sizeof(struct notify),
+		offsetof(struct notify, _ber_dec_ctx),
+		asn1_DEF_notify_elements,
+		2,	/* Elements count */
+		1,	/* Start extensions */
+		3	/* Stop extensions */
+	};
+	asn1_TYPE_descriptor_t asn1_DEF_notify = {
+		"notify",
+		SEQUENCE_constraint,
+		SEQUENCE_decode_ber,
+		SEQUENCE_encode_der,
+		SEQUENCE_print,
+		SEQUENCE_free,
+		0,	/* Use generic outmost tag fetcher */
+		asn1_DEF_notify_tags,
+		sizeof(asn1_DEF_notify_tags)
+			/sizeof(asn1_DEF_notify_tags[0]),
+		0,	/* Tags to skip */
+		1,	/* Whether CONSTRUCTED */
+		&asn1_DEF_notify_specs	/* Additional specs */
+	};
+	
+#include <constr_SEQUENCE.h>
+
+static asn1_SEQUENCE_element_t asn1_DEF_ActionItem_elements[] = {
+	{ offsetof(struct ActionItem, accept_as), 0,
+		(ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
+		0,
+		(void *)&asn1_DEF_ENUMERATED,
+		"accept-as"
+		},
+	{ offsetof(struct ActionItem, notify), 1,
+		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
+		0,
+		(void *)&asn1_DEF_notify,
+		"notify"
+		},
+};
+static ber_tlv_tag_t asn1_DEF_ActionItem_tags[] = {
+	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+};
+static asn1_SEQUENCE_specifics_t asn1_DEF_ActionItem_specs = {
+	sizeof(struct ActionItem),
+	offsetof(struct ActionItem, _ber_dec_ctx),
+	asn1_DEF_ActionItem_elements,
+	2,	/* Elements count */
+	1,	/* Start extensions */
+	3	/* Stop extensions */
+};
+asn1_TYPE_descriptor_t asn1_DEF_ActionItem = {
+	"ActionItem",
+	SEQUENCE_constraint,
+	SEQUENCE_decode_ber,
+	SEQUENCE_encode_der,
+	SEQUENCE_print,
+	SEQUENCE_free,
+	0,	/* Use generic outmost tag fetcher */
+	asn1_DEF_ActionItem_tags,
+	sizeof(asn1_DEF_ActionItem_tags)
+		/sizeof(asn1_DEF_ActionItem_tags[0]),
+	0,	/* Tags to skip */
+	1,	/* Whether CONSTRUCTED */
+	&asn1_DEF_ActionItem_specs	/* Additional specs */
+};
+
diff --git a/tests/43-recursion-OK.asn1 b/tests/43-recursion-OK.asn1
new file mode 100644
index 0000000..185b8cc
--- /dev/null
+++ b/tests/43-recursion-OK.asn1
@@ -0,0 +1,26 @@
+
+-- OK: Everything is fine
+
+-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
+-- .spelio.software.asn1c.test (9363.1.5.1)
+-- .43
+
+ModuleRecursion
+	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
+		spelio(9363) software(1) asn1c(5) test(1) 43 }
+	DEFINITIONS ::=
+BEGIN
+
+	Test-structure-1 ::= SEQUENCE {
+		t-member1 SET OF Test-structure-1,
+		t-member2 SEQUENCE OF Test-structure-1,
+		t-member3 Test-structure-1 OPTIONAL
+	}
+
+	Sets ::= SEQUENCE {
+		s-member1 SET OF INTEGER,
+		s-member2 SET OF ENUMERATED { a, b },
+		s-member3 SET OF IA5String
+	}
+
+END
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..03dda3b
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,2 @@
+
+EXTRA_DIST = *.asn1*
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 0000000..a391a53
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,219 @@
+# Makefile.in generated automatically by automake 1.5 from Makefile.am.
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = @program_transform_name@
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_alias = @build_alias@
+build_triplet = @build@
+host_alias = @host_alias@
+host_triplet = @host@
+target_alias = @target_alias@
+target_triplet = @target@
+ADD_CFLAGS = @ADD_CFLAGS@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AWK = @AWK@
+CC = @CC@
+CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@
+CPP = @CPP@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+EXEEXT = @EXEEXT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LEX = @LEX@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+MAINT = @MAINT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PATH = @PATH@
+RANLIB = @RANLIB@
+VERSION = @VERSION@
+YACC = @YACC@
+am__include = @am__include@
+am__quote = @am__quote@
+install_sh = @install_sh@
+
+EXTRA_DIST = *.asn1*
+subdir = tests
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+DIST_SOURCES =
+DIST_COMMON = README Makefile.am Makefile.in
+all: all-am
+
+.SUFFIXES:
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  tests/Makefile
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && \
+	  CONFIG_HEADERS= CONFIG_LINKS= \
+	  CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status
+uninstall-info-am:
+tags: TAGS
+TAGS:
+
+
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+	@for file in $(DISTFILES); do \
+	  if test -f $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    $(mkinstalldirs) "$(distdir)/$$dir"; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    cp -pR $$d/$$file $(distdir) \
+	    || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+
+installdirs:
+
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+
+distclean-am: clean-am distclean-generic distclean-libtool
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+uninstall-am: uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	distclean distclean-generic distclean-libtool distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool uninstall uninstall-am uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..abba350
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,24 @@
+
+This is a collection of various little ASN.1 modules, used independently
+by several different testing engines below the main tree (i.e. libasn1fix)
+for stressing various aspects of compiler operation.
+
+The files follow certain naming conventions:
+
+Source file:
+	<Index>-<arbitrary-name>-{OK|SE|NP}.asn1
+
+Regenerator test file:
+	<Index>-<arbitrary-name>-{OK|SE|NP}.asn1.[<compiler-flags>]
+
+Where
+	<Index> is arbitrary number (digits)
+	<arbitrary-name> is arbitrary string, without dots
+	OK	file syntax and semantics are absolutely correct
+	SE	file semantics is wrong
+	NP	file syntax is incorrect, file not parseable
+	<cimpiler-flags>	command-line flags for compiler
+
+Example:
+	07-int-OK.asn1		# Correct ASN.1 file
+	07-int-OK.asn1.-EFN	# Test of file regeneration with -EFN flags.