More test cases

This commit is contained in:
Sheetal Nandi 2019-05-31 14:40:59 -07:00
parent 9703b3d6c1
commit b61813ea1d
20 changed files with 82 additions and 72 deletions

View File

@ -1,7 +1,7 @@
/// <reference path='fourslash.ts'/>
////export default class [|DefaultExportedClass|] {
////}
////[|export default class [|{| "declarationRangeIndex": 0 |}DefaultExportedClass|] {
////}|]
/////*
//// * Commenting [|{| "inComment": true |}DefaultExportedClass|]
//// */
@ -10,5 +10,5 @@
////
////var y = new [|DefaultExportedClass|];
const ranges = test.ranges();
const ranges = test.rangesByText().get("DefaultExportedClass");
verify.renameLocations(ranges.filter(r => !(r.marker && r.marker.data.inComment)), { findInComments: true, ranges });

View File

@ -1,8 +1,8 @@
/// <reference path='fourslash.ts'/>
////export default function /*1*/[|DefaultExportedFunction|]() {
////[|export default function /*1*/[|{| "declarationRangeIndex": 0 |}DefaultExportedFunction|]() {
//// return /*2*/[|DefaultExportedFunction|]
////}
////}|]
/////**
//// * Commenting [|{| "inComment": true |}DefaultExportedFunction|]
//// */
@ -11,5 +11,5 @@
////
////var y = /*4*/[|DefaultExportedFunction|]();
const ranges = test.ranges();
const ranges = test.rangesByText().get("DefaultExportedFunction");
verify.renameLocations(ranges.filter(r => !(r.marker && r.marker.data.inComment)), { findInComments: true, ranges });

View File

@ -1,10 +1,10 @@
/// <reference path='fourslash.ts'/>
////function /*1*/[|f|]() {
////[|function /*1*/[|{| "declarationRangeIndex": 0 |}f|]() {
//// return 100;
////}
////}|]
////
////export default /*2*/[|f|];
////[|export default /*2*/[|{| "declarationRangeIndex": 2 |}f|];|]
////
////var x: typeof /*3*/[|f|];
////
@ -13,9 +13,9 @@
/////**
//// * Commenting [|{| "inComment": true |}f|]
//// */
////namespace /*5*/[|f|] {
////[|namespace /*5*/[|{| "declarationRangeIndex": 7 |}f|] {
//// var local = 100;
////}
////}|]
const ranges = test.ranges();
const ranges = test.rangesByText().get("f");
verify.renameLocations(ranges.filter(r => !(r.marker && r.marker.data.inComment)), { findInComments: true, ranges });

View File

@ -1,8 +1,8 @@
/// <reference path='fourslash.ts' />
////import [|a|] from "module";
////export { [|a|] };
////[|import [|{| "declarationRangeIndex": 0 |}a|] from "module";|]
////[|export { [|{| "declarationRangeIndex": 2 |}a|] };|]
const [r0, r1] = test.ranges();
const [r0Def, r0, r1Def, r1] = test.ranges();
verify.renameLocations(r0, [r0, { range: r1, suffixText: " as a" }]);
verify.renameLocations(r1, [{ range: r1, prefixText: "a as " }]);

View File

@ -1,13 +1,13 @@
/// <reference path='fourslash.ts' />
// @Filename: a.ts
////export var [|{| "isDefinition": true |}a|];
////[|export var [|{| "isDefinition": true, "declarationRangeIndex": 0 |}a|];|]
// @Filename: b.ts
////import { [|{| "isWriteAccess": true, "isDefinition": true |}a|] } from './a';
////export { [|{| "isWriteAccess": true, "isDefinition": true |}a|] };
////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}a|] } from './a';|]
////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}a|] };|]
const [r0, r1, r2] = test.ranges();
const [r0Def, r0, r1Def, r1, r2Def, r2] = test.ranges();
const vars = { definition: "var a: any", ranges: [r0] };
const imports = { definition: "(alias) var a: any\nimport a", ranges: [r1, r2] };
verify.referenceGroups(r0, [vars, imports]);

View File

@ -1,7 +1,7 @@
/// <reference path='fourslash.ts' />
////import [|foo|] from 'bar';
////[|import [|{| "declarationRangeIndex": 0 |}foo|] from 'bar';|]
////const bar = { [|foo|] };
const [r0, r1] = test.ranges();
const [r0Def, r0, r1] = test.ranges();
verify.renameLocations([r0, r1], [r0, { range: r1, prefixText: "foo: " }]);

View File

@ -1,7 +1,7 @@
/// <reference path='fourslash.ts' />
////import * as [|foo|] from 'bar';
////[|import * as [|{| "declarationRangeIndex": 0 |}foo|] from 'bar';|]
////const bar = { [|foo|] };
const [r0, r1] = test.ranges();
const [r0Def, r0, r1] = test.ranges();
verify.renameLocations([r0, r1], [r0, { range: r1, prefixText: "foo: " }]);

View File

