Titan Core Initial Contribution
[deliverable/titan.core.git] / regression_test / XML / TTCNandXML / X693amd1.ttcn
1 /******************************************************************************
2 * Copyright (c) 2000-2014 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8 /*
9
10 TTCN-3 equivalents of the examples in Annex C
11
12 */
13 module X693amd1 {
14
15 type integer salary;
16 //---------- C.2.2
17 type record Employee {
18 integer id,
19 charstring recruited,
20 record of salary salaries
21 }
22 with {
23 variant "name as uncapitalized";
24 variant (id) "attribute";
25 variant (salaries) "list"
26 }
27
28
29 //---------- C.3.1 USE-UNION
30 type union Int_or_boolean_u {
31 integer int,
32 boolean boolean_
33 }
34 with {
35 variant "useUnion";
36 variant (boolean_) "name as 'boolean'"
37 }
38
39 //---------- C.3.2 USE-TYPE
40 type union Int_or_boolean_t {
41 integer int,
42 boolean boolean_,
43 charstring text
44 }
45 with {
46 variant "useType";
47 variant (boolean_) "name as 'boolean'"
48 //variant (boolean_) "namespace as 'foo:bar:baz' prefix 'foobar'"
49 }
50
51 //---------- C.3.3 USENUMBER, LIST
52 type enumerated PrimesUnder30 { int2(2), int3(3), int5(5), int7(7), int11(11),
53 int13(13), int17(17), int19(19), int23(23), int29(29) }
54 with {
55 variant "useNumber"
56 }
57
58 // record-of
59 type record of PrimesUnder30 InputValues with {
60 variant "attribute"
61 }
62
63 // record-of with LIST
64 type record of PrimesUnder30 InputValuesList with {
65 variant "attribute"
66 variant "list"
67 }
68
69 type float REAL;
70
71 // record which relies on its record-of member having LIST
72 type record PrimeProducts {
73 InputValuesList input,
74 REAL output
75 }
76 with {
77 variant (input) "attribute"; // it is not enough that InputValuesList has "attribute"
78 variant (output) "attribute"
79 variant (output) "XSD:decimal"
80 }
81
82 // record which puts LIST on its record-of member
83 type record PrimeProductsLocalList {
84 InputValues input,
85 float output
86 }
87 with {
88 variant (input) "attribute"; // it is not enough that InputValues has "attribute"
89 variant (output) "attribute"
90 variant (output) "XSD:decimal"
91 variant (input) "list"
92 }
93
94 //---------- C.3.4 DEFAULT-FOR-EMPTY
95 type enumerated Responses { ringing, engaged, number_not_known }
96 with { variant "text 'number_not_known' as 'number-not-known'"}
97
98 type record CallDetails {
99 charstring number, // NumericString
100 Responses response
101 }
102 with {
103 variant "defaultForEmpty as 'number_not_known'";
104 variant (number) "attribute";
105 variant (response) "untagged"; // Nokalva requires this (correctly, I think)
106 // even though it's not in the example from the ASN.1 standard
107 }
108
109 // Same as above but defaultForEmpty will be applied later
110 type record CallDetails0 {
111 charstring number, // NumericString
112 Responses response
113 }
114 with {
115 variant (number) "attribute"
116 variant (response) "untagged";
117 variant "name as 'CallDetails'"; // same name so we can reuse the test strings
118 }
119
120 type CallDetails0 CallDetails_indirect
121 with {
122 variant "defaultForEmpty as 'ringing'";
123 variant "name as 'CallDetails'"; // same name so we can reuse the test strings
124 // variant (number) "attribute" not possible here
125 }
126
127 //------------ D-F-E
128 /*
129 type charstring NoFoo
130 with {
131 variant "defaultForEmpty as 'foo'"
132 }
133
134 type record NoBar {
135 integer nb
136 }
137 with {
138 variant "useNil";
139 variant "defaultForEmpty as '13'"
140 }
141 */
142
143 //---------- C.3.5
144 // embedValues (in EmbedValues.ttcnpp)
145 //
146
147 /* * * * * * * * * * * * * * * * * * */
148 // USE-NIL
149
150 type record nilluser {
151 charstring title,
152 integer maybe optional
153 }
154 with {
155 variant (title) "attribute"
156 variant "useNil"
157 }
158
159 /* * * * * * * * * * * * * * * * * * */
160 // TEXT, from the TTCN standard, 5.2.2
161 type enumerated State { magic(-13), more_magic(17) }
162 with {
163 variant "name as uncapitalized";
164 variant "text all as capitalized";
165 variant "text 'more_magic' as 'off'"
166 }
167
168 /* * * * * * * * * * * * * * * * * * */
169
170 type boolean textboolean
171 with { variant "text" }
172
173 /* * * * * * * * * * * * * * * * * * */
174 // Nillable (nested USE-NIL)
175
176 type record Nillable {
177 record {
178 record { charstring content optional } forename
179 } content optional
180 }
181 with {
182 variant "useNil";
183 variant (content.forename) "useNil";
184 }
185
186 }
187 with {
188 encode "XML"
189 //variant "controlNamespace 'c\x94ntr\x94l-n\x82mszp\x82sz'" // required by USE-NIL and USE-TYPE
190 variant "controlNamespace 'cns' prefix 'p'"
191 }
This page took 0.040698 seconds and 6 git commands to generate.