ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / base / test / common / cancelPreviousCalls.test.ts 304 строк · изменён 14 нояб., 04:52
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import assert from 'assert' ;
import { Disposable } from '../../common/lifecycle.js' ;
import { CancellationToken } from '../../common/cancellation.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from './utils.js' ;
import { cancelPreviousCalls } from '../../common/decorators/cancelPreviousCalls.js' ;
suite ( 'cancelPreviousCalls decorator' , ( ) => {
const disposables = ensureNoDisposablesAreLeakedInTestSuite ( ) ;
class MockDisposable extends Disposable
callArgs1 CancellationToken
callArgs2 CancellationToken
callArgs1
callArgs2
arg1 arg2 cancellationToken CancellationToken
callArgs1 arg1 arg2 cancellationToken
resolve resolve
arg1 arg2 cancellationToken CancellationToken
callArgs2 arg1 arg2 cancellationToken
resolve resolve
instance disposables
instance
callArguments instance callArguments1
assert
callArguments length
args callArguments
args length
arg1 args
arg2 args
arg3 args
assert
arg1
assert
arg2
CancellationToken arg3
arg3 isCancellationRequested
instance callArguments2 length
instance disposables
instance
resolve resolve
instance
callArguments instance callArguments1
assert
callArguments length
call1Args callArguments
call1Args length
assert
call1Args
assert
call1Args
CancellationToken call1Args
call1Args isCancellationRequested
call2Args callArguments
call2Args length
assert
call2Args
assert
call2Args
CancellationToken call2Args
call2Args isCancellationRequested
instance callArguments2 length
instance disposables
instance
resolve resolve
instance
assert
instance callArguments1 length
call1Args instance callArguments1
call1Args length
assert
call1Args
assert
call1Args
CancellationToken call1Args
call1Args isCancellationRequested
assert
instance callArguments2 length
call2Args instance callArguments2
call2Args length
assert
call2Args
assert
call2Args
CancellationToken call2Args
call2Args isCancellationRequested
instance
assert
instance callArguments1 length
assert
instance callArguments2 length
call1Args isCancellationRequested
call3Args instance callArguments2
CancellationToken call3Args
call2Args isCancellationRequested
call3Args isCancellationRequested
assert
call3Args
assert
call3Args
{
private
readonly
:
(
[
number
,
string
,
|
undefined
]
)
[
]
=
[
]
;
private
readonly
:
(
[
number
,
string
,
|
undefined
]
)
[
]
=
[
]
;
public
get
callArguments1
(
)
{
return
this
.
;
}
public
get
callArguments2
(
)
{
return
this
.
;
}
@ cancelPreviousCalls
async
doSomethingAsync
(
:
number
,
:
string
,
?
:
)
:
Promise
<
void
>
{
this
.
.
push
(
[
,
,
]
)
;
await
new
Promise
(
=>
setTimeout
(
,
25
)
)
;
}
@ cancelPreviousCalls
async
doSomethingElseAsync
(
:
number
,
:
string
,
?
:
)
:
Promise
<
void
>
{
this
.
.
push
(
[
,
,
]
)
;
await
new
Promise
(
=>
setTimeout
(
,
25
)
)
;
}
}
test
(
'should call method with CancellationToken'
,
async
(
)
=>
{
const
=
.
add
(
new
MockDisposable
(
)
)
;
await
.
doSomethingAsync
(
1
,
'foo'
)
;
const
=
.
;
.
strictEqual
(
.
,
1
,
` The 'doSomethingAsync' method must be called just once. `
,
)
;
const
=
[
0
]
;
assert
(
.
===
3
,
` The 'doSomethingAsync' method must be called with '3' arguments, got ' ${ args. length} '. `
,
)
;
const
=
[
0
]
;
const
=
[
1
]
;
const
=
[
2
]
;
.
strictEqual
(
,
1
,
` The 'doSomethingAsync' method call must have the correct 1st argument. `
,
)
;
.
strictEqual
(
,
'foo'
,
` The 'doSomethingAsync' method call must have the correct 2nd argument. `
,
)
;
assert
(
.
isCancellationToken
(
)
,
` The last argument of the 'doSomethingAsync' method must be a 'CancellationToken', got ' ${ arg3} '. `
,
)
;
assert
(
.
===
false
,
` The 'CancellationToken' argument must not yet be cancelled. `
,
)
;
assert
(
.
.
===
0
,
` The 'doSomethingElseAsync' method must not be called. `
,
)
;
}
)
;
test
(
'cancel token of the previous call when method is called again'
,
async
(
)
=>
{
const
=
.
add
(
new
MockDisposable
(
)
)
;
.
doSomethingAsync
(
1
,
'foo'
)
;
await
new
Promise
(
=>
setTimeout
(
,
10
)
)
;
.
doSomethingAsync
(
2
,
'bar'
)
;
const
=
.
;
.
strictEqual
(
.
,
2
,
` The 'doSomethingAsync' method must be called twice. `
,
)
;
const
=
[
0
]
;
assert
(
.
===
3
,
` The first call of the 'doSomethingAsync' method must have '3' arguments, got ' ${ call1Args. length} '. `
,
)
;
.
strictEqual
(
[
0
]
,
1
,
` The first call of the 'doSomethingAsync' method must have the correct 1st argument. `
,
)
;
.
strictEqual
(
[
1
]
,
'foo'
,
` The first call of the 'doSomethingAsync' method must have the correct 2nd argument. `
,
)
;
assert
(
.
isCancellationToken
(
[
2
]
)
,
` The first call of the 'doSomethingAsync' method must have the 'CancellationToken' as the 3rd argument. `
,
)
;
assert
(
[
2
]
.
===
true
,
` The 'CancellationToken' of the first call must be cancelled. `
,
)
;
const
=
[
1
]
;
assert
(
.
===
3
,
` The second call of the 'doSomethingAsync' method must have '3' arguments, got ' ${ call1Args. length} '. `
,
)
;
.
strictEqual
(
[
0
]
,
2
,
` The second call of the 'doSomethingAsync' method must have the correct 1st argument. `
,
)
;
.
strictEqual
(
[
1
]
,
'bar'
,
` The second call of the 'doSomethingAsync' method must have the correct 2nd argument. `
,
)
;
assert
(
.
isCancellationToken
(
[
2
]
)
,
` The second call of the 'doSomethingAsync' method must have the 'CancellationToken' as the 3rd argument. `
,
)
;
assert
(
[
2
]
.
===
false
,
` The 'CancellationToken' of the second call must be cancelled. `
,
)
;
assert
(
.
.
===
0
,
` The 'doSomethingElseAsync' method must not be called. `
,
)
;
}
)
;
test
(
'different method calls must not interfere with each other'
,
async
(
)
=>
{
const
=
.
add
(
new
MockDisposable
(
)
)
;
.
doSomethingAsync
(
10
,
'baz'
)
;
await
new
Promise
(
=>
setTimeout
(
,
10
)
)
;
.
doSomethingElseAsync
(
25
,
'qux'
)
;
.
strictEqual
(
.
.
,
1
,
` The 'doSomethingAsync' method must be called once. `
,
)
;
const
=
.
[
0
]
;
assert
(
.
===
3
,
` The first call of the 'doSomethingAsync' method must have '3' arguments, got ' ${ call1Args. length} '. `
,
)
;
.
strictEqual
(
[
0
]
,
10
,
` The first call of the 'doSomethingAsync' method must have the correct 1st argument. `
,
)
;
.
strictEqual
(
[
1
]
,
'baz'
,
` The first call of the 'doSomethingAsync' method must have the correct 2nd argument. `
,
)
;
assert
(
.
isCancellationToken
(
[
2
]
)
,
` The first call of the 'doSomethingAsync' method must have the 'CancellationToken' as the 3rd argument. `
,
)
;
assert
(
[
2
]
.
===
false
,
` The 'CancellationToken' of the first call must not be cancelled. `
,
)
;
.
strictEqual
(
.
.
,
1
,
` The 'doSomethingElseAsync' method must be called once. `
,
)
;
const
=
.
[
0
]
;
assert
(
.
===
3
,
` The first call of the 'doSomethingElseAsync' method must have '3' arguments, got ' ${ call1Args. length} '. `
,
)
;
.
strictEqual
(
[
0
]
,
25
,
` The first call of the 'doSomethingElseAsync' method must have the correct 1st argument. `
,
)
;
.
strictEqual
(
[
1
]
,
'qux'
,
` The first call of the 'doSomethingElseAsync' method must have the correct 2nd argument. `
,
)
;
assert
(
.
isCancellationToken
(
[
2
]
)
,
` The first call of the 'doSomethingElseAsync' method must have the 'CancellationToken' as the 3rd argument. `
,
)
;
assert
(
[
2
]
.
===
false
,
` The 'CancellationToken' of the second call must be cancelled. `
,
)
;
.
doSomethingElseAsync
(
105
,
'uxi'
)
;
.
strictEqual
(
.
.
,
1
,
` The 'doSomethingAsync' method must be called once. `
,
)
;
.
strictEqual
(
.
.
,
2
,
` The 'doSomethingElseAsync' method must be called twice. `
,
)
;
assert
(
[
2
]
.
===
false
,
` The 'CancellationToken' of the first call must not be cancelled. `
,
)
;
const
=
.
[
1
]
;
assert
(
.
isCancellationToken
(
[
2
]
)
,
` The last argument of the second call of the 'doSomethingElseAsync' method must be a 'CancellationToken'. `
,
)
;
assert
(
[
2
]
.
,
` The 'CancellationToken' of the first call must be cancelled. `
,
)
;
assert
(
[
2
]
.
===
false
,
` The 'CancellationToken' of the second call must not be cancelled. `
,
)
;
.
strictEqual
(
[
0
]
,
105
,
` The second call of the 'doSomethingElseAsync' method must have the correct 1st argument. `
,
)
;
.
strictEqual
(
[
1
]
,
'uxi'
,
` The second call of the 'doSomethingElseAsync' method must have the correct 2nd argument. `
,
)
;
}
)
;
}
)
;