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