binutils-gdb/gdb/testsuite/gdb.chill/gch981.exp
1996-04-09 08:19:58 +00:00

250 lines
9.8 KiB
Plaintext

# Copyright (C) 1995 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# This file tests various Chill values, expressions, and types.
# This file was written by Wilfried Moser (moser@aut.alcatel.at)
# Kurt Fuchs (fuchs_k@aut.alcatel.at)
#
if $tracelevel then {
strace $tracelevel
}
if [skip_chill_tests] then { continue }
set testfile "gch981"
set srcfile ${srcdir}/$subdir/${testfile}.ch
set binfile ${objdir}/${subdir}/${testfile}.exe
if { [compile "${srcfile} -g -w -o ${binfile} ${CHILL_RT0} ${CHILL_LIB}"] != "" } {
perror "Couldn't compile ${srcfile}"
return -1
}
# Set the current language to chill. This counts as a test. If it
# fails, then we skip the other tests.
proc set_lang_chill {} {
global prompt
global binfile objdir subdir
verbose "loading file '$binfile'"
gdb_load $binfile
send "set language chill\n"
expect {
-re ".*$prompt $" {}
timeout { fail "set language chill (timeout)" ; return 0 }
}
send "show language\n"
expect {
-re ".* source language is \"chill\".*$prompt $" {
pass "set language to \"chill\""
send "break xx_\n"
expect {
-re ".*$prompt $" {
send "run\n"
expect -re ".*$prompt $" {}
return 1
}
timeout {
fail "can't set breakpoint (timeout)"
return 0
}
}
}
-re ".*$prompt $" {
fail "setting language to \"chill\""
return 0
}
timeout {
fail "can't show language (timeout)"
return 0
}
}
}
# Testing printing of a specific value. Increment passcount for
# success or issue fail message for failure. In both cases, return
# a 1 to indicate that more tests can proceed. However a timeout
# is a serious error, generates a special fail message, and causes
# a 0 to be returned to indicate that more tests are likely to fail
# as well.
#
# Args are:
#
# First one is string to send to gdb
# Second one is string to match gdb result to
# Third one is an optional message to be printed
proc test_print_accept { args } {
global prompt
global passcount
global verbose
if [llength $args]==3 then {
set message [lindex $args 2]
} else {
set message [lindex $args 0]
}
set sendthis [lindex $args 0]
set expectthis [lindex $args 1]
set result [gdb_test $sendthis ".* = ${expectthis}" $message]
if $result==0 {incr passcount}
return $result
}
proc test_power {} {
global passcount prompt
verbose "Testing some POWERSET Stuff"
set passcount 0
test_print_accept "print v1_power1" {\[e1:e5\]}
test_print_accept "print v2_power1" {\[\]}
test_print_accept "print SIZE(v1_power1)" "1"
send "set v1_power1 := \[b1\] \n" ; expect -re "$prompt $"
# if GDB has rejected the improper values, we have to expect the same!
test_print_accept "print v1_power1" {\[e1:e5\]}
send "set v1_power1 := \[a1,a2\] \n" ; expect -re "$prompt $"
test_print_accept "print v1_power1" {\[e1:e5\]}
send "set v1_power1 := \[b1,b2,b3,e4\] \n" ; expect -re "$prompt $"
test_print_accept "print v1_power1" {\[e1:e5\]}
send "set v1_power1 := \[e4:e5\] \n" ; expect -re "$prompt $"
test_print_accept "print v1_power1" {\[e4:e5\]}
send "set v1_power1 := \[e1, e2:e3, e5\] \n" ; expect -re "$prompt $"
test_print_accept "print v1_power1" {\[e1:e3, e5\]}
send "set v1_power1 := \[e1, e2:e4, e4:e5\] \n" ; expect -re "$prompt $"
test_print_accept "print v1_power1" {\[e1:e5\]}
send "set v1_power1 := \[e1, e1:e3, e1:e2, e2:e3\] \n" ; expect -re "$prompt $"
test_print_accept "print v1_power1" {\[e1:e3\]}
send "set v_power2 := \[e2\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power2" {\[\]}
send "set v_power2 := \[1,2,3\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power2" {\[\]}
send "set v_power2 := \[e2, b2, b1\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power2" {\[\]}
# Note, that this is a numbered SET, so a1:a3 contains all elements (exept a6)
send "set v_power2 := \[a1:a3, a6:a4, a7:a9\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power2" {\[a6:a3\]}
send "set v_power2 := \[a1, a4:a6, a9\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power2" {\[a1, a9\]}
send "set v_power2 := \[a1:a2, a6, a9\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power2" {\[a6:a2, a9\]}
send "set v_power2 := \[a1, a4, a7:a8, a9:a3\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power2" {\[a1, a4, a9:a8\]}
send "set v_power2 := \[a1, a4:a8\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power2" {\[a1, a4:a8\]}
send "set v_power2 := \[a8,a3,a7,a9,a5,a6\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power2" {\[a6, a5, a9, a7, a3, a8\]}
send "set v_power3 := \[b1:b2,e1\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power3" {\[b1:b2\]}
send "set v_power3 := \[b1, b3, b6:b7\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power3" {\[b1, b3, b6:b7\]}
send "set v_power3 := \[b1, b3:b4, b7\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power3" {\[b1, b3:b4, b7\]}
send "set v_power3 := \[b1, b4:b6, b7\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power3" {\[b1, b4:b7\]}
send "set v_power3 := \[b1:b7\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power3" {\[b1:b7\]}
send "set v_power3 := \[b5:b7, b1\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power3" {\[b1, b5:b7\]}
send "set v_power4 := \[\"b\"\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power4" {\['b':'x'\]}
send "set v_power4 := \[5\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power4" {\['b':'x'\]}
send "set v_power4 := \['c':'f','g':'h','o':'t'\]\n"; expect -re "$prompt $"
test_print_accept "print v_power4" {\['c':'h', 'o':'t'\]}
send "set v_power4 := \['a','b','c','d','e','f'\]\n"; expect -re "$prompt $"
test_print_accept "print v_power4" {\['a':'f'\]}
send "set v_power4 := \['\^(0)':'\^(200)'\]\n"; expect -re "$prompt $"
test_print_accept "print v_power4" {\['\^\(0\)':'\^\(200\)'\]}
send "set v_power5 := \[a8\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power5" {\[2:100\]}
send "set v_power5 := \[4\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power5" {\[4\]}
send "set v_power5 := \[3:95,9:100,10:107,200:250\]\n" ; expect -re "$prompt $"
test_print_accept "print v_power5" {\[3:107, 200:250\]}
send "set v_power5 := \[2, 100:120, 350:400\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power5" {\[2, 100:120, 350:400\]}
send "set v_power5 := \[2:64,65:127,128:256,256:399,400\]\n" ; expect -re "$prompt $"
test_print_accept "print v_power5" {\[2:400\]}
send "set v_power5 := \[3:95, 99:100, 101:107, 200:250\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power5" {\[3:95, 99:107, 200:250\]}
send "set v_power6 := \[a8\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power6" {\[\]}
send "set v_power6 := \[4\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power6" {\[4\]}
send "set v_power6 := \[3:95, 99:100, 101:107, 200:250\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power6" {\[3:95, 99:107, 200:250\]}
send "set v_power6 := \[-111:0, 1:112, 11111:22222\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power6" {\[-111:112, 11111:22222\]}
send "set v_power6 := \[0, 200:4000, 6666:9999\] \n" ; expect -re "$prompt $"
test_print_accept "print v_power6" {\[0, 200:4000, 6666:9999\]}
# send "set v_power7 := \[a8\] \n" ; expect -re "$prompt $"
# test_print_accept "print v_power7" {\[2:100\]}
# send "set v_power7 := \[4\] \n" ; expect -re "$prompt $"
# test_print_accept "print v_power7" {\[4\]}
# send "set v_power7 := \[3:95, 99:100, 101:107, 200:250\]\n" ; expect -re "$prompt $"
# test_print_accept "print v_power7" {\[3:95, 99:107, 200:250\]}
# send "set v_power7 := \[0, 1000, 1000000, 10000000000\] \n" ; expect -re "$prompt $"
# test_print_accept "print v_power7" {\[0, 1000, 1000000, 1000000000\]}
# send "set v_power7 := \[-20000:100000, 111111:2222222\] \n" ; expect -re "$prompt $"
# test_print_accept "print v_power7" {\[-20000:100000, 111111:2222222\]}
# send "set v_power7 := \[\] \n" ; expect -re "$prompt $"
# test_print_accept "print v_power7" {\[3:95, 99:107, 200:250\]}
# send "set v_power7 := \[2:-500, -501:1, 20:370, -888:-920, 1000:2000, 1800:2500\]\ \n" ; expect -re "$prompt $"
# test_print_accept "print v_power7" {\[-920:-888, -501:2, 20:370, 1000:2500\]}
# test_print_accept "print SIZE(v_power7)" ""
runto 58
test_print_accept "print v_set1 IN v1_power1" "TRUE"
test_print_accept "print v_set1 IN v2_power1" "FALSE"
}
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
send "set print sevenbit-strings\n" ; expect -re ".*$prompt $"
if [set_lang_chill] then {
# test builtins as described in chapter 6.20.3 Z.200
test_power
} else {
warning "$test_name tests suppressed."
}