]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.testsuite/parse_options_args.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.testsuite / parse_options_args.exp
1 # Copyright 2021-2023 Free Software Foundation, Inc.
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 3 of the License, or
5 # (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
15 # Testsuite self-tests for parse_options and parse_args.
16
17 with_test_prefix parse_options {
18 proc test1 { options a b } {
19 set v2 "defval2"
20 parse_options {
21 { opt1 defval1 }
22 { opt2 $v2 }
23 { opt3 }
24 { opt4 }
25 }
26
27 gdb_assert { [string equal $a "vala"] }
28 gdb_assert { [string equal $b "valb"] }
29 gdb_assert { [string equal $opt1 "val1"] }
30 gdb_assert { [string equal $opt2 "defval2"] }
31 gdb_assert { $opt3 == 1 }
32 gdb_assert { $opt4 == 0 }
33 }
34
35 set v1 "val1"
36 test1 { opt1 $v1 opt3 } "vala" "valb"
37 }
38
39 with_test_prefix parse_args {
40 proc test2 { args } {
41 parse_args {
42 { opt1 defval1 }
43 { opt2 defval2 }
44 { opt3 }
45 { opt4 }
46 }
47 gdb_assert { [llength $args] == 2 }
48 lassign $args a b
49 gdb_assert { [string equal $a "vala"] }
50 gdb_assert { [string equal $b "valb"] }
51 gdb_assert { [string equal $opt1 "val1"] }
52 gdb_assert { [string equal $opt2 "defval2"] }
53 gdb_assert { $opt3 == 1 }
54 gdb_assert { $opt4 == 0 }
55 }
56
57 set v1 "val1"
58 test2 -opt1 $v1 -opt3 "vala" "valb"
59 }