Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.guile / scm-color.exp
blob9fd7f38b495f8c21b5b0cd88bdb1fcfbdd1d1570
1 # Copyright (C) 2010-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 GDB parameter support in Guile.
19 load_lib gdb-guile.exp
21 require allow_guile_tests
23 clean_restart
25 gdb_install_guile_utils
26 gdb_install_guile_module
28 gdb_test_no_output [concat "guile (define (print_color_attrs c) " \
29     "(display (color-string c)) (display \" \") " \
30     "(display (color-colorspace c)) (display \" \") " \
31     "(display (color-none? c)) (display \" \") " \
32     "(display (color-indexed? c)) (display \" \") " \
33     "(display (color-direct? c)) (newline))"] \
34     "print_color_attrs helper"
36 gdb_test "guile (print_color_attrs (make-color))" \
37     "none 0 #t #f #f" \
38     "print attrs of a color without params"
40 gdb_test_no_output "guile (define c (make-color \"green\"))" \
41     "create color from basic name string"
42 gdb_test "guile (print_color_attrs c)" "green 1 #f #t #f" \
43     "print attrs of a basic color name"
44 gdb_test "guile (print (color-index c))" "2" \
45     "print index of a basic color name"
47 gdb_test_no_output "guile (define c (make-color 2))" \
48     "create color from basic index"
49 gdb_test "guile (print_color_attrs c)" "green 1 #f #t #f" \
50     "print attrs of a basic color"
51 gdb_test "guile (print (color-index c))" "2" \
52     "print index of a basic color"
54 gdb_test_no_output "guile (define c (make-color 14))" \
55     "create color from integer 14"
56 gdb_test "guile (print_color_attrs c)" "14 2 #f #t #f" \
57     "print attrs of an color 14"
58 gdb_test "guile (print (color-index c))" "14" \
59     "print index of color 14"
61 gdb_test_no_output "guile (define c (make-color 2 #:color-space COLORSPACE_ANSI_8COLOR))" \
62     "create color from basic index and ansi colorspace"
63 gdb_test "guile (print_color_attrs c)" "green 1 #f #t #f" \
64     "print attrs of a basic color with ansi colorspace"
65 gdb_test "guile (print (color-index c))" "2" \
66     "print index of a basic color with ansi colorspace"
68 gdb_test_no_output "guile (define c (make-color 2 #:color-space COLORSPACE_XTERM_256COLOR))" \
69     "create color from basic index and xterm256 colorspace"
70 gdb_test "guile (print_color_attrs c)" "2 3 #f #t #f" \
71     "print attrs of a basic color with xterm256 colorspace"
72 gdb_test "guile (print (color-index c))" "2" \
73     "print index of a basic color with xterm256 colorspace"
75 gdb_test_no_output "guile (define c (make-color '(171 205 239) #:color-space COLORSPACE_RGB_24BIT))" \
76     "create color from rgb components"
77 gdb_test "guile (print_color_attrs c)" "#ABCDEF 4 #f #f #t" \
78     "print attrs of an RGB color"
79 gdb_test "guile (print (color-components c))" "\\(171 205 239\\)" \
80     "print components of an RGB color"
82 gdb_test_no_output "guile (define c (make-color \"none\"))" \
83     "create color from string none"
84 gdb_test "guile (print_color_attrs c)" "none 0 #t #f #f" \
85     "print attrs of a color none"
87 gdb_test_no_output "guile (define c (make-color \"254\"))" \
88     "create color from string 254"
89 gdb_test "guile (print_color_attrs c)" "254 3 #f #t #f" \
90     "print attrs of an color 254"
91 gdb_test "guile (print (color-index c))" "254" \
92     "print index of color 254"
94 gdb_test_no_output "guile (define c_none (make-color \"none\"))" \
95     "save default color"
96 gdb_test_no_output "guile (define c_red (make-color \"red\"))" \
97     "save blue color"
98 gdb_test_no_output "guile (define c_green (make-color \"green\"))" \
99     "save yellow color"
100 gdb_test [concat "guile " \
101     "(display (color-escape-sequence c_red #t)) " \
102     "(display (color-escape-sequence c_green #f)) " \
103     "(display \"red on green\") " \
104     "(display (color-escape-sequence c_none #f)) " \
105     "(display \" red on default\") " \
106     "(display (color-escape-sequence c_none #t)) " \
107     "(newline)"] \
108     "\033\\\[31m\033\\\[42mred on green\033\\\[49m red on default\033\\\[39m" \
109     "escape sequences"