]>
Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 1999-2016 Free Software Foundation, Inc. |
2dcad5ea JM |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
2dcad5ea | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
2dcad5ea JM |
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. | |
e22f8b7c | 12 | # |
2dcad5ea | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2dcad5ea | 15 | |
ec3c07fc NS |
16 | load_lib "java.exp" |
17 | ||
18 | if { [skip_java_tests] } { continue } | |
19 | ||
2dcad5ea JM |
20 | proc test_integer_literals_accepted {} { |
21 | global gdb_prompt | |
22 | ||
23 | # Test various decimal values. | |
24 | ||
25 | gdb_test "p 123" " = 123" | |
26 | gdb_test "p -123" " = -123" | |
27 | gdb_test "p/d 123" " = 123" | |
28 | ||
29 | # Test various octal values. | |
30 | ||
31 | gdb_test "p 0123" " = 83" | |
32 | gdb_test "p 00123" " = 83" | |
33 | gdb_test "p -0123" " = -83" | |
34 | gdb_test "p/o 0123" " = 0123" | |
35 | ||
36 | # Test various hexadecimal values. | |
37 | ||
38 | gdb_test "p 0x123" " = 291" | |
39 | gdb_test "p -0x123" " = -291" | |
40 | gdb_test "p 0x0123" " = 291" | |
41 | gdb_test "p -0x0123" " = -291" | |
42 | gdb_test "p 0xABCDEF" " = 11259375" | |
43 | gdb_test "p 0xabcdef" " = 11259375" | |
44 | gdb_test "p 0xAbCdEf" " = 11259375" | |
45 | gdb_test "p/x 0x123" " = 0x123" | |
46 | } | |
47 | ||
48 | proc test_character_literals_accepted {} { | |
49 | global gdb_prompt | |
50 | ||
51 | gdb_test "p 'a'" " = 'a'" | |
52 | gdb_test "p/c 'a'" " = 'a'" | |
53 | gdb_test "p/c 70" " = 'F'" | |
54 | gdb_test "p/x 'a'" " = 0x61" | |
55 | gdb_test "p/d 'a'" " = 97" | |
56 | gdb_test "p/t 'a'" " = 1100001" | |
57 | gdb_test "p/x '\\377'" " = 0xff" | |
58 | gdb_test "p '\\''" " = '\\\\''" | |
59 | # Note "p '\\'" => "= 92 '\\'" | |
60 | gdb_test "p '\\\\'" " = '\\\\\\\\'" | |
61 | ||
62 | # Test the /c print format. | |
63 | } | |
64 | ||
65 | proc test_integer_literals_rejected {} { | |
66 | global gdb_prompt | |
67 | ||
68 | test_print_reject "p 0x" | |
5415e7c5 MK |
69 | gdb_test "p ''" "Empty character constant" |
70 | gdb_test "p '''" "Empty character constant" | |
2dcad5ea JM |
71 | test_print_reject "p '\\'" |
72 | ||
73 | # Note that this turns into "p '\\\'" at gdb's input. | |
74 | test_print_reject "p '\\\\\\'" | |
75 | ||
76 | # Test various decimal values. | |
77 | ||
78 | test_print_reject "p DEADBEEF" | |
79 | ||
80 | test_print_reject "p 123DEADBEEF" | |
81 | test_print_reject "p 123foobar.bazfoo3" | |
82 | test_print_reject "p 123EEEEEEEEEEEEEEEEE33333k333" | |
83 | gdb_test "p 123.4+56.7" "180.(099\[0-9]*|100\[0-9\]*)" "check for floating addition" | |
84 | ||
85 | # Test various octal values. | |
86 | ||
87 | test_print_reject "p 09" | |
88 | test_print_reject "p 079" | |
89 | ||
90 | # Test various hexadecimal values. | |
91 | ||
92 | test_print_reject "p 0xG" | |
93 | test_print_reject "p 0xAG" | |
94 | } | |
95 | ||
d30f5e1f | 96 | proc test_float_accepted {} { |
809df446 JK |
97 | global gdb_prompt |
98 | ||
d30f5e1f DE |
99 | # Test parsing of fp value with legit text following. |
100 | gdb_test "p 1234.5+1" " = 1235.5" "check fp + text" | |
101 | ||
102 | # Test all the suffixes (including no suffix). | |
103 | gdb_test "p 1." " = 1" | |
104 | gdb_test "p 1.5" " = 1.5" | |
105 | gdb_test "p 1.f" " = 1" | |
106 | gdb_test "p 1.5f" " = 1.5" | |
107 | gdb_test "p 1.d" " = 1" | |
108 | gdb_test "p 1.5d" " = 1.5" | |
809df446 JK |
109 | |
110 | # Test hexadecimal floating point. | |
111 | set test "p 0x1.1" | |
112 | gdb_test_multiple $test $test { | |
113 | -re " = 1\\.0625\r\n$gdb_prompt $" { | |
114 | pass $test | |
115 | } | |
116 | -re "Invalid number \"0x1\\.1\"\r\n$gdb_prompt $" { | |
117 | # Older glibc does not support hex float, newer does. | |
118 | xfail $test | |
119 | } | |
120 | } | |
d30f5e1f DE |
121 | } |
122 | ||
123 | proc test_float_rejected {} { | |
d30f5e1f DE |
124 | # Test bad suffixes. |
125 | test_print_reject "p 1.1x" | |
126 | test_print_reject "p 1.1ff" | |
127 | test_print_reject "p 1.1dd" | |
128 | } | |
2dcad5ea JM |
129 | |
130 | ||
131 | # Start with a fresh gdb. | |
132 | ||
133 | gdb_exit | |
134 | gdb_start | |
135 | gdb_reinitialize_dir $srcdir/$subdir | |
136 | ||
137 | gdb_test "print \$pc" "No registers\\." | |
138 | # FIXME: should also test "print $pc" when there is an execfile but no | |
139 | # remote debugging target, process or corefile. | |
140 | ||
141 | gdb_test "set print sevenbit-strings" "" | |
142 | gdb_test "set print address off" "" "" | |
143 | gdb_test "set width 0" "" | |
144 | ||
145 | if [set_lang_java] then { | |
146 | test_integer_literals_accepted | |
147 | test_character_literals_accepted | |
148 | test_integer_literals_rejected | |
d30f5e1f DE |
149 | test_float_accepted |
150 | test_float_rejected | |
2dcad5ea | 151 | } else { |
f1208f9e | 152 | warning "Java print command tests suppressed" |
2dcad5ea | 153 | } |