xref: /aoo42x/main/idlc/test/parser/constant.tests (revision 57f04c0e)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22EXPECT SUCCESS "constant.tests 1":
23constants C {
24    const boolean C1 = FALSE;
25    const byte C2 = 0;
26    const short C3 = 0;
27    const unsigned short C4 = 0;
28    const long C5 = 0;
29    const unsigned long C6 = 0;
30    const hyper C7 = 0;
31    const unsigned hyper C8 = 0;
32    const float C9 = 0.0;
33    const double C10 = 0.0;
34};
35
36
37EXPECT SUCCESS "constant.tests 2":
38module m {
39    const boolean C1 = FALSE;
40    const byte C2 = 0;
41    const short C3 = 0;
42    const unsigned short C4 = 0;
43    const long C5 = 0;
44    const unsigned long C6 = 0;
45    const hyper C7 = 0;
46    const unsigned hyper C8 = 0;
47    const float C9 = 0.0;
48    const double C10 = 0.0;
49};
50
51
52EXPECT FAILURE "constant.tests 3":
53constants C {
54    const char C1 = 'A';
55};
56
57
58EXPECT FAILURE "constant.tests 4":
59module m {
60    const char C1 = 'A';
61};
62
63
64EXPECT FAILURE "constant.tests 5":
65constants C {
66    const string C1 = "";
67};
68
69
70EXPECT FAILURE "constant.tests 6":
71module m {
72    const string C1 = "";
73};
74
75
76EXPECT SUCCESS "constant.tests 7":
77constants C {};
78
79
80EXPECT SUCCESS "constant.tests 8":
81module m {
82    const byte C1 = -128;
83    const byte C2 = -0200;
84    const byte C3 = -0x80;
85    const byte C4 = 255;
86    const byte C5 = 0377;
87    const byte C6 = 0xFF;
88    const short C7 = -32768;
89    const short C8 = -0100000;
90    const short C9 = -0x8000;
91    const short C10 = 32767;
92    const short C11 = 077777;
93    const short C12 = 0x7FFF;
94    const unsigned short C13 = 0;
95    const unsigned short C14 = 0x0;
96    const unsigned short C15 = 65535;
97    const unsigned short C16 = 0177777;
98    const unsigned short C17 = 0xFFFF;
99    const long C18 = -2147483648;
100    const long C19 = -020000000000;
101    const long C20 = -0x80000000;
102    const long C21 = 2147483647;
103    const long C22 = 017777777777;
104    const long C23 = 0x7FFFFFFF;
105    const unsigned long C24 = 0;
106    const unsigned long C25 = 0x0;
107    const unsigned long C26 = 4294967295;
108    const unsigned long C27 = 037777777777;
109	const unsigned long C28 = 0xFFFFFFFF;
110	const hyper C29 = -9223372036854775808;
111    const hyper C30 = -01000000000000000000000;
112    const hyper C31 = -0x8000000000000000;
113	const hyper C32 = 9223372036854775807;
114    const hyper C33 = 0777777777777777777777;
115    const hyper C34 = 0x7FFFFFFFFFFFFFFF;
116    const unsigned hyper C35 = 0;
117    const unsigned hyper C36 = 0x0;
118    const unsigned hyper C37 = 18446744073709551615;
119    const unsigned hyper C38 = 01777777777777777777777;
120    const unsigned hyper C39 = 0xFFFFFFFFFFFFFFFF;
121};
122
123
124EXPECT FAILURE "constant.tests 9":
125module m { const byte C = -129; };
126
127
128EXPECT FAILURE "constant.tests 10":
129module m { const byte C = -0201; };
130
131
132EXPECT FAILURE "constant.tests 11":
133module m { const byte C = -0x81; };
134
135
136EXPECT FAILURE "constant.tests 12":
137module m { const byte C = 256; };
138
139
140EXPECT FAILURE "constant.tests 13":
141module m { const byte C = 0400; };
142
143
144EXPECT FAILURE "constant.tests 14":
145module m { const byte C = 0x100; };
146
147
148EXPECT FAILURE "constant.tests 15":
149module m { const short C = -32769; };
150
151
152EXPECT FAILURE "constant.tests 16":
153module m { const short C = -0100001; };
154
155
156EXPECT FAILURE "constant.tests 17":
157module m { const short C = -0x8001; };
158
159
160EXPECT FAILURE "constant.tests 18":
161module m { const short C = 32768; };
162
163
164EXPECT FAILURE "constant.tests 19":
165module m { const short C = 0100000; };
166
167
168EXPECT FAILURE "constant.tests 20":
169module m { const short C = 0x8000; };
170
171
172EXPECT FAILURE "constant.tests 21":
173module m { const unsigned short C = -1; };
174
175
176EXPECT FAILURE "constant.tests 22":
177module m { const unsigned short C = -01; };
178
179
180EXPECT FAILURE "constant.tests 23":
181module m { const unsigned short C = -0x1; };
182
183
184EXPECT FAILURE "constant.tests 24":
185module m { const unsigned short C = 65536; };
186
187
188EXPECT FAILURE "constant.tests 25":
189module m { const unsigned short C = 0200000; };
190
191
192EXPECT FAILURE "constant.tests 26":
193module m { const unsigned short C = 0x10000; };
194
195
196EXPECT FAILURE "constant.tests 27":
197module m { const long C = -2147483649; };
198
199
200EXPECT FAILURE "constant.tests 28":
201module m { const long C = -020000000001; };
202
203
204EXPECT FAILURE "constant.tests 29":
205module m { const long C = -0x80000001; };
206
207
208EXPECT FAILURE "constant.tests 30":
209module m { const long C = 2147483648; };
210
211
212EXPECT FAILURE "constant.tests 31":
213module m { const long C = 020000000000; };
214
215
216EXPECT FAILURE "constant.tests 32":
217module m { const long C = 0x80000000; };
218
219
220EXPECT FAILURE "constant.tests 33":
221module m { const unsigned long C = -1; };
222
223
224EXPECT FAILURE "constant.tests 34":
225module m { const unsigned long C = -01; };
226
227
228EXPECT FAILURE "constant.tests 35":
229module m { const unsigned long C = -0x1; };
230
231
232EXPECT FAILURE "constant.tests 36":
233module m { const unsigned long C = 4294967296; };
234
235
236EXPECT FAILURE "constant.tests 37":
237module m { const unsigned long C = 040000000000; };
238
239
240EXPECT FAILURE "constant.tests 38":
241module m { const unsigned long C = 0x100000000; };
242
243
244EXPECT FAILURE "constant.tests 39":
245module m { const hyper C = -9223372036854775809; };
246
247
248EXPECT FAILURE "constant.tests 40":
249module m { const hyper C = -01000000000000000000001; };
250
251
252EXPECT FAILURE "constant.tests 41":
253module m { const hyper C = -0x8000000000000001; };
254
255
256EXPECT FAILURE "constant.tests 42":
257module m { const hyper C = 9223372036854775808; };
258
259
260EXPECT FAILURE "constant.tests 43":
261module m { const hyper C = 01000000000000000000000; };
262
263
264EXPECT FAILURE "constant.tests 44":
265module m { const hyper C = 0x8000000000000000; };
266
267
268EXPECT FAILURE "constant.tests 45":
269module m { const unsigned hyper C = -1; };
270
271
272EXPECT FAILURE "constant.tests 46":
273module m { const unsigned hyper C = -01; };
274
275
276EXPECT FAILURE "constant.tests 47":
277module m { const unsigned hyper C = -0x1; };
278
279
280EXPECT FAILURE "constant.tests 48":
281module m { const unsigned hyper C = 18446744073709551616; };
282
283
284EXPECT FAILURE "constant.tests 49":
285module m { const unsigned hyper C = 02000000000000000000000; };
286
287
288EXPECT FAILURE "constant.tests 50":
289module m { const unsigned hyper C = 0x10000000000000000; };
290