]>
Commit | Line | Data |
---|---|---|
3666a048 | 1 | # Copyright (C) 2014-2021 Free Software Foundation, Inc. |
ed3ef339 DE |
2 | # |
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
16 | # This file is part of the GDB testsuite. | |
17 | # It tests the (gdb types) module. | |
18 | ||
19 | load_lib gdb-guile.exp | |
20 | ||
21 | standard_testfile .cc | |
22 | ||
5b362f04 | 23 | if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { |
ed3ef339 DE |
24 | return -1 |
25 | } | |
26 | ||
27 | # Skip all tests if Guile scripting is not enabled. | |
28 | if { [skip_guile_tests] } { continue } | |
29 | ||
30 | if ![gdb_guile_runto_main] { | |
31 | return | |
32 | } | |
33 | ||
34 | gdb_scm_test_silent_cmd "guile (use-modules (gdb types))" \ | |
35 | "import (gdb types)" | |
36 | ||
37 | gdb_scm_test_silent_cmd "guile (define d (lookup-type \"derived\"))" \ | |
38 | "get derived type" | |
39 | ||
40 | gdb_test "guile (print (type-has-field? d \"base_member\"))" \ | |
41 | "= #f" "type-has-field? member in baseclass" | |
42 | ||
43 | gdb_test "guile (print (type-has-field-deep? d \"base_member\"))" \ | |
44 | "= #t" "type-has-field-deep? member in baseclass" | |
45 | ||
186fcde0 | 46 | gdb_test "guile (print (type-has-field-deep? (lookup-type \"int\") \"base_member\"))" \ |
ae5369e7 | 47 | "Wrong type argument in position 1 \\(expecting struct or union\\): #<gdb:type int>.*" \ |
186fcde0 DE |
48 | "type-has-field-deep? from int" |
49 | ||
ed3ef339 DE |
50 | gdb_scm_test_silent_cmd "guile (define enum-htab (make-enum-hashtable (lookup-type \"enum_type\")))" \ |
51 | "create enum hash table" | |
52 | ||
53 | gdb_test "guile (print (hash-ref enum-htab \"B\"))" \ | |
54 | "= 1" "verify make-enum-hashtable" | |
186fcde0 DE |
55 | |
56 | gdb_test "guile (define bad-enum-htab (make-enum-hashtable #f))" \ | |
ae5369e7 | 57 | "Wrong type argument in position 1 \\(expecting gdb:type\\): #f.*" \ |
186fcde0 DE |
58 | "make-enum-hashtable from #f" |
59 | ||
60 | gdb_test "guile (define bad-enum-htab (make-enum-hashtable (lookup-type \"int\")))" \ | |
ae5369e7 | 61 | "Wrong type argument in position 1 \\(expecting enum\\): #<gdb:type int>.*" \ |
186fcde0 | 62 | "make-enum-hashtable from int" |