1 # Copyright (C) 1995 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file tests various Chill values, expressions, and types.
26 if [skip_chill_tests] then { continue }
28 set testfile "builtins"
29 set srcfile ${srcdir}/$subdir/${testfile}.ch
30 set binfile ${objdir}/${subdir}/${testfile}.exe
31 if { [compile "${srcfile} -g -w -o ${binfile} ${CHILL_RT0} ${CHILL_LIB}"] != "" } {
32 perror "Couldn't compile ${srcfile}"
36 # Set the current language to chill. This counts as a test. If it
37 # fails, then we skip the other tests.
39 proc set_lang_chill {} {
41 global binfile objdir subdir
43 verbose "loading file '$binfile'"
45 send_gdb "set language chill\n"
48 timeout { fail "set language chill (timeout)" ; return 0 }
51 send_gdb "show language\n"
53 -re ".* source language is \"chill\".*$prompt $" {
54 pass "set language to \"chill\""
55 send_gdb "break xx_\n"
59 expect -re ".*$prompt $" {}
63 fail "can't set breakpoint (timeout)"
69 fail "setting language to \"chill\""
73 fail "can't show language (timeout)"
79 # Testing printing of a specific value. Increment passcount for
80 # success or issue fail message for failure. In both cases, return
81 # a 1 to indicate that more tests can proceed. However a timeout
82 # is a serious error, generates a special fail message, and causes
83 # a 0 to be returned to indicate that more tests are likely to fail
88 # First one is string to send_gdb to gdb
89 # Second one is string to match gdb result to
90 # Third one is an optional message to be printed
92 proc test_print_accept { args } {
97 if [llength $args]==3 then {
98 set message [lindex $args 2]
100 set message [lindex $args 0]
102 set sendthis [lindex $args 0]
103 set expectthis [lindex $args 1]
104 set result [gdb_test $sendthis ".* = ${expectthis}" $message]
105 if $result==0 {incr passcount}
112 verbose "testing builtin LOWER"
115 # discrete mode names
116 test_print_accept "print lower(bool)" "FALSE"
117 test_print_accept "print lower(char)" {'\^[(]0[)]'}
118 test_print_accept "print lower(byte)" "-128"
119 test_print_accept "print lower(ubyte)" "0"
120 if [istarget "alpha-*-*"] then {
121 test_print_accept "print lower(int)" "-2147483648"
123 test_print_accept "print lower(int)" "-32768"
125 test_print_accept "print lower(uint)" "0"
126 setup_xfail "alpha-*-*"
127 test_print_accept "print lower(long)" "-2147483648"
128 test_print_accept "print lower(ulong)" "0"
129 test_print_accept "print lower(m_set)" "e1"
130 test_print_accept "print lower(m_set_range)" "e2"
131 test_print_accept "print lower(m_numbered_set)" "n2"
132 test_print_accept "print lower(m_char_range)" "'A'"
133 test_print_accept "print lower(m_bool_range)" "FALSE"
134 test_print_accept "print lower(m_long_range)" "255"
135 test_print_accept "print lower(m_range)" "12"
138 test_print_accept "print lower(v_bool)" "FALSE"
139 test_print_accept "print lower(v_char)" {'\^[(]0[)]'}
140 test_print_accept "print lower(v_byte)" "-128"
141 test_print_accept "print lower(v_ubyte)" "0"
142 if [istarget "alpha-*-*"] then {
143 test_print_accept "print lower(v_int)" "-2147483648"
145 test_print_accept "print lower(v_int)" "-32768"
147 test_print_accept "print lower(v_uint)" "0"
148 setup_xfail "alpha-*-*"
149 test_print_accept "print lower(v_long)" "-2147483648"
150 test_print_accept "print lower(v_ulong)" "0"
151 test_print_accept "print lower(v_set)" "e1"
152 test_print_accept "print lower(v_set_range)" "e2"
153 test_print_accept "print lower(v_numbered_set)" "n2"
154 test_print_accept "print lower(v_char_range)" "'A'"
155 test_print_accept "print lower(v_bool_range)" "FALSE"
156 test_print_accept "print lower(v_long_range)" "255"
157 test_print_accept "print lower(v_range)" "12"
160 test_print_accept "print lower(m_chars)" "0"
161 test_print_accept "print lower(m_chars_v)" "0"
162 test_print_accept "print lower(m_bits)" "0"
165 test_print_accept "print lower(v_chars)" "0"
166 test_print_accept "print lower(v_chars_v)" "0"
167 test_print_accept "print lower(v_bits)" "0"
170 test_print_accept "print lower(\"abcd\")" "0"
171 test_print_accept "print lower(B'010101')" "0"
174 test_print_accept "print lower(m_arr)" "1";
175 test_print_accept "print lower(m_char_arr)" {'\^[(]0[)]'}
176 test_print_accept "print lower(m_bool_arr)" "FALSE"
177 if [istarget "alpha-*-*"] then {
178 test_print_accept "print lower(m_int_arr)" "-2147483648"
180 test_print_accept "print lower(m_int_arr)" "-32768"
182 test_print_accept "print lower(m_set_arr)" "e1"
183 test_print_accept "print lower(m_set_range_arr)" "e2"
184 test_print_accept "print lower(m_numbered_set_arr)" "n2"
185 test_print_accept "print lower(m_char_range_arr)" "'A'"
186 test_print_accept "print lower(m_bool_range_arr)" "FALSE"
187 test_print_accept "print lower(m_long_range_arr)" "255"
188 test_print_accept "print lower(m_range_arr)" "12"
191 test_print_accept "print lower(v_arr)" "1";
192 test_print_accept "print lower(v_char_arr)" {'\^[(]0[)]'}
193 test_print_accept "print lower(v_bool_arr)" "FALSE"
194 if [istarget "alpha-*-*"] then {
195 test_print_accept "print lower(v_int_arr)" "-2147483648"
197 test_print_accept "print lower(v_int_arr)" "-32768"
199 test_print_accept "print lower(v_set_arr)" "e1"
200 test_print_accept "print lower(v_set_range_arr)" "e2"
201 test_print_accept "print lower(v_numbered_set_arr)" "n2"
202 test_print_accept "print lower(v_char_range_arr)" "'A'"
203 test_print_accept "print lower(v_bool_range_arr)" "FALSE"
204 test_print_accept "print lower(v_long_range_arr)" "255"
205 test_print_accept "print lower(v_range_arr)" "12"
211 verbose "testing builtin UPPER"
214 # discrete mode names
215 test_print_accept "print upper(bool)" "TRUE"
216 test_print_accept "print upper(char)" {'\^[(]255[)]'}
217 test_print_accept "print upper(byte)" "127"
218 test_print_accept "print upper(ubyte)" "255"
219 if [istarget "alpha-*-*"] then {
220 test_print_accept "print upper(int)" "2147483647"
221 test_print_accept "print upper(uint)" "4294967295"
222 setup_xfail "alpha-*-*"
223 test_print_accept "print upper(long)" "4294967295"
224 test_print_accept "print upper(ulong)" "18446744073709551615"
226 test_print_accept "print upper(int)" "32767"
227 test_print_accept "print upper(uint)" "65535"
228 test_print_accept "print upper(long)" "2147483647"
229 test_print_accept "print upper(ulong)" "4294967295"
231 test_print_accept "print upper(m_set)" "e6"
232 test_print_accept "print upper(m_set_range)" "e5"
233 test_print_accept "print upper(m_numbered_set)" "n5"
234 test_print_accept "print upper(m_char_range)" "'Z'"
235 test_print_accept "print upper(m_bool_range)" "FALSE"
236 test_print_accept "print upper(m_long_range)" "3211"
237 test_print_accept "print upper(m_range)" "28"
240 test_print_accept "print upper(v_bool)" "TRUE"
241 test_print_accept "print upper(v_char)" {'\^[(]255[)]'}
242 test_print_accept "print upper(v_byte)" "127"
243 test_print_accept "print upper(v_ubyte)" "255"
244 if [istarget "alpha-*-*"] then {
245 test_print_accept "print upper(v_int)" "2147483647"
246 test_print_accept "print upper(v_uint)" "4294967295"
247 setup_xfail "alpha-*-*"
248 test_print_accept "print upper(v_long)" "4294967295"
249 test_print_accept "print upper(v_ulong)" "18446744073709551615"
251 test_print_accept "print upper(v_int)" "32767"
252 test_print_accept "print upper(v_uint)" "65535"
253 test_print_accept "print upper(v_long)" "2147483647"
254 test_print_accept "print upper(v_ulong)" "4294967295"
256 test_print_accept "print upper(v_set)" "e6"
257 test_print_accept "print upper(v_set_range)" "e5"
258 test_print_accept "print upper(v_numbered_set)" "n5"
259 test_print_accept "print upper(v_char_range)" "'Z'"
260 test_print_accept "print upper(v_bool_range)" "FALSE"
261 test_print_accept "print upper(v_long_range)" "3211"
262 test_print_accept "print upper(v_range)" "28"
265 test_print_accept "print upper(m_chars)" "19"
266 test_print_accept "print upper(m_chars_v)" "19"
267 test_print_accept "print upper(m_bits)" "9"
270 test_print_accept "print upper(v_chars)" "19"
271 test_print_accept "print upper(v_chars_v)" "19"
272 test_print_accept "print upper(v_bits)" "9"
275 test_print_accept "print upper(\"abcd\")" "3"
276 test_print_accept "print upper(B'010101')" "5"
279 test_print_accept "print upper(m_arr)" "10";
280 test_print_accept "print upper(m_char_arr)" {'\^[(]255[)]'}
281 test_print_accept "print upper(m_bool_arr)" "TRUE"
282 if [istarget "alpha-*-*"] then {
283 test_print_accept "print upper(m_int_arr)" "2147483647"
285 test_print_accept "print upper(m_int_arr)" "32767"
287 test_print_accept "print upper(m_set_arr)" "e6"
288 test_print_accept "print upper(m_set_range_arr)" "e5"
289 test_print_accept "print upper(m_numbered_set_arr)" "n5"
290 test_print_accept "print upper(m_char_range_arr)" "'Z'"
291 test_print_accept "print upper(m_bool_range_arr)" "FALSE"
292 test_print_accept "print upper(m_long_range_arr)" "3211"
293 test_print_accept "print upper(m_range_arr)" "28"
296 test_print_accept "print upper(v_arr)" "10";
297 test_print_accept "print upper(v_char_arr)" {'\^[(]255[)]'}
298 test_print_accept "print upper(v_bool_arr)" "TRUE"
299 if [istarget "alpha-*-*"] then {
300 test_print_accept "print upper(v_int_arr)" "2147483647"
302 test_print_accept "print upper(v_int_arr)" "32767"
304 test_print_accept "print upper(v_set_arr)" "e6"
305 test_print_accept "print upper(v_set_range_arr)" "e5"
306 test_print_accept "print upper(v_numbered_set_arr)" "n5"
307 test_print_accept "print upper(v_char_range_arr)" "'Z'"
308 test_print_accept "print upper(v_bool_range_arr)" "FALSE"
309 test_print_accept "print upper(v_long_range_arr)" "3211"
310 test_print_accept "print upper(v_range_arr)" "28"
313 proc test_length {} {
316 verbose "testing builtin LENGTH"
320 test_print_accept "print length(v_chars)" "20"
321 test_print_accept "print length(v_chars_v)" "7";
322 test_print_accept "print length(v_bits)" "10";
325 test_print_accept "print length(\"the quick brown fox ...\")" "23"
326 test_print_accept "print length(B'010101010101')" "12"
327 test_print_accept "print length(\"foo \" // \"bar\")" "7"
329 # check some failures
331 test_print_accept "print length(m_chars)" "typename in invalid context"
333 test_print_accept "print length(v_byte)" "bad argument to LENGTH builtin"
335 test_print_accept "print length(b'000000' // b'111111')" "12"
341 verbose "testing builtin SIZE"
345 test_print_accept "print size(bool)" "1"
346 test_print_accept "print size(char)" "1"
347 test_print_accept "print size(byte)" "1"
348 if [istarget "alpha-*-*"] then {
349 test_print_accept "print size(int)" "4"
350 test_print_accept "print size(ulong)" "8"
351 test_print_accept "print size(ptr)" "8"
352 test_print_accept "print size(m_chars_v)" "24"
353 test_print_accept "print size(m_struct)" "40"
355 test_print_accept "print size(int)" "2"
356 test_print_accept "print size(ulong)" "4"
357 test_print_accept "print size(ptr)" "4"
358 test_print_accept "print size(m_chars_v)" "22"
359 test_print_accept "print size(m_struct)" "36"
361 test_print_accept "print size(m_set)" "1"
362 test_print_accept "print size(m_numbered_set)" "1"
363 test_print_accept "print size(m_char_range)" "1"
364 test_print_accept "print size(m_range_arr)" "17"
365 test_print_accept "print size(m_chars)" "20"
366 test_print_accept "print size(m_bits)" "2"
369 test_print_accept "print size(v_bool)" "1"
370 test_print_accept "print size(v_char)" "1"
371 test_print_accept "print size(v_byte)" "1"
372 if [istarget "alpha-*-*"] then {
373 test_print_accept "print size(v_int)" "4"
374 test_print_accept "print size(v_ulong)" "8"
375 test_print_accept "print size(v_ptr)" "8"
376 test_print_accept "print size(v_chars_v)" "24"
377 test_print_accept "print size(v_struct)" "40"
379 test_print_accept "print size(v_int)" "2"
380 test_print_accept "print size(v_ulong)" "4"
381 test_print_accept "print size(v_ptr)" "4"
382 test_print_accept "print size(v_chars_v)" "22"
383 test_print_accept "print size(v_struct)" "36"
385 test_print_accept "print size(v_set)" "1"
386 test_print_accept "print size(v_numbered_set)" "1"
387 test_print_accept "print size(v_char_range)" "1"
388 test_print_accept "print size(v_range_arr)" "17"
389 test_print_accept "print size(v_chars)" "20"
390 test_print_accept "print size(v_bits)" "2"
396 verbose "testing builtin NUM"
400 test_print_accept "print num(false)" "0"
401 test_print_accept "print num(true)" "1"
402 test_print_accept "print num(10)" "10"
403 test_print_accept "print num(33-34)" "-1"
404 test_print_accept "print num('X')" "88"
405 test_print_accept "print num(e5)" "4"
408 test_print_accept "print num(v_bool)" "0"
409 test_print_accept "print num(v_char)" "88"
410 test_print_accept "print num(v_byte)" "-30"
411 test_print_accept "print num(v_ubyte)" "30"
412 test_print_accept "print num(v_int)" "-333"
413 test_print_accept "print num(v_uint)" "333"
414 test_print_accept "print num(v_long)" "-4444"
415 test_print_accept "print num(v_ulong)" "4444"
416 test_print_accept "print num(v_set)" "2"
417 test_print_accept "print num(v_set_range)" "2"
418 test_print_accept "print num(v_numbered_set)" "35"
419 test_print_accept "print num(v_char_range)" "71"
420 test_print_accept "print num(v_long_range)" "1000"
421 test_print_accept "print num(v_range)" "23"
424 # Start with a fresh gdb.
428 gdb_reinitialize_dir $srcdir/$subdir
430 gdb_test "set print sevenbit-strings ".*"
432 if [set_lang_chill] then {
433 # test builtins as described in chapter 6.20.3 Z.200
440 warning "$test_name tests suppressed."