]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2023-2024 Free Software Foundation, Inc. |
cc313a1d TV |
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 | # Check with_override proc. | |
16 | ||
17 | proc foo {} { | |
18 | return 0 | |
19 | } | |
20 | ||
21 | proc foo1 {} { | |
22 | return 1 | |
23 | } | |
24 | ||
25 | proc foo2 {} { | |
26 | return 2 | |
27 | } | |
28 | ||
29 | with_test_prefix no-args { | |
30 | ||
31 | with_test_prefix before { | |
32 | gdb_assert { [foo] == 0 } | |
33 | } | |
34 | ||
35 | with_override foo foo1 { | |
36 | with_test_prefix foo1 { | |
37 | gdb_assert { [foo] == 1 } | |
38 | } | |
39 | ||
40 | with_override foo foo2 { | |
41 | with_test_prefix foo2 { | |
42 | gdb_assert { [foo] == 2 } | |
43 | } | |
44 | } | |
45 | } | |
46 | ||
47 | with_test_prefix after { | |
48 | gdb_assert { [foo] == 0 } | |
49 | } | |
50 | } | |
51 | ||
52 | proc foo { {a 0} } { | |
53 | return [expr $a + 1] | |
54 | } | |
55 | ||
56 | proc foo_plus_1 { {a 0} } { | |
57 | return [expr $a + 2] | |
58 | } | |
59 | ||
60 | with_test_prefix default-arg { | |
61 | ||
62 | with_test_prefix before { | |
63 | gdb_assert { [foo] == 1 } | |
64 | gdb_assert { [foo 0] == 1 } | |
65 | gdb_assert { [foo 1] == 2 } | |
66 | } | |
67 | ||
68 | with_override foo foo_plus_1 { | |
69 | with_test_prefix foo_plus_1 { | |
70 | gdb_assert { [foo] == 2 } | |
71 | gdb_assert { [foo 0] == 2 } | |
72 | gdb_assert { [foo 1] == 3 } | |
73 | } | |
74 | } | |
75 | ||
76 | with_test_prefix after { | |
77 | gdb_assert { [foo] == 1 } | |
78 | gdb_assert { [foo 0] == 1 } | |
79 | gdb_assert { [foo 1] == 2 } | |
80 | } | |
81 | } |