Commit | Line | Data |
---|---|---|
a766d390 DE |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
618f726f | 3 | # Copyright 2012-2016 Free Software Foundation, Inc. |
a766d390 DE |
4 | # |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | # Test basic builtin types. | |
19 | # NOTE: The tests here intentionally do not require a go compiler. | |
20 | ||
21 | load_lib "go.exp" | |
22 | ||
23 | if { [skip_go_tests] } { continue } | |
24 | ||
25 | proc test_integer_literal_types_accepted {} { | |
26 | # Test various decimal values. | |
27 | ||
28 | gdb_test "pt 123" "type = int" | |
29 | ||
30 | gdb_test "pt void(42)" "type = void" | |
31 | gdb_test "pt byte(42)" "type = uint8" | |
32 | gdb_test "pt int(42)" "type = int" | |
33 | gdb_test "pt uint(42)" "type = uint" | |
34 | gdb_test "pt uintptr(42)" "type = uintptr" | |
35 | ||
36 | gdb_test "pt int8(42)" "type = int8" | |
37 | gdb_test "pt int16(42)" "type = int16" | |
38 | gdb_test "pt int32(42)" "type = int32" | |
39 | gdb_test "pt int64(42)" "type = int64" | |
40 | ||
41 | gdb_test "pt uint8(42)" "type = uint8" | |
42 | gdb_test "pt uint16(42)" "type = uint16" | |
43 | gdb_test "pt uint32(42)" "type = uint32" | |
44 | gdb_test "pt uint64(42)" "type = uint64" | |
45 | } | |
46 | ||
47 | proc test_logical_literal_types_accepted {} { | |
48 | # Test the only possible values for a logical, TRUE and FALSE. | |
49 | ||
50 | gdb_test "pt true" "type = bool" | |
51 | gdb_test "pt false" "type = bool" | |
52 | ||
53 | gdb_test "pt bool(0)" "type = bool" | |
54 | gdb_test "pt bool(1)" "type = bool" | |
55 | } | |
56 | ||
57 | proc test_character_literal_types_accepted {} { | |
58 | # Test various character values. | |
59 | ||
60 | gdb_test "pt 'a'" "type = char" | |
61 | ||
62 | # FIXME: Need more. | |
63 | } | |
64 | ||
65 | proc test_string_literal_types_accepted {} { | |
66 | # Test various string values. | |
67 | ||
68 | gdb_test "pt \"a simple string\"" "type = string" | |
69 | gdb_test "pt `a simple raw string`" "type = string" | |
70 | ||
71 | # FIXME: Need more. | |
72 | } | |
73 | ||
74 | proc test_float_literal_types_accepted {} { | |
75 | # Test various floating point formats. | |
76 | ||
77 | gdb_test "pt .44" "type = float64" | |
78 | gdb_test "pt 44.0" "type = float64" | |
79 | gdb_test "pt 10e20" "type = float64" | |
80 | gdb_test "pt 10E20" "type = float64" | |
81 | ||
82 | gdb_test "pt float32(.42)" "type = float32" | |
83 | ||
84 | gdb_test "pt float64(.42)" "type = float64" | |
85 | } | |
86 | ||
87 | proc test_complex_literal_types_accepted {} { | |
88 | # Test various complex formats. | |
89 | ||
90 | gdb_test "pt complex64(.42)" "type = complex64" | |
91 | setup_xfail "*-*-*" | |
92 | gdb_test "pt complex64(.42i1.0)" "type = complex64" | |
93 | setup_xfail "*-*-*" | |
94 | gdb_test "pt complex64(i1.0)" "type = complex64" | |
95 | ||
96 | gdb_test "pt complex128(.42)" "type = complex128" | |
97 | setup_xfail "*-*-*" | |
98 | gdb_test "pt complex128(.42i1.0)" "type = complex128" | |
99 | setup_xfail "*-*-*" | |
100 | gdb_test "pt complex128(i1.0)" "type = complex128" | |
101 | } | |
102 | ||
103 | # Start with a fresh gdb. | |
104 | ||
105 | gdb_exit | |
106 | gdb_start | |
107 | gdb_reinitialize_dir $srcdir/$subdir | |
108 | ||
109 | if [set_lang_go] { | |
110 | test_integer_literal_types_accepted | |
111 | test_logical_literal_types_accepted | |
112 | test_character_literal_types_accepted | |
113 | test_string_literal_types_accepted | |
114 | test_float_literal_types_accepted | |
115 | test_complex_literal_types_accepted | |
116 | } else { | |
117 | warning "Go type tests suppressed." | |
118 | } |