# Copyright (C) 2014-2023 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 . # This file is part of the GDB testsuite. # It tests the (gdb types) module. load_lib gdb-guile.exp require allow_guile_tests standard_testfile .cc if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } 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\"))" \ "Wrong type argument in position 1 \\(expecting struct or union\\): #.*" \ "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))" \ "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\")))" \ "Wrong type argument in position 1 \\(expecting enum\\): #.*" \ "make-enum-hashtable from int"