* tuples.ch, tuples.exp, Makefile.in: New test case.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.chill / tuples.exp
1 # Copyright (C) 1995 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Per Bothner. (bothner@cygnus.com)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 proc do_tests {} {
27 global prms_id bug_id subdir objdir srcdir binfile prompt
28
29 set prms_id 0
30 set bug_id 0
31
32 # Start with a fresh gdb.
33
34 gdb_exit
35 gdb_start
36 gdb_reinitialize_dir $srcdir/$subdir
37 gdb_load $objdir/$subdir/$binfile
38
39 send "set language chill\n" ; expect -re "$prompt $"
40
41 runto tuples.ch:31
42
43 gdb_test_exact "print v_arri" {= [(1): -1, (2): -2, (3): -3, (4): -4, (5): -5]}
44 send "set v_arri := \[ 33, 44, 55, 66, 77 \]\n" ; expect -re "$prompt $"
45 gdb_test_exact "print v_arri" {= [(1): 33, (2): 44, (3): 55, (4): 66, (5): 77]} "after assignment 1 to v_arri"
46 send "set v_arri := \[-33, -44, -55, -66, -77\]\n"; expect -re "$prompt $"
47 gdb_test_exact "print v_arri" {= [(1): -33, (2): -44, (3): -55, (4): -66, (5): -77]} {after assignment 2 to v_arri}
48
49 gdb_test_exact "print v_arrui" {= [(1): 1, (2): 2, (3): 3, (4): 4, (5): 5]}
50 send "set v_arrui := \[ 11, 11, 11, 11, 11 \]\n"; expect -re "$prompt $"
51 gdb_test_exact "print v_arrui" {= [(1:5): 11]} "after assignment to v_arrui"
52
53 gdb_test_exact "print v_arrb" {= [(1): -3, (2): -4, (3): -5, (4): -6, (5): -7]}
54
55 send "set v_arrb := \[ -9, -8, -7, -6, -5 \]\n"; expect -re "$prompt $"
56 gdb_test_exact "print v_arrb" {= [(1): -9, (2): -8, (3): -7, (4): -6, (5): -5]} "after assignment to v_arrb"
57
58 gdb_test_exact "print v_arrub" {= [(1): 3, (2): 4, (3): 5, (4): 6, (5): 7]}
59 send "set v_arrub := \[ 77, 77, 77, 77, 77 \]\n"; expect -re "$prompt $"
60 gdb_test_exact "print v_arrub" {= [(1:5): 77]} "v_arrub after assignment"
61
62 gdb_test_exact "print j" {= 4}
63 gdb_test_exact "print j := 3+4" {= 7}
64 gdb_test_exact "print j := r1(3)" {= 3}
65
66 gdb_test_exact "print v_arrc" {= [(1): '1', (2): '2', (3): '3', (4): '4', (5): '5']}
67 send "set v_arrc := \[ 'a', 'b', 'c', 'd', 'e' \]\n"; expect -re "$prompt $"
68 gdb_test_exact "print v_arrc" {= [(1): 'a', (2): 'b', (3): 'c', (4): 'd', (5): 'e']} "v_arrc after assignment"
69
70 gdb_test_exact "print v_ps" {= [1, 3, 5]}
71 send "set v_ps := \[ 2, 4 \]\n"; expect -re "$prompt $"
72 gdb_test_exact "print v_ps" {= [2, 4]}
73 gdb_test_exact "print v_ps := \[\]" {= []} {assign [] to v_ps}
74
75 gdb_test_exact "print m_arri\[1, 2, 3, 4, 5\]" {= [(1): 1, (2): 2, (3): 3, (4): 4, (5): 5]}
76 gdb_test_exact "print m_arrub\[45, 46, 47, 48, 49\]" {= [(1): 45, (2): 46, (3): 47, (4): 48, (5): 49]}
77
78 gdb_test_exact "print v_cv" {= "foo"}
79 send "set v_cv := \"foo-bar\"\n"; expect -re "$prompt $"
80 gdb_test_exact "print v_cv" {= "foo-bar"} "v_cv after assignment"
81 send "print v_cv(3) := ' '\n"; expect -re "$prompt $"
82 gdb_test_exact "print v_cv" {= "foo bar"} "v_cv after element assignment"
83
84 gdb_test_exact "print v_arrbool" {= [(1): TRUE, (2): FALSE, (3): TRUE, (4): FALSE, (5): TRUE]}
85 send "set v_arrbool := \[ false, false, false, false, false \]\n"
86 expect -re "$prompt $"
87 gdb_test_exact "print v_arrbool" {= [(1:5): FALSE]} "v_arrbool after assignment 1"
88 send "set v_arrbool := \[true, true, true, true, true\]\n"
89 expect -re "$prompt $"
90 gdb_test_exact "print v_arrbool" {= [(1:5): TRUE]} "v_arrbool after assignment 2"
91 send "set v_arrbool(3) := false\n"; expect -re "$prompt $"
92 gdb_test_exact "print v_arrbool" {= [(1:2): TRUE, (3): FALSE, (4:5): TRUE]} "v_arrbool after element assignment"
93
94 send "set v_arrbool(1 up 2) := \[ false, true \]\n"
95 expect -re "$prompt $"
96 gdb_test_exact "print v_arrbool" {= [(1): FALSE, (2): TRUE, (3): FALSE, (4:5): TRUE]} "v_arrbool after slice assignment 1"
97 send "set v_arrbool(3 : 5) := \[ true, true, false \]\n"
98 expect -re "$prompt $"
99 gdb_test_exact "print v_arrbool" {= [(1): FALSE, (2:4): TRUE, (5): FALSE]} "v_arrbool after slice assignment 2"
100 }
101
102 # Check to see if we have an executable to test. If not, then either we
103 # haven't tried to compile one, or the compilation failed for some reason.
104 # In either case, just notify the user and skip the tests in this file.
105
106 set binfile "tuples.exe"
107 set srcfile $binfile.ch
108
109 if ![file exists $objdir/$subdir/$binfile] then {
110 warning "$binfile does not exist; tests suppressed."
111 } else {
112 do_tests
113 }
This page took 0.032196 seconds and 4 git commands to generate.