Update to VS Code 1.52.1

This commit is contained in:
Asher
2021-02-09 16:08:37 +00:00
1351 changed files with 56560 additions and 38990 deletions

View File

@@ -7,7 +7,7 @@ import * as assert from 'assert';
import * as async from 'vs/base/common/async';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import { URI } from 'vs/base/common/uri';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
suite('Async', () => {
@@ -651,41 +651,39 @@ suite('Async', () => {
test('raceCancellation', async () => {
const cts = new CancellationTokenSource();
const now = Date.now();
const p = async.raceCancellation(async.timeout(100), cts.token);
let triggered = false;
const p = async.raceCancellation(async.timeout(100).then(() => triggered = true), cts.token);
cts.cancel();
await p;
assert.ok(Date.now() - now < 100);
assert.ok(!triggered);
});
test('raceTimeout', async () => {
const cts = new CancellationTokenSource();
// timeout wins
let now = Date.now();
let timedout = false;
let triggered = false;
const p1 = async.raceTimeout(async.timeout(100), 1, () => timedout = true);
const p1 = async.raceTimeout(async.timeout(100).then(() => triggered = true), 1, () => timedout = true);
cts.cancel();
await p1;
assert.ok(Date.now() - now < 100);
assert.ok(!triggered);
assert.equal(timedout, true);
// promise wins
now = Date.now();
timedout = false;
const p2 = async.raceTimeout(async.timeout(1), 100, () => timedout = true);
const p2 = async.raceTimeout(async.timeout(1).then(() => triggered = true), 100, () => timedout = true);
cts.cancel();
await p2;
assert.ok(Date.now() - now < 100);
assert.ok(triggered);
assert.equal(timedout, false);
});
@@ -719,4 +717,63 @@ suite('Async', () => {
assert.equal(counter.increment(), 2);
assert.equal(counter.increment(), 3);
});
test('firstParallel - simple', async () => {
const a = await async.firstParallel([
Promise.resolve(1),
Promise.resolve(2),
Promise.resolve(3),
], v => v === 2);
assert.equal(a, 2);
});
test('firstParallel - uses null default', async () => {
assert.equal(await async.firstParallel([Promise.resolve(1)], v => v === 2), null);
});
test('firstParallel - uses value default', async () => {
assert.equal(await async.firstParallel([Promise.resolve(1)], v => v === 2, 4), 4);
});
test('firstParallel - empty', async () => {
assert.equal(await async.firstParallel([], v => v === 2, 4), 4);
});
test('firstParallel - cancels', async () => {
let ct1: CancellationToken;
const p1 = async.createCancelablePromise(async (ct) => {
ct1 = ct;
await async.timeout(200, ct);
return 1;
});
let ct2: CancellationToken;
const p2 = async.createCancelablePromise(async (ct) => {
ct2 = ct;
await async.timeout(2, ct);
return 2;
});
assert.equal(await async.firstParallel([p1, p2], v => v === 2, 4), 2);
assert.equal(ct1!.isCancellationRequested, true, 'should cancel a');
assert.equal(ct2!.isCancellationRequested, true, 'should cancel b');
});
test('firstParallel - rejection handling', async () => {
let ct1: CancellationToken;
const p1 = async.createCancelablePromise(async (ct) => {
ct1 = ct;
await async.timeout(200, ct);
return 1;
});
let ct2: CancellationToken;
const p2 = async.createCancelablePromise(async (ct) => {
ct2 = ct;
await async.timeout(2, ct);
throw new Error('oh no');
});
assert.equal(await async.firstParallel([p1, p2], v => v === 2, 4).catch(() => 'ok'), 'ok');
assert.equal(ct1!.isCancellationRequested, true, 'should cancel a');
assert.equal(ct2!.isCancellationRequested, true, 'should cancel b');
});
});