OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [tests/] [history.test] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Commands covered:  history
2
#
3
# This file contains a collection of tests for one or more of the Tcl
4
# built-in commands.  Sourcing this file into Tcl runs the tests and
5
# generates output for errors.  No output means no errors were found.
6
#
7
# Copyright (c) 1991-1993 The Regents of the University of California.
8
# Copyright (c) 1994 Sun Microsystems, Inc.
9
#
10
# See the file "license.terms" for information on usage and redistribution
11
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
#
13
# RCS: @(#) $Id: history.test,v 1.1.1.1 2002-01-16 10:25:36 markom Exp $
14
 
15
if {[catch {history}]} {
16
    puts stdout "This version of Tcl was built without the history command;\n"
17
    puts stdout "history tests will be skipped.\n"
18
    return
19
}
20
 
21
if {[string compare test [info procs test]] == 1} then {source defs}
22
 
23
set num [history nextid]
24
history keep 3
25
history add {set a 12345}
26
history add {set b [format {A test %s} string]}
27
history add {Another test}
28
 
29
# "history event"
30
 
31
test history-1.1 {event option} {history event -1} \
32
        {set b [format {A test %s} string]}
33
test history-1.2 {event option} {history event $num} \
34
        {set a 12345}
35
test history-1.3 {event option} {history event [expr $num+2]} \
36
        {Another test}
37
test history-1.4 {event option} {history event set} \
38
        {set b [format {A test %s} string]}
39
test history-1.5 {event option} {history e "* a*"} \
40
        {set a 12345}
41
test history-1.6 {event option} {catch {history event *gorp} msg} 1
42
test history-1.7 {event option} {
43
    catch {history event *gorp} msg
44
    set msg
45
} {no event matches "*gorp"}
46
test history-1.8 {event option} {history event} \
47
        {set b [format {A test %s} string]}
