xref: /aoo42x/main/idlc/test/parser/constant.tests (revision cdf0e10c)
1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28EXPECT SUCCESS "constant.tests 1":
29constants C {
30    const boolean C1 = FALSE;
31    const byte C2 = 0;
32    const short C3 = 0;
33    const unsigned short C4 = 0;
34    const long C5 = 0;
35    const unsigned long C6 = 0;
36    const hyper C7 = 0;
37    const unsigned hyper C8 = 0;
38    const float C9 = 0.0;
39    const double C10 = 0.0;
40};
41
42
43EXPECT SUCCESS "constant.tests 2":
44module m {
45    const boolean C1 = FALSE;
46    const byte C2 = 0;
47    const short C3 = 0;
48    const unsigned short C4 = 0;
49    const long C5 = 0;
50    const unsigned long C6 = 0;
51    const hyper C7 = 0;
52    const unsigned hyper C8 = 0;
53    const float C9 = 0.0;
54    const double C10 = 0.0;
55};
56
57
58EXPECT FAILURE "constant.tests 3":
59constants C {
60    const char C1 = 'A';
61};
62
63
64EXPECT FAILURE "constant.tests 4":
65module m {
66    const char C1 = 'A';
67};
68
69
70EXPECT FAILURE "constant.tests 5":
71constants C {
72    const string C1 = "";
73};
74
75
76EXPECT FAILURE "constant.tests 6":
77module m {
78    const string C1 = "";
79};
80
81
82EXPECT SUCCESS "constant.tests 7":
83constants C {};
84
85
86EXPECT SUCCESS "constant.tests 8":
87module m {
88    const byte C1 = -128;
89    const byte C2 = -0200;
90    const byte C3 = -0x80;
91    const byte C4 = 255;
92    const byte C5 = 0377;
93    const byte C6 = 0xFF;
94    const short C7 = -32768;
95    const short C8 = -0100000;
96    const short C9 = -0x8000;
97    const short C10 = 32767;
98    const short C11 = 077777;
99    const short C12 = 0x7FFF;
100    const unsigned short C13 = 0;
101    const unsigned short C14 = 0x0;
102    const unsigned short C15 = 65535;
103    const unsigned short C16 = 0177777;
104    const unsigned short C17 = 0xFFFF;
105    const long C18 = -2147483648;
106    const long C19 = -020000000000;
107    const long C20 = -0x80000000;
108    const long C21 = 2147483647;
109    const long C22 = 017777777777;
110    const long C23 = 0x7FFFFFFF;
111    const unsigned long C24 = 0;
112    const unsigned long C25 = 0x0;
113    const unsigned long C26 = 4294967295;
114    const unsigned long C27 = 037777777777;
115	const unsigned long C28 = 0xFFFFFFFF;
116	const hyper C29 = -9223372036854775808;
117    const hyper C30 = -01000000000000000000000;
118    const hyper C31 = -0x8000000000000000;
119	const hyper C32 = 9223372036854775807;
120    const hyper C33 = 0777777777777777777777;
121    const hyper C34 = 0x7FFFFFFFFFFFFFFF;
122    const unsigned hyper C35 = 0;
123    const unsigned hyper C36 = 0x0;
124    const unsigned hyper C37 = 18446744073709551615;
125    const unsigned hyper C38 = 01777777777777777777777;
126    const unsigned hyper C39 = 0xFFFFFFFFFFFFFFFF;
127};
128
129
130EXPECT FAILURE "constant.tests 9":
131module m { const byte C = -129; };
132
133
134EXPECT FAILURE "constant.tests 10":
135module m { const byte C = -0201; };
136
137
138EXPECT FAILURE "constant.tests 11":
139module m { const byte C = -0x81; };
140
141
142EXPECT FAILURE "constant.tests 12":
143module m { const byte C = 256; };
144
145
146EXPECT FAILURE "constant.tests 13":
147module m { const byte C = 0400; };
148
149
150EXPECT FAILURE "constant.tests 14":
151module m { const byte C = 0x100; };
152
153
154EXPECT FAILURE "constant.tests 15":
155module m { const short C = -32769; };
156
157
158EXPECT FAILURE "constant.tests 16":
159module m { const short C = -0100001; };
160
161
162EXPECT FAILURE "constant.tests 17":
163module m { const short C = -0x8001; };
164
165
166EXPECT FAILURE "constant.tests 18":
167module m { const short C = 32768; };
168
169
170EXPECT FAILURE "constant.tests 19":
171module m { const short C = 0100000; };
172
173
174EXPECT FAILURE "constant.tests 20":
175module m { const short C = 0x8000; };
176
177
178EXPECT FAILURE "constant.tests 21":
179module m { const unsigned short C = -1; };
180
181
182EXPECT FAILURE "constant.tests 22":
183module m { const unsigned short C = -01; };
184
185
186EXPECT FAILURE "constant.tests 23":
187module m { const unsigned short C = -0x1; };
188
189
190EXPECT FAILURE "constant.tests 24":
191module m { const unsigned short C = 65536; };
192
193
194EXPECT FAILURE "constant.tests 25":
195module m { const unsigned short C = 0200000; };
196
197
198EXPECT FAILURE "constant.tests 26":
199module m { const unsigned short C = 0x10000; };
200
201
202EXPECT FAILURE "constant.tests 27":
203module m { const long C = -2147483649; };
204
205
206EXPECT FAILURE "constant.tests 28":
207module m { const long C = -020000000001; };
208
209
210EXPECT FAILURE "constant.tests 29":
211module m { const long C = -0x80000001; };
212
213
214EXPECT FAILURE "constant.tests 30":
215module m { const long C = 2147483648; };
216
217
218EXPECT FAILURE "constant.tests 31":
219module m { const long C = 020000000000; };
220
221
222EXPECT FAILURE "constant.tests 32":
223module m { const long C = 0x80000000; };
224
225
226EXPECT FAILURE "constant.tests 33":
227module m { const unsigned long C = -1; };
228
229
230EXPECT FAILURE "constant.tests 34":
231module m { const unsigned long C = -01; };
232
233
234EXPECT FAILURE "constant.tests 35":
235module m { const unsigned long C = -0x1; };
236
237
238EXPECT FAILURE "constant.tests 36":
239module m { const unsigned long C = 4294967296; };
240
241
242EXPECT FAILURE "constant.tests 37":
243module m { const unsigned long C = 040000000000; };
244
245
246EXPECT FAILURE "constant.tests 38":
247module m { const unsigned long C = 0x100000000; };
248
249
250EXPECT FAILURE "constant.tests 39":
251module m { const hyper C = -9223372036854775809; };
252
253
254EXPECT FAILURE "constant.tests 40":
255module m { const hyper C = -01000000000000000000001; };
256
257
258EXPECT FAILURE "constant.tests 41":
259module m { const hyper C = -0x8000000000000001; };
260
261
262EXPECT FAILURE "constant.tests 42":
263module m { const hyper C = 9223372036854775808; };
264
265
266EXPECT FAILURE "constant.tests 43":
267module m { const hyper C = 01000000000000000000000; };
268
269
270EXPECT FAILURE "constant.tests 44":
271module m { const hyper C = 0x8000000000000000; };
272
273
274EXPECT FAILURE "constant.tests 45":
275module m { const unsigned hyper C = -1; };
276
277
278EXPECT FAILURE "constant.tests 46":
279module m { const unsigned hyper C = -01; };
280
281
282EXPECT FAILURE "constant.tests 47":
283module m { const unsigned hyper C = -0x1; };
284
285
286EXPECT FAILURE "constant.tests 48":
287module m { const unsigned hyper C = 18446744073709551616; };
288
289
290EXPECT FAILURE "constant.tests 49":
291module m { const unsigned hyper C = 02000000000000000000000; };
292
293
294EXPECT FAILURE "constant.tests 50":
295module m { const unsigned hyper C = 0x10000000000000000; };
296