Sync with 5.2.0
[deliverable/titan.core.git] / regression_test / XML / NegativeTest / exer_rec_of.ttcn
CommitLineData
970ed795
EL
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 ******************************************************************************/
8module exer_rec_of {
9
10type record of charstring stringlist
11with { variant "list" }
12
13external function encSL(in stringlist pars) return octetstring
14with { extension "prototype(convert) encode(XER:XER_EXTENDED)" }
15
16
17import from ReadXml all;
18import from rec { type Neg; function check_match }
19
20const stringlist c_marx_plain := { "chico", "groucho", "harpo" }
21
22template Nodes t_plain := {
23 // node_type, depth, name, value
24 { XML_READER_TYPE_ELEMENT , 0, "stringlist", "", "" },
25 { XML_READER_TYPE_TEXT , 1, "#text" , "chico groucho harpo", "" },
26 { XML_READER_TYPE_END_ELEMENT, 0, "stringlist", "", "" }
27};
28
29const stringlist c_marx_before0 := { "chico", "groucho", "harpo" }
30with { erroneous ([0]) "before := ""karl"" " }
31
32template Nodes t_before0 modifies t_plain := {
33 [1] := { XML_READER_TYPE_TEXT, 1, "#text", "karl chico groucho harpo", "" }
34};
35
36const stringlist c_marx_before0raw := { "chico", "groucho", "harpo" }
37with { erroneous ([0]) "before(raw) := ""karl,"" " }
38
39template Nodes t_before0raw modifies t_plain := {
40 [1] := { XML_READER_TYPE_TEXT, 1, "#text", "karl,chico groucho harpo", "" }
41 // Note: no space after ``karl,'' ---------------^
42};
43
44testcase exer_recof_plain() runs on Neg
45{
46 var octetstring o;
47 var Nodes nodes;
48
49 o := encSL(c_marx_plain);
50 nodes := gather(o, ignore_ws);
51 check_match(nodes, t_plain);
52}
53
54testcase exer_recof_before0() runs on Neg
55{
56 var octetstring o;
57 var Nodes nodes;
58
59 o := encSL(c_marx_before0);
60 nodes := gather(o, ignore_ws);
61 check_match(nodes, t_before0);
62
63 o := encSL(c_marx_before0raw);
64 nodes := gather(o, ignore_ws);
65 check_match(nodes, t_before0raw);
66}
67
68// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
69
70type record Container {
71 record of universal charstring aa
72}
73with {
74 variant (aa) "anyAttributes"
75}
76
77external function enc_aa(in Container c) return octetstring
78with {
79 extension "prototype(convert) encode(XER:XER_EXTENDED)"
80}
81
82const Container c_aa_plain := {
83 aa := {
84 // AnyAttributeFormat:
85 // "URI(optional), space, NCName, equals, \"xmlcstring\""
86 "uri:geller bender=""true""", // Apostrophe does not work :(
87 "Randi=""sceptic""",
88 "http://www.matrix.org neo=""1"""
89 }
90}
91
92const Container c_aa_plain_trouble := {
93 aa := {
94 // AnyAttributeFormat:
95 // "URI(optional), space, NCName, equals, \"xmlcstring\""
96 "uri:geller\t\tbender=""true""", // Apostrophe does not work :(
97 "Randi=""sceptic""",
98 "http://www.matrix.org neo=""1"" "
99 }
100}
101
102template Nodes t_aa_plain := {
103 // node_type , depth, name, value
104 { XML_READER_TYPE_ELEMENT , 0, "Container", "", "" },
105 { XML_READER_TYPE_ATTRIBUTE , 1, "xmlns:b0", "uri:geller", "http://www.w3.org/2000/xmlns/" },
106 { XML_READER_TYPE_ATTRIBUTE , 1, "xmlns:b2", "http://www.matrix.org", "http://www.w3.org/2000/xmlns/" },
107 { XML_READER_TYPE_ATTRIBUTE , 1, "b0:bender", "true", "uri:geller" },
108 { XML_READER_TYPE_ATTRIBUTE , 1, "Randi", "sceptic", "" },
109 { XML_READER_TYPE_ATTRIBUTE , 1, "b2:neo", "1", "http://www.matrix.org" }
110 // no { XML_READER_TYPE_END_ELEMENT, 0, "Container", "" }
111}
112
113testcase aa_plain() runs on Neg
114{
115 var octetstring o;
116 var Nodes nodes;
117
118 o := enc_aa(c_aa_plain);
119 nodes := gather(o, ignore_ws);
120 check_match(nodes, t_aa_plain);
121
122 o := enc_aa(c_aa_plain_trouble);
123 nodes := gather(o, ignore_ws);
124 check_match(nodes, t_aa_plain);
125}
126
127//-------------------------------------- BEFORE
128
129type charstring main_screen
130with { variant "attribute" }
131
132const Container c_aa_before0 := c_aa_plain
133with {
134 erroneous (aa[0]) "before := main_screen:""on"" "
135}
136
137template Nodes t_aa_before0 modifies t_aa_plain := {
138 -, //0. element
139 -, //1. attribute (ns)
140 -, //2. attribute (ns)
141 // here comes the disturbance: an extra attribute
142 { XML_READER_TYPE_ATTRIBUTE , 1, "main_screen", "on", "" }, //3.
143 t_aa_plain[3],
144 t_aa_plain[4],
145 t_aa_plain[5]
146}
147
148const Container c_aa_before0raw := c_aa_plain
149with {
150 erroneous (aa[0]) "before(raw) := "" move='zig'"" "
151 // the space here ------------------^
152 // ensures that we get a well-formed XML
153}
154
155template Nodes t_aa_before0raw modifies t_aa_plain := {
156 -, //0. element
157 -, //1. attribute (ns)
158 -, //2. attribute (ns)
159 // here comes the disturbance: an extra attribute
160 { XML_READER_TYPE_ATTRIBUTE , 1, "move", "zig", "" }, //3.
161 t_aa_plain[3],
162 t_aa_plain[4],
163 t_aa_plain[5]
164}
165
166
167testcase aa_before0() runs on Neg
168{
169 var octetstring o;
170 var Nodes nodes;
171
172 o := enc_aa(c_aa_before0);
173 nodes := gather(o, ignore_ws);
174 check_match(nodes, t_aa_before0);
175
176 o := enc_aa(c_aa_before0raw);
177 nodes := gather(o, ignore_ws);
178 check_match(nodes, t_aa_before0raw);
179}
180
181//-------------------------------------- REPLACE
182
183const Container c_aa_replace0 := c_aa_plain
184with {
185 erroneous (aa[0]) "value := main_screen:""off"" "
186}
187
188template Nodes t_aa_replace0 modifies t_aa_plain := {
189 // node_type , depth, name, value
190 { XML_READER_TYPE_ELEMENT , 0, "Container", "", "" },
191 //namespace for #0, not written { XML_READER_TYPE_ATTRIBUTE , 1, "xmlns:b0", "uri:geller", "http://www.w3.org/2000/xmlns/" },
192 { XML_READER_TYPE_ATTRIBUTE , 1, "xmlns:b2", "http://www.matrix.org", "http://www.w3.org/2000/xmlns/" },
193
194 //element #0 replaced { XML_READER_TYPE_ATTRIBUTE , 1, "b0:bender", "true", "uri:geller" },
195 { XML_READER_TYPE_ATTRIBUTE , 1, "main_screen", "off", "" },
196
197 { XML_READER_TYPE_ATTRIBUTE , 1, "Randi", "sceptic", "" },
198 { XML_READER_TYPE_ATTRIBUTE , 1, "b2:neo", "1", "http://www.matrix.org" }
199 // no { XML_READER_TYPE_END_ELEMENT, 0, "Container", "" }
200}
201
202const Container c_aa_replace0raw := c_aa_plain
203with {
204 erroneous (aa[0]) "value(raw) := "" main_screen='off'"" "
205 // again, space here --------------^ for well-formed XML
206}
207
208
209testcase aa_replace0() runs on Neg
210{
211 var octetstring o;
212 var Nodes nodes;
213
214 o := enc_aa(c_aa_replace0);
215 nodes := gather(o, ignore_ws);
216 check_match(nodes, t_aa_replace0);
217
218 o := enc_aa(c_aa_replace0raw);
219 nodes := gather(o, ignore_ws);
220 check_match(nodes, t_aa_replace0);
221}
222
223//-------------------------------------- AFTER
224
225const Container c_aa_after2 := c_aa_plain
226with {
227 erroneous (aa[2]) "after := main_screen : ""turn on"" "
228}
229
230template Nodes t_aa_after2 modifies t_aa_plain := {
231 -,-,-,-,-,-,
232 { XML_READER_TYPE_ATTRIBUTE, 1, "main_screen", "turn on", "" }
233}
234
235const Container c_aa_after2raw := c_aa_plain
236with {
237 erroneous (aa[2]) "after(raw) := "" main_screen='turn on'"" "
238}
239
240testcase aa_after() runs on Neg
241{
242 var octetstring o;
243 var Nodes nodes;
244
245 o := enc_aa(c_aa_after2);
246 nodes := gather(o, ignore_ws);
247 check_match(nodes, t_aa_after2);
248
249 o := enc_aa(c_aa_after2raw);
250 nodes := gather(o, ignore_ws);
251 check_match(nodes, t_aa_after2);
252}
253
254}
255with {
256 encode "XML";
257 optional "implicit omit";
258}
This page took 0.06092 seconds and 5 git commands to generate.