本文整理匯總了TypeScript中vs/workbench/api/node/extHostTypes.Position類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Position類的具體用法?TypeScript Position怎麽用?TypeScript Position使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Position類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('Position, isBefore(OrEqual)?', function() {
let p1 = new types.Position(1, 3);
let p2 = new types.Position(1, 2);
let p3 = new types.Position(0, 4);
assert.ok(p1.isBeforeOrEqual(p1));
assert.ok(!p1.isBefore(p1));
assert.ok(p2.isBefore(p1));
assert.ok(p3.isBefore(p2));
});
示例2: test
test('Position, compareTo', function() {
let p1 = new types.Position(1, 3);
let p2 = new types.Position(1, 2);
let p3 = new types.Position(0, 4);
assert.equal(p1.compareTo(p1), 0);
assert.equal(p2.compareTo(p1), -1);
assert.equal(p1.compareTo(p2), 1);
assert.equal(p2.compareTo(p3), 1);
assert.equal(p1.compareTo(p3), 1);
});
示例3: test
test('Position, with', function () {
let p1 = new types.Position(1, 3);
assert.ok(p1.with() === p1);
assert.ok(p1.with(1) === p1);
assert.ok(p1.with(undefined, 3) === p1);
assert.ok(p1.with(1, 3) === p1);
assert.ok(p1.with(undefined) === p1);
assert.ok(p1.with({ line: 1 }) === p1);
assert.ok(p1.with({ character: 3 }) === p1);
assert.ok(p1.with({ line: 1, character: 3 }) === p1);
let p2 = p1.with({ line: 0, character: 11 });
assert.equal(p2.line, 0);
assert.equal(p2.character, 11);
assert.throws(() => p1.with(null));
assert.throws(() => p1.with(-9));
assert.throws(() => p1.with(0, -9));
assert.throws(() => p1.with({ line: -1 }));
assert.throws(() => p1.with({ character: -1 }));
});
示例4:
assert.throws(() => p1.with(0, -9));
示例5:
assert.throws(() => p1.with({ character: -1 }));