@ -1,21 +1,21 @@
/// <reference path='fourslash.ts' />
////declare namespace [|{| "isWriteAccess": true, "isDefinition": true |}N|] {
//// export var [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number;
////}
////[|declare namespace [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}N|] {
//// [|export var [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}x|]: number;|]
////}|]
////declare module "mod" {
//// export = [|N|];
//// [|export = [|{| "declarationRangeIndex": 4 |}N|];|]
////}
////declare module "a" {
//// import * as [|{| "isWriteAccess": true, "isDefinition": true |}N|] from "mod";
//// export { [|{| "isWriteAccess": true, "isDefinition": true |}N|] }; // Renaming N here would rename
//// [|import * as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}N|] from "mod";|]
//// [|export { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 8 |}N|] };|] // Renaming N here would rename
////}
////declare module "b" {
//// import { [|{| "isWriteAccess": true, "isDefinition": true |}N|] } from "a";
//// [|import { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 10 |}N|] } from "a";|]
//// export const y: typeof [|N|].[|x|];
////}
const [N0, x0, N1, a0, a1, b0, b1, x1] = test.ranges();
const [N0Def, N0, x0Def, x0, N1Def, N1, a0Def, a0, a1Def, a1, b0Def, b0, b1, x1] = test.ranges();
const nRanges = [N0, N1];
const aRanges = [a0, a1];
const bRanges = [b0, b1];

View File

@ -1,27 +1,27 @@
/// <reference path='fourslash.ts' />
////declare namespace [|{| "isWriteAccess": true, "isDefinition": true |}N|] {
////[|declare namespace [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}N|] {
//// export var x: number;
////}
////}|]
////declare module "mod" {
//// export = [|N|];
//// [|export = [|{| "declarationRangeIndex": 2 |}N|];|]
////}
////declare module "a" {
//// import * as [|{| "isWriteAccess": true, "isDefinition": true |}O|] from "mod";
//// export { [|O|] as [|{| "isWriteAccess": true, "isDefinition": true |}P|] }; // Renaming N here would rename
//// [|import * as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}O|] from "mod";|]
//// [|export { [|{| "declarationRangeIndex": 6 |}O|] as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}P|] };|] // Renaming N here would rename
////}
////declare module "b" {
//// import { [|P|] as [|{| "isWriteAccess": true, "isDefinition": true |}Q|] } from "a";
//// [|import { [|{| "declarationRangeIndex": 9 |}P|] as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 9 |}Q|] } from "a";|]
//// export const y: typeof [|Q|].x;
////}
verify.noErrors();
const [N0, N1, O0, O1, P0, P1, Q0, Q1] = test.ranges();
const nRanges = [N0, N1];
const oRanges = [O0, O1];
const pRanges = [P0, P1];
const qRanges = [Q0, Q1];
const ranges = test.rangesByText();
const nRanges = ranges.get("N");// [N0, N1];
const oRanges = ranges.get("O");// [O0, O1];
const pRanges = ranges.get("P");//[P0, P1];
const qRanges = ranges.get("Q");//[Q0, Q1];
const ns = { definition: "namespace N", ranges: nRanges };
const os = { definition: "(alias) namespace O\nimport O", ranges: oRanges };
@ -33,4 +33,7 @@ verify.referenceGroups(oRanges, [os, ps, qs]);
verify.referenceGroups(pRanges, [ps, qs]);
verify.referenceGroups(qRanges, [qs]);
verify.rangesWithSameTextAreRenameLocations();
verify.rangesAreRenameLocations(nRanges);
verify.rangesAreRenameLocations(oRanges);
verify.rangesAreRenameLocations(pRanges);
verify.rangesAreRenameLocations(qRanges);

View File

@ -2,20 +2,20 @@
// @noLib: true
////declare module "a" {
//// export class [|{| "isWriteAccess": true, "isDefinition": true |}C|] {}
//// [|export class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}C|] {}|]
////}
////declare module "b" {
//// export { [|{| "isWriteAccess": true, "isDefinition": true |}C|] } from "a";
//// [|export { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}C|] } from "a";|]
////}
////declare module "c" {
//// import { [|{| "isWriteAccess": true, "isDefinition": true |}C|] } from "b";
//// [|import { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}C|] } from "b";|]
//// export function f(c: [|C|]): void;
////}
verify.noErrors();
const ranges = test.ranges();
const [r0, r1, r2, r3] = ranges;
const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = ranges;
const importRanges = [r2, r3];
verify.renameLocations(r0, [r0, { range: r1, suffixText: " as C" }]); //, r1
verify.renameLocations(r1, [{ range: r1, prefixText: "C as " }, r2, r3]);

View File

@ -1,13 +1,13 @@
/// <reference path='fourslash.ts' />
////declare module "a" {
//// export class [|{| "isWriteAccess": true, "isDefinition": true |}C|] {}
//// [|export class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}C|] {}|]
////}
////declare module "b" {
//// export { [|C|] as [|{| "isWriteAccess": true, "isDefinition": true |}D|] } from "a";
//// [|export { [|{| "declarationRangeIndex": 2 |}C|] as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}D|] } from "a";|]
////}
////declare module "c" {
//// import { [|{| "isWriteAccess": true, "isDefinition": true |}D|] } from "b";
//// [|import { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 5 |}D|] } from "b";|]
//// export function f(c: [|D|]): void;
////}

