From b61813ea1d6c99438dfd267d34df9d74cb1fa265 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 31 May 2019 14:40:59 -0700 Subject: [PATCH] More test cases --- .../fourslash/renameForDefaultExport01.ts | 6 ++--- .../fourslash/renameForDefaultExport02.ts | 6 ++--- .../fourslash/renameForDefaultExport03.ts | 12 ++++----- .../cases/fourslash/renameImportAndExport.ts | 6 ++--- .../renameImportAndExportInDiffFiles.ts | 8 +++--- .../fourslash/renameImportAndShorthand.ts | 4 +-- .../renameImportNamespaceAndShorthand.ts | 4 +-- .../fourslash/renameImportOfExportEquals.ts | 16 +++++------ .../fourslash/renameImportOfExportEquals2.ts | 27 ++++++++++--------- .../cases/fourslash/renameImportOfReExport.ts | 8 +++--- .../fourslash/renameImportOfReExport2.ts | 6 ++--- tests/cases/fourslash/renameImportRequire.ts | 10 +++---- .../fourslash/renameInheritedProperties1.ts | 5 ++-- .../fourslash/renameInheritedProperties2.ts | 5 ++-- .../fourslash/renameInheritedProperties3.ts | 5 ++-- .../fourslash/renameInheritedProperties4.ts | 5 ++-- .../fourslash/renameInheritedProperties5.ts | 5 ++-- .../fourslash/renameInheritedProperties6.ts | 5 ++-- .../fourslash/renameInheritedProperties7.ts | 5 ++-- .../fourslash/renameInheritedProperties8.ts | 6 ++--- 20 files changed, 82 insertions(+), 72 deletions(-) diff --git a/tests/cases/fourslash/renameForDefaultExport01.ts b/tests/cases/fourslash/renameForDefaultExport01.ts index 1256a9698fa..04169d093e5 100644 --- a/tests/cases/fourslash/renameForDefaultExport01.ts +++ b/tests/cases/fourslash/renameForDefaultExport01.ts @@ -1,7 +1,7 @@ /// -////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 }); diff --git a/tests/cases/fourslash/renameForDefaultExport02.ts b/tests/cases/fourslash/renameForDefaultExport02.ts index a6f6116ec1a..1b97657da67 100644 --- a/tests/cases/fourslash/renameForDefaultExport02.ts +++ b/tests/cases/fourslash/renameForDefaultExport02.ts @@ -1,8 +1,8 @@ /// -////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 }); diff --git a/tests/cases/fourslash/renameForDefaultExport03.ts b/tests/cases/fourslash/renameForDefaultExport03.ts index edc22bb0db0..f9f859d2396 100644 --- a/tests/cases/fourslash/renameForDefaultExport03.ts +++ b/tests/cases/fourslash/renameForDefaultExport03.ts @@ -1,10 +1,10 @@ /// -////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 }); diff --git a/tests/cases/fourslash/renameImportAndExport.ts b/tests/cases/fourslash/renameImportAndExport.ts index 6a9cac061a4..bae23ec2d1a 100644 --- a/tests/cases/fourslash/renameImportAndExport.ts +++ b/tests/cases/fourslash/renameImportAndExport.ts @@ -1,8 +1,8 @@ /// -////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 " }]); diff --git a/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts b/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts index 28297fc7255..c2578a80849 100644 --- a/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts +++ b/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts @@ -1,13 +1,13 @@ /// // @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]); diff --git a/tests/cases/fourslash/renameImportAndShorthand.ts b/tests/cases/fourslash/renameImportAndShorthand.ts index 01be6650b3b..be3ee23fb10 100644 --- a/tests/cases/fourslash/renameImportAndShorthand.ts +++ b/tests/cases/fourslash/renameImportAndShorthand.ts @@ -1,7 +1,7 @@ /// -////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: " }]); diff --git a/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts b/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts index e577d82d3ae..942d6a5ffde 100644 --- a/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts +++ b/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts @@ -1,7 +1,7 @@ /// -////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: " }]); diff --git a/tests/cases/fourslash/renameImportOfExportEquals.ts b/tests/cases/fourslash/renameImportOfExportEquals.ts index 6dfe8270c6b..230c50d71fd 100644 --- a/tests/cases/fourslash/renameImportOfExportEquals.ts +++ b/tests/cases/fourslash/renameImportOfExportEquals.ts @@ -1,21 +1,21 @@ /// -////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]; diff --git a/tests/cases/fourslash/renameImportOfExportEquals2.ts b/tests/cases/fourslash/renameImportOfExportEquals2.ts index dfb472caab8..67cb06b761b 100644 --- a/tests/cases/fourslash/renameImportOfExportEquals2.ts +++ b/tests/cases/fourslash/renameImportOfExportEquals2.ts @@ -1,27 +1,27 @@ /// -////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); diff --git a/tests/cases/fourslash/renameImportOfReExport.ts b/tests/cases/fourslash/renameImportOfReExport.ts index ced67d43b9c..9d181b3892f 100644 --- a/tests/cases/fourslash/renameImportOfReExport.ts +++ b/tests/cases/fourslash/renameImportOfReExport.ts @@ -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]); diff --git a/tests/cases/fourslash/renameImportOfReExport2.ts b/tests/cases/fourslash/renameImportOfReExport2.ts index a6389d4aeb8..fe3926fbf9b 100644 --- a/tests/cases/fourslash/renameImportOfReExport2.ts +++ b/tests/cases/fourslash/renameImportOfReExport2.ts @@ -1,13 +1,13 @@ /// ////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; ////} diff --git a/tests/cases/fourslash/renameImportRequire.ts b/tests/cases/fourslash/renameImportRequire.ts index 915143263dd..11b729c72d6 100644 --- a/tests/cases/fourslash/renameImportRequire.ts +++ b/tests/cases/fourslash/renameImportRequire.ts @@ -1,16 +1,16 @@ /// // @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" }]); diff --git a/tests/cases/fourslash/renameInheritedProperties1.ts b/tests/cases/fourslash/renameInheritedProperties1.ts index b42335277a9..2cd8ec23781 100644 --- a/tests/cases/fourslash/renameInheritedProperties1.ts +++ b/tests/cases/fourslash/renameInheritedProperties1.ts @@ -1,10 +1,11 @@ /// //// 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); diff --git a/tests/cases/fourslash/renameInheritedProperties2.ts b/tests/cases/fourslash/renameInheritedProperties2.ts index bcc4c5fc323..de6c6e14d15 100644 --- a/tests/cases/fourslash/renameInheritedProperties2.ts +++ b/tests/cases/fourslash/renameInheritedProperties2.ts @@ -1,10 +1,11 @@ /// //// class class1 extends class1 { -//// [|doStuff|]() { } +//// [|[|{| "declarationRangeIndex": 0 |}doStuff|]() { }|] //// } //// //// var v: class1; //// v.[|doStuff|](); -verify.rangesAreRenameLocations(); +const [rDef, ...ranges] = test.ranges(); +verify.rangesAreRenameLocations(ranges); diff --git a/tests/cases/fourslash/renameInheritedProperties3.ts b/tests/cases/fourslash/renameInheritedProperties3.ts index f1ec547d6ed..9d8e9b65476 100644 --- a/tests/cases/fourslash/renameInheritedProperties3.ts +++ b/tests/cases/fourslash/renameInheritedProperties3.ts @@ -1,10 +1,11 @@ /// //// 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); diff --git a/tests/cases/fourslash/renameInheritedProperties4.ts b/tests/cases/fourslash/renameInheritedProperties4.ts index 42d9acfdb53..1fe0bc9de7b 100644 --- a/tests/cases/fourslash/renameInheritedProperties4.ts +++ b/tests/cases/fourslash/renameInheritedProperties4.ts @@ -1,10 +1,11 @@ /// //// 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); diff --git a/tests/cases/fourslash/renameInheritedProperties5.ts b/tests/cases/fourslash/renameInheritedProperties5.ts index e153742d4ed..352201999a4 100644 --- a/tests/cases/fourslash/renameInheritedProperties5.ts +++ b/tests/cases/fourslash/renameInheritedProperties5.ts @@ -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); diff --git a/tests/cases/fourslash/renameInheritedProperties6.ts b/tests/cases/fourslash/renameInheritedProperties6.ts index 59318334cb0..5f997f3c664 100644 --- a/tests/cases/fourslash/renameInheritedProperties6.ts +++ b/tests/cases/fourslash/renameInheritedProperties6.ts @@ -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); diff --git a/tests/cases/fourslash/renameInheritedProperties7.ts b/tests/cases/fourslash/renameInheritedProperties7.ts index bc0521458f8..94becfd2e5b 100644 --- a/tests/cases/fourslash/renameInheritedProperties7.ts +++ b/tests/cases/fourslash/renameInheritedProperties7.ts @@ -1,7 +1,7 @@ /// //// 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); diff --git a/tests/cases/fourslash/renameInheritedProperties8.ts b/tests/cases/fourslash/renameInheritedProperties8.ts index 7cde300bf0b..f27ded79dae 100644 --- a/tests/cases/fourslash/renameInheritedProperties8.ts +++ b/tests/cases/fourslash/renameInheritedProperties8.ts @@ -1,14 +1,14 @@ /// //// 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"));