48
test history-1.9 {event option} {catch {history event 123 456} msg} 1
49
test history-1.10 {event option} {
50
    catch {history event 123 456} msg
51
    set msg
52
} {wrong # args: should be "history event ?event?"}
53
 
54
# "history redo"
55
 
56
set a 0
57
history redo -2
58
test history-2.1 {redo option} {set a} 12345
59
set b 0
60
history redo
61
test history-2.2 {redo option} {set b} {A test string}
62
test history-2.3 {redo option} {catch {history redo -3 -4}} 1
63
test history-2.4 {redo option} {
64
    catch {history redo -3 -4} msg
65
    set msg
66
} {wrong # args: should be "history redo ?event?"}
67
 
68
# "history add"
69
 
70
history add "set a 444" exec
71
test history-3.1 {add option} {set a} 444
72
test history-3.2 {add option} {catch {history add "set a 444" execGorp}} 1
73
test history-3.3 {add option} {
74
    catch {history add "set a 444" execGorp} msg
75
    set msg
76
} {bad argument "execGorp": should be "exec"}
77
test history-3.4 {add option} {catch {history add "set a 444" a} msg} 1
78
test history-3.5 {add option} {
79
    catch {history add "set a 444" a} msg
80
    set msg
81
} {bad argument "a": should be "exec"}
82
history add "set a 555" e
83
test history-3.6 {add option} {set a} 555
84
history add "set a 666"
85
test history-3.7 {add option} {set a} 555
86
test history-3.8 {add option} {catch {history add "set a 666" e f} msg} 1
87
test history-3.9 {add option} {
88
    catch {history add "set a 666" e f} msg
89
    set msg
90
} {wrong # args: should be "history add event ?exec?"}
91
 
92
# "history change"
93
 
94
history change "A test value"
95
test history-4.1 {change option} {history event [expr {[history n]-1}]} \
96
        "A test value"
97
history ch "Another test" -1
98
test history-4.2 {change option} {history e} "Another test"
99
test history-4.3 {change option} {history event [expr {[history n]-1}]} \
100
        "A test value"
101
test history-4.4 {change option} {catch {history change Foo 4 10}} 1
102
test history-4.5 {change option} {
103
    catch {history change Foo 4 10} msg
104
    set msg
105
} {wrong # args: should be "history change newValue ?event?"}
106
test history-4.6 {change option} {
107
    catch {history change Foo [expr {[history n]-4}]}
108
} 1
109
set num [expr {[history n]-4}]
110
test history-4.7 {change option} {
111
    catch {history change Foo $num} msg
112
    set msg
113
} "event \"$num\" is too far in the past"
114
 
115
# "history info"
116
 
117
set num [history n]
118
history add set\ a\ {b\nc\ d\ e}
119
history add {set b 1234}
120
history add set\ c\ {a\nb\nc}
121
test history-5.1 {info option} {history info} [format {%6d  set a {b
122
        c d e}
123
%6d  set b 1234
124
%6d  set c {a
125
        b
126
        c}} $num [expr $num+1] [expr $num+2]]
127
test history-5.2 {info option} {history i 2} [format {%6d  set b 1234
128
%6d  set c {a
129
        b
130
        c}} [expr $num+1] [expr $num+2]]
131
test history-5.3 {info option} {catch {history i 2 3}} 1
132
test history-5.4 {info option} {
133
    catch {history i 2 3} msg
134
    set msg
135
} {wrong # args: should be "history info ?count?"}
136
test history-5.5 {info option} {history} [format {%6d  set a {b
137
        c d e}
138
%6d  set b 1234
139
%6d  set c {a
140
        b
141
        c}} $num [expr $num+1] [expr $num+2]]
142
 
143
# "history keep"
144
 
145
history add "foo1"
146
history add "foo2"
147
history add "foo3"
148
history keep 2
149
test history-6.1 {keep option} {history event [expr [history n]-1]} foo3
150
test history-6.2 {keep option} {history event -1} foo2
151
test history-6.3 {keep option} {catch {history event -3}} 1
152
test history-6.4 {keep option} {
153
    catch {history event -3} msg
154
    set msg
155
} {event "-3" is too far in the past}
156
history k 5
157
test history-6.5 {keep option} {history event -1} foo2
158
test history-6.6 {keep option} {history event -2} {}
159
test history-6.7 {keep option} {history event -3} {}
160
test history-6.8 {keep option} {history event -4} {}
161
test history-6.9 {keep option} {catch {history event -5}} 1
162
test history-6.10 {keep option} {catch {history keep 4 6}} 1
163
test history-6.11 {keep option} {
164
    catch {history keep 4 6} msg
165
    set msg
166
} {wrong # args: should be "history keep ?count?"}
167
test history-6.12 {keep option} {catch {history keep}} 0
168
test history-6.13 {keep option} {
169
    history keep
170
} {5}
171
test history-6.14 {keep option} {catch {history keep -3}} 1
172
test history-6.15 {keep option} {
173
    catch {history keep -3} msg
174
    set msg
175
} {illegal keep count "-3"}
176
test history-6.16 {keep option} {
177
    catch {history keep butter} msg
178
    set msg
179
} {illegal keep count "butter"}
180
 
181
# "history nextid"
182
 
183
set num [history n]
184
history add "Testing"
185
history add "Testing2"
186
test history-7.1 {nextid option} {history event} "Testing"
187
test history-7.2 {nextid option} {history next} [expr $num+2]
188
test history-7.3 {nextid option} {catch {history nextid garbage}} 1
189
test history-7.4 {nextid option} {
190
    catch {history nextid garbage} msg
191
    set msg
192
} {wrong # args: should be "history nextid"}
193
 
194
# "history clear"
195
 
196
set num [history n]
197
history add "Testing"
198
history add "Testing2"
199
test history-8.1 {clear option} {catch {history clear junk}} 1
200
test history-8.2 {clear option} {history clear} {}
201
history add "Testing"
202
test history-8.3 {clear option} {history} {     1  Testing}
203
 
204
# miscellaneous
205
 
206
test history-9.1 {miscellaneous} {catch {history gorp} msg} 1
207
test history-9.2 {miscellaneous} {
208
    catch {history gorp} msg
209
    set msg
210
} {bad option "gorp": must be add, change, clear, event, info, keep, nextid, or redo}
211
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.