View File

@ -1,16 +1,16 @@
/// <reference path='fourslash.ts' />
// @Filename: /a.ts
////import [|e|] = require("mod4");
////[|import [|{| "declarationRangeIndex": 0 |}e|] = require("mod4");|]
////[|e|];
////a = { [|e|] };
////export { [|e|] };
////[|export { [|{| "declarationRangeIndex": 4 |}e|] };|]
// @Filename: /b.ts
////import { [|e|] } from "./a";
////export { [|e|] };
////[|import { [|{| "declarationRangeIndex": 6 |}e|] } from "./a";|]
////[|export { [|{| "declarationRangeIndex": 8 |}e|] };|]
const [r0, r1, r2, r3, r4, r5] = test.ranges();
const [r0Def, r0, r1, r2, r3Def, r3, r4Def, r4, r5Def, r5] = test.ranges();
verify.renameLocations([r0, r1, r2], [r0, r1, { range: r2, prefixText: "e: " }, { range: r3, suffixText: " as e" }]);
verify.renameLocations(r3, [{ range: r3, prefixText: "e as " }, r4, { range: r5, suffixText: " as e" }]);
verify.renameLocations(r4, [{ range: r4, prefixText: "e as " }, { range: r5, suffixText: " as e" }]);

View File

@ -1,10 +1,11 @@
/// <reference path='fourslash.ts'/>
//// class class1 extends class1 {
//// [|propName|]: string;
//// [|[|{| "declarationRangeIndex": 0 |}propName|]: string;|]
//// }
////
//// var v: class1;
//// v.[|propName|];
verify.rangesAreRenameLocations();
const [rDef, ...ranges] = test.ranges();
verify.rangesAreRenameLocations(ranges);

View File

@ -1,10 +1,11 @@
/// <reference path='fourslash.ts'/>
//// class class1 extends class1 {
//// [|doStuff|]() { }
//// [|[|{| "declarationRangeIndex": 0 |}doStuff|]() { }|]
//// }
////
//// var v: class1;
//// v.[|doStuff|]();
verify.rangesAreRenameLocations();
const [rDef, ...ranges] = test.ranges();
verify.rangesAreRenameLocations(ranges);

View File

@ -1,10 +1,11 @@
/// <reference path='fourslash.ts'/>
//// interface interface1 extends interface1 {
//// [|propName|]: string;
//// [|[|{| "declarationRangeIndex": 0 |}propName|]: string;|]
//// }
////
//// var v: interface1;
//// v.[|propName|];
verify.rangesAreRenameLocations();
const [rDef, ...ranges] = test.ranges();
verify.rangesAreRenameLocations(ranges);

View File

@ -1,10 +1,11 @@
/// <reference path='fourslash.ts'/>
//// interface interface1 extends interface1 {
//// [|doStuff|](): string;
//// [|[|{| "declarationRangeIndex": 0 |}doStuff|](): string;|]
//// }
////
//// var v: interface1;
//// v.[|doStuff|]();
verify.rangesAreRenameLocations();
const [rDef, ...ranges] = test.ranges();
verify.rangesAreRenameLocations(ranges);

View File

@ -4,10 +4,11 @@
//// propC: number;
//// }
//// interface D extends C {
//// [|propD|]: string;
//// [|[|{| "declarationRangeIndex": 0 |}propD|]: string;|]
//// }
//// var d: D;
//// d.[|propD|];
verify.rangesAreRenameLocations();
const [rDef, ...ranges] = test.ranges();
verify.rangesAreRenameLocations(ranges);

View File

@ -4,9 +4,10 @@
//// propD: number;
//// }
//// interface D extends C {
//// [|propC|]: number;
//// [|[|{| "declarationRangeIndex": 0 |}propC|]: number;|]
//// }
//// var d: D;
//// d.[|propC|];
verify.rangesAreRenameLocations();
const [rDef, ...ranges] = test.ranges();
verify.rangesAreRenameLocations(ranges);

View File

@ -1,7 +1,7 @@
/// <reference path='fourslash.ts'/>
//// class C extends D {
//// [|prop1|]: string;
//// [|[|{| "declarationRangeIndex": 0 |}prop1|]: string;|]
//// }
////
//// class D extends C {
@ -11,4 +11,5 @@
//// var c: C;
//// c.[|prop1|];
verify.rangesAreRenameLocations();
const [rDef, ...ranges] = test.ranges();
verify.rangesAreRenameLocations(ranges);

View File

@ -1,14 +1,14 @@
/// <reference path='fourslash.ts'/>
//// class C implements D {
//// [|prop1|]: string;
//// [|[|{| "declarationRangeIndex": 0 |}prop1|]: string;|]
//// }
////
//// interface D extends C {
//// [|prop1|]: string;
//// [|[|{| "declarationRangeIndex": 2 |}prop1|]: string;|]
//// }
////
//// var c: C;
//// c.[|prop1|];
verify.rangesAreRenameLocations();
verify.rangesAreRenameLocations(test.rangesByText().get("prop1"));