2012-01-16 Pedro Alves <palves@redhat.com>
[external/binutils.git] / gdb / testsuite / gdb.fortran / types.exp
1 # Copyright 1994-1995, 1997-1998, 2007-2012 Free Software Foundation,
2 # Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # This file was adapted from old Chill tests by Stan Shebs
18 # (shebs@cygnus.com).
19
20 load_lib "fortran.exp"
21
22 if { [skip_fortran_tests] } { continue }
23
24 proc test_integer_literal_types_accepted {} {
25     global gdb_prompt
26
27     # Test various decimal values.
28     # Should be integer*4 probably.
29     gdb_test "pt 123" "type = int" 
30 }
31
32 proc test_character_literal_types_accepted {} {
33     global gdb_prompt
34
35     # Test various character values.
36
37     gdb_test "pt 'a'" "type = character\\*1"
38 }
39
40 proc test_integer_literal_types_rejected {} {
41     global gdb_prompt
42
43     test_print_reject "pt _"
44 }
45
46 proc test_logical_literal_types_accepted {} {
47     global gdb_prompt
48
49     # Test the only possible values for a logical, TRUE and FALSE.
50
51     gdb_test "pt .TRUE." "type = logical\\*2"
52     gdb_test "pt .FALSE." "type = logical\\*2"
53 }
54
55 proc test_float_literal_types_accepted {} {
56     global gdb_prompt
57
58     # Test various floating point formats
59
60     # this used to guess whether to look for "real*4" or
61     # "real*8" based on a target config variable, but noone
62     # maintained it properly.
63
64     gdb_test "pt .44" "type = real\\*\[0-9\]+"
65     gdb_test "pt 44.0" "type = real\\*\[0-9\]+"
66     gdb_test "pt 10D20" "type = real\\*\[0-9\]+"
67     gdb_test "pt 10D20" "type = real\\*\[0-9\]+"
68     gdb_test "pt 10d20" "type = real\\*\[0-9\]+"
69     gdb_test "pt 10d20" "type = real\\*\[0-9\]+"
70     gdb_test "pt 10E20" "type = real\\*\[0-9\]+"
71     gdb_test "pt 10E20" "type = real\\*\[0-9\]+"
72     gdb_test "pt 10e20" "type = real\\*\[0-9\]+"
73     gdb_test "pt 10e20" "type = real\\*\[0-9\]+"
74 }
75
76 # Start with a fresh gdb.
77
78 gdb_exit
79 gdb_start
80 gdb_reinitialize_dir $srcdir/$subdir
81
82 gdb_test "set print sevenbit-strings" ""
83
84 if [set_lang_fortran] then {
85     test_integer_literal_types_accepted
86     test_integer_literal_types_rejected
87     test_logical_literal_types_accepted
88     test_character_literal_types_accepted
89     test_float_literal_types_accepted
90 } else {
91     warning "$test_name tests suppressed." 0
92 }