* lib/gdb.exp (gdb_compile_test): New.
[external/binutils.git] / gdb / testsuite / gdb.fortran / types.exp
1 # Copyright 1994, 1995, 1997, 1998, 2007 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 adapted from old Chill tests by Stan Shebs
21 # (shebs@cygnus.com).
22
23 if $tracelevel then {
24         strace $tracelevel
25 }
26
27 if { [skip_fortran_tests] } { continue }
28
29 set prms_id 0
30 set bug_id 0
31
32 # Set the current language to fortran.  This counts as a test.  If it
33 # fails, then we skip the other tests.
34
35 proc set_lang_fortran {} {
36     global gdb_prompt
37     
38     if [gdb_test "set language fortran" ""] {
39         return 0;
40     }
41
42     if ![gdb_test "show language" ".* source language is \"fortran\".*"] {
43         return 1;
44     } else {
45         return 0;
46     }
47 }
48
49 proc test_integer_literal_types_accepted {} {
50     global gdb_prompt
51
52     # Test various decimal values.
53     # Should be integer*4 probably.
54     gdb_test "pt 123" "type = int" 
55 }
56
57 proc test_character_literal_types_accepted {} {
58     global gdb_prompt
59
60     # Test various character values.
61
62     gdb_test "pt 'a'" "type = character\\*1"
63 }
64
65 proc test_integer_literal_types_rejected {} {
66     global gdb_prompt
67
68     test_print_reject "pt _"
69 }
70
71 proc test_logical_literal_types_accepted {} {
72     global gdb_prompt
73
74     # Test the only possible values for a logical, TRUE and FALSE.
75
76     gdb_test "pt .TRUE." "type = logical\\*2"
77     gdb_test "pt .FALSE." "type = logical\\*2"
78 }
79
80 proc test_float_literal_types_accepted {} {
81     global gdb_prompt
82
83     # Test various floating point formats
84
85     # this used to guess whether to look for "real*4" or
86     # "real*8" based on a target config variable, but noone
87     # maintained it properly.
88
89     gdb_test "pt .44" "type = real\\*\[0-9\]+"
90     gdb_test "pt 44.0" "type = real\\*\[0-9\]+"
91     gdb_test "pt 10D20" "type = real\\*\[0-9\]+"
92     gdb_test "pt 10D20" "type = real\\*\[0-9\]+"
93     gdb_test "pt 10d20" "type = real\\*\[0-9\]+"
94     gdb_test "pt 10d20" "type = real\\*\[0-9\]+"
95     gdb_test "pt 10E20" "type = real\\*\[0-9\]+"
96     gdb_test "pt 10E20" "type = real\\*\[0-9\]+"
97     gdb_test "pt 10e20" "type = real\\*\[0-9\]+"
98     gdb_test "pt 10e20" "type = real\\*\[0-9\]+"
99 }
100
101 # Start with a fresh gdb.
102
103 gdb_exit
104 gdb_start
105 gdb_reinitialize_dir $srcdir/$subdir
106
107 gdb_test "set print sevenbit-strings" ""
108
109 if [set_lang_fortran] then {
110     test_integer_literal_types_accepted
111     test_integer_literal_types_rejected
112     test_logical_literal_types_accepted
113     test_character_literal_types_accepted
114     test_float_literal_types_accepted
115 } else {
116     warning "$test_name tests suppressed." 0
117 }