blob: dd0d92fd04db32416090533ef010be9189d49825 [file] [log] [blame]
# This testcase is part of GDB, the GNU debugger.
# Copyright 2012-2020 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."
}