summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.guile/types-module.exp
blob: 45099e644a0044cf37b2ea6cb753563d866b25cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright (C) 2014-2022 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\"))" \
    "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))" \
    "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\\): #<gdb:type int>.*" \
    "make-enum-hashtable from int"