Merge from vscode cfc1ab4c5f816765b91fb7ead3c3427a7c8581a3

This commit is contained in:
ADS Merger
2020-03-11 04:19:23 +00:00
parent 16fab722d5
commit 4c3e48773d
880 changed files with 20441 additions and 11232 deletions

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { isMacintosh, isLinux, isWindows } from 'vs/base/common/platform';
function createContext(ctx: any) {
return {
@@ -101,6 +102,8 @@ suite('ContextKeyExpr', () => {
testBatch('d', 'd');
testBatch('z', undefined);
testExpression('true', true);
testExpression('false', false);
testExpression('a && !b', true && !false);
testExpression('a && b', true && false);
testExpression('a && !b && c == 5', true && !false && '5' === '5');
@@ -119,10 +122,30 @@ suite('ContextKeyExpr', () => {
const actual = ContextKeyExpr.deserialize(expr)!.negate().serialize();
assert.strictEqual(actual, expected);
}
testNegate('true', 'false');
testNegate('false', 'true');
testNegate('a', '!a');
testNegate('a && b || c', '!a && !c || !b && !c');
testNegate('a && b || c || d', '!a && !c && !d || !b && !c && !d');
testNegate('!a && !b || !c && !d', 'a && c || a && d || b && c || b && d');
testNegate('!a && !b || !c && !d || !e && !f', 'a && c && e || a && c && f || a && d && e || a && d && f || b && c && e || b && c && f || b && d && e || b && d && f');
});
test('false, true', () => {
function testNormalize(expr: string, expected: string): void {
const actual = ContextKeyExpr.deserialize(expr)!.serialize();
assert.strictEqual(actual, expected);
}
testNormalize('true', 'true');
testNormalize('!true', 'false');
testNormalize('false', 'false');
testNormalize('!false', 'true');
testNormalize('a && true', 'a');
testNormalize('a && false', 'false');
testNormalize('a || true', 'true');
testNormalize('a || false', 'a');
testNormalize('isMac', isMacintosh ? 'true' : 'false');
testNormalize('isLinux', isLinux ? 'true' : 'false');
testNormalize('isWindows', isWindows ? 'true' : 'false');
});
});