63 lines
2.3 KiB
Plaintext
63 lines
2.3 KiB
Plaintext
# Copyright (C) 2014-2017 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/>.
|
|
|
|
# This file is part of the GDB testsuite.
|
|
# It tests the (gdb types) module.
|
|
|
|
load_lib gdb-guile.exp
|
|
|
|
standard_testfile .cc
|
|
|
|
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
|
|
return -1
|
|
}
|
|
|
|
# Skip all tests if Guile scripting is not enabled.
|
|
if { [skip_guile_tests] } { continue }
|
|
|
|
if ![gdb_guile_runto_main] {
|
|
return
|
|
}
|
|
|
|
gdb_scm_test_silent_cmd "guile (use-modules (gdb types))" \
|
|
"import (gdb types)"
|
|
|
|
gdb_scm_test_silent_cmd "guile (define d (lookup-type \"derived\"))" \
|
|
"get derived type"
|
|
|
|
gdb_test "guile (print (type-has-field? d \"base_member\"))" \
|
|
"= #f" "type-has-field? member in baseclass"
|
|
|
|
gdb_test "guile (print (type-has-field-deep? d \"base_member\"))" \
|
|
"= #t" "type-has-field-deep? member in baseclass"
|
|
|
|
gdb_test "guile (print (type-has-field-deep? (lookup-type \"int\") \"base_member\"))" \
|
|
"ERROR: .*Wrong type argument in position 1 \\(expecting struct or union\\): #<gdb:type int>.*" \
|
|
"type-has-field-deep? from int"
|
|
|
|
gdb_scm_test_silent_cmd "guile (define enum-htab (make-enum-hashtable (lookup-type \"enum_type\")))" \
|
|
"create enum hash table"
|
|
|
|
gdb_test "guile (print (hash-ref enum-htab \"B\"))" \
|
|
"= 1" "verify make-enum-hashtable"
|
|
|
|
gdb_test "guile (define bad-enum-htab (make-enum-hashtable #f))" \
|
|
"ERROR: .*Wrong type argument in position 1 \\(expecting gdb:type\\): #f.*" \
|
|
"make-enum-hashtable from #f"
|
|
|
|
gdb_test "guile (define bad-enum-htab (make-enum-hashtable (lookup-type \"int\")))" \
|
|
"ERROR: .*Wrong type argument in position 1 \\(expecting enum\\): #<gdb:type int>.*" \
|
|
"make-enum-hashtable from int"
|