Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.guile / types-module.exp
blobdfd942213ef9b856c2f069528a21d4dbca499f5e
1 # Copyright (C) 2014-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 # This file is part of the GDB testsuite.
17 # It tests the (gdb types) module.
19 load_lib gdb-guile.exp
21 require allow_guile_tests
23 standard_testfile .cc
25 set flags {}
26 lappend flags debug
27 lappend flags c++
29 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $flags] } {
30     return -1
33 if ![gdb_guile_runto_main] {
34     return
37 gdb_scm_test_silent_cmd "guile (use-modules (gdb types))" \
38     "import (gdb types)"
40 gdb_scm_test_silent_cmd "guile (define d (lookup-type \"derived\"))" \
41     "get derived type"
43 gdb_test "guile (print (type-has-field? d \"base_member\"))" \
44     "= #f" "type-has-field? member in baseclass"
46 gdb_test "guile (print (type-has-field-deep? d \"base_member\"))" \
47     "= #t" "type-has-field-deep? member in baseclass"
49 gdb_test "guile (print (type-has-field-deep? (lookup-type \"int\") \"base_member\"))" \
50     "Wrong type argument in position 1 \\(expecting struct or union\\): #<gdb:type int>.*" \
51     "type-has-field-deep? from int"
53 gdb_scm_test_silent_cmd "guile (define enum-htab (make-enum-hashtable (lookup-type \"enum_type\")))" \
54     "create enum hash table"
56 gdb_test "guile (print (hash-ref enum-htab \"B\"))" \
57     "= 1" "verify make-enum-hashtable"
59 gdb_test "guile (define bad-enum-htab (make-enum-hashtable #f))" \
60     "Wrong type argument in position 1 \\(expecting gdb:type\\): #f.*" \
61     "make-enum-hashtable from #f"
63 gdb_test "guile (define bad-enum-htab (make-enum-hashtable (lookup-type \"int\")))" \
64     "Wrong type argument in position 1 \\(expecting enum\\): #<gdb:type int>.*" \
65     "make-enum-hashtable from int"
67 gdb_test_no_output "guile (define foo-ref (parse-and-eval \"foo_ref\"))" \
68     "get foo-ref value"
69 gdb_test "guile (get-basic-type (value-type foo-ref))" "#<gdb:type int>" \
70     "check get-basic-type"