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