summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.go/basic-types.exp
blob: 107e2220431205539cf34adf6d7b3460dcf13d29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# This testcase is part of GDB, the GNU debugger.

# Copyright 2012-2022 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Test basic builtin types.
# NOTE: The tests here intentionally do not require a go compiler.

load_lib "go.exp"

if { [skip_go_tests] } { continue }

proc test_integer_literal_types_accepted {} {
    # Test various decimal values.

    gdb_test "pt 123" "type = int" 

    gdb_test "pt void(42)" "type = void"
    gdb_test "pt byte(42)" "type = uint8"
    gdb_test "pt int(42)" "type = int"
    gdb_test "pt uint(42)" "type = uint"
    gdb_test "pt uintptr(42)" "type = uintptr"

    gdb_test "pt int8(42)" "type = int8"
    gdb_test "pt int16(42)" "type = int16"
    gdb_test "pt int32(42)" "type = int32"
    gdb_test "pt int64(42)" "type = int64"

    gdb_test "pt uint8(42)" "type = uint8"
    gdb_test "pt uint16(42)" "type = uint16"
    gdb_test "pt uint32(42)" "type = uint32"
    gdb_test "pt uint64(42)" "type = uint64"
}

proc test_logical_literal_types_accepted {} {
    # Test the only possible values for a logical, TRUE and FALSE.

    gdb_test "pt true" "type = bool"
    gdb_test "pt false" "type = bool"

    gdb_test "pt bool(0)" "type = bool"
    gdb_test "pt bool(1)" "type = bool"
}

proc test_character_literal_types_accepted {} {
    # Test various character values.

    gdb_test "pt 'a'" "type = char"

    # FIXME: Need more.
}

proc test_string_literal_types_accepted {} {
    # Test various string values.

    gdb_test "pt \"a simple string\"" "type = string"
    gdb_test "pt `a simple raw string`" "type = string"

    # FIXME: Need more.
}

proc test_float_literal_types_accepted {} {
    # Test various floating point formats.

    gdb_test "pt .44" "type = float64"
    gdb_test "pt 44.0" "type = float64"
    gdb_test "pt 10e20" "type = float64"
    gdb_test "pt 10E20" "type = float64"

    gdb_test "pt float32(.42)" "type = float32"

    gdb_test "pt float64(.42)" "type = float64"
}

proc test_complex_literal_types_accepted {} {
    # Test various complex formats.

    gdb_test "pt complex64(.42)" "type = complex64"
    setup_xfail "*-*-*"
    gdb_test "pt complex64(.42i1.0)" "type = complex64"
    setup_xfail "*-*-*"
    gdb_test "pt complex64(i1.0)" "type = complex64"

    gdb_test "pt complex128(.42)" "type = complex128"
    setup_xfail "*-*-*"
    gdb_test "pt complex128(.42i1.0)" "type = complex128"
    setup_xfail "*-*-*"
    gdb_test "pt complex128(i1.0)" "type = complex128"
}

# Start with a fresh gdb.

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir

if [set_lang_go] {
    test_integer_literal_types_accepted
    test_logical_literal_types_accepted
    test_character_literal_types_accepted
    test_string_literal_types_accepted
    test_float_literal_types_accepted
    test_complex_literal_types_accepted
} else {
    warning "Go type tests suppressed."
}