Include range markers in Extract Constant/Function baselines

This commit is contained in:
Andrew Casey
2017-10-03 13:50:17 -07:00
parent 2cb965c268
commit a10274a867
108 changed files with 128 additions and 128 deletions
+1 -1
View File
@@ -135,7 +135,7 @@ namespace ts {
Harness.Baseline.runBaseline(`${baselineFolder}/${caption}${extension}`, () => {
const data: string[] = [];
data.push(`// ==ORIGINAL==`);
data.push(sourceFile.text);
data.push(text.replace("[#|", "/*[#|*/").replace("|]", "/*|]*/"));
for (const action of actions) {
const { renameLocation, edits } = refactor.extractSymbol.getEditsForAction(context, action.name);
assert.lengthOf(edits, 1);
@@ -1,7 +1,7 @@
// ==ORIGINAL==
const f = () => {
return 2 + 1;
return /*[#|*/2 + 1/*|]*/;
};
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,7 +1,7 @@
// ==ORIGINAL==
const f = () => {
return 2 + 1;
return /*[#|*/2 + 1/*|]*/;
};
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,5 +1,5 @@
// ==ORIGINAL==
const f = () => 2 + 1;
const f = () => /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in global scope==
const newLocal = 2 + 1;
@@ -1,5 +1,5 @@
// ==ORIGINAL==
const f = () => 2 + 1;
const f = () => /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in global scope==
const newLocal = 2 + 1;
@@ -2,7 +2,7 @@
for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
const x = i + 1;
const x = /*[#|*/i + 1/*|]*/;
}
}
@@ -2,7 +2,7 @@
for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
const x = i + 1;
const x = /*[#|*/i + 1/*|]*/;
}
}
@@ -1,7 +1,7 @@
// ==ORIGINAL==
for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,7 +1,7 @@
// ==ORIGINAL==
for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,6 +1,6 @@
// ==ORIGINAL==
class C {
x = 1;
x = /*[#|*/1/*|]*/;
}
// ==SCOPE::Extract to constant in global scope==
const newLocal = 1;
@@ -1,6 +1,6 @@
// ==ORIGINAL==
class C {
x = 1;
x = /*[#|*/1/*|]*/;
}
// ==SCOPE::Extract to readonly field in class 'C'==
class C {
@@ -5,7 +5,7 @@ class C {
M1() { }
M2() { }
M3() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -5,7 +5,7 @@ class C {
M1() { }
M2() { }
M3() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -5,7 +5,7 @@ class C {
b = 2;
M2() { }
M3() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -5,7 +5,7 @@ class C {
b = 2;
M2() { }
M3() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -5,7 +5,7 @@ class C {
b = 2;
M2() { }
M3() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -5,7 +5,7 @@ class C {
b = 2;
M2() { }
M3() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -2,7 +2,7 @@
"strict";
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -2,7 +2,7 @@
"strict";
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,4 +1,4 @@
// ==ORIGINAL==
"hello";
/*[#|*/"hello";/*|]*/
// ==SCOPE::Extract to constant in enclosing scope==
const /*RENAME*/newLocal = "hello";
@@ -1,4 +1,4 @@
// ==ORIGINAL==
"hello";
/*[#|*/"hello";/*|]*/
// ==SCOPE::Extract to constant in enclosing scope==
const /*RENAME*/newLocal = "hello";
@@ -2,7 +2,7 @@
function F() {
let i = 0;
i++;
/*[#|*/i++/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -2,7 +2,7 @@
function F() {
let i = 0;
i++;
/*[#|*/i++/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,4 +1,4 @@
// ==ORIGINAL==
"hello";
/*[#|*/"hello"/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
const /*RENAME*/newLocal = "hello";
@@ -1,4 +1,4 @@
// ==ORIGINAL==
"hello";
/*[#|*/"hello"/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
const /*RENAME*/newLocal = "hello";
@@ -2,7 +2,7 @@
let i = 0;
function F() {
i++;
/*[#|*/i++/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -2,7 +2,7 @@
let i = 0;
function F() {
i++;
/*[#|*/i++/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,6 +1,6 @@
// ==ORIGINAL==
function F() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
function F() {
@@ -1,6 +1,6 @@
// ==ORIGINAL==
function F() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
function F() {
@@ -1,7 +1,7 @@
// ==ORIGINAL==
class C {
M() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,7 +1,7 @@
// ==ORIGINAL==
class C {
M() {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -6,7 +6,7 @@
"strict";
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -6,7 +6,7 @@
"strict";
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,6 +1,6 @@
// ==ORIGINAL==
namespace N {
let x = 1;
let x = /*[#|*/1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
namespace N {
@@ -1,7 +1,7 @@
// ==ORIGINAL==
function F() {
let w = 1;
let x = w + 1;
let x = /*[#|*/w + 1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
function F() {
@@ -1,7 +1,7 @@
// ==ORIGINAL==
function F() {
let w = 1;
let x = w + 1;
let x = /*[#|*/w + 1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
function F() {
@@ -2,7 +2,7 @@
/*! Copyright */
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -2,7 +2,7 @@
/*! Copyright */
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -3,7 +3,7 @@
/*! Copyright */
/* About x */
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -3,7 +3,7 @@
/*! Copyright */
/* About x */
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,7 +1,7 @@
// ==ORIGINAL==
namespace X {
export const j = 10;
export const y = j * j;
export const y = /*[#|*/j * j/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
namespace X {
@@ -2,7 +2,7 @@
const i = 0;
for (let j = 0; j < 10; j++) {
const x = i + 1;
const x = /*[#|*/i + 1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -2,7 +2,7 @@
const i = 0;
for (let j = 0; j < 10; j++) {
const x = i + 1;
const x = /*[#|*/i + 1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -3,7 +3,7 @@
const i = 0;
function F() {
for (let j = 0; j < 10; j++) {
const x = i + 1;
const x = /*[#|*/i + 1/*|]*/;
}
}
@@ -3,7 +3,7 @@
const i = 0;
function F() {
for (let j = 0; j < 10; j++) {
const x = i + 1;
const x = /*[#|*/i + 1/*|]*/;
}
}
@@ -1,7 +1,7 @@
// ==ORIGINAL==
for (let j = 0; j < 10; j++) {
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,7 +1,7 @@
// ==ORIGINAL==
for (let j = 0; j < 10; j++) {
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
@@ -2,7 +2,7 @@
function F() {
for (let j = 0; j < 10; j++) {
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
}
}
@@ -2,7 +2,7 @@
function F() {
for (let j = 0; j < 10; j++) {
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
}
}
@@ -2,7 +2,7 @@
function F0() {
function F1() {
function F2(x = 2 + 1) {
function F2(x = /*[#|*/2 + 1/*|]*/) {
}
}
}
@@ -2,7 +2,7 @@
function F0() {
function F1() {
function F2(x = 2 + 1) {
function F2(x = /*[#|*/2 + 1/*|]*/) {
}
}
}
@@ -1,7 +1,7 @@
// ==ORIGINAL==
class C {
x = 2 + 1;
x = /*[#|*/2 + 1/*|]*/;
}
// ==SCOPE::Extract to constant in global scope==
@@ -1,7 +1,7 @@
// ==ORIGINAL==
class C {
x = 2 + 1;
x = /*[#|*/2 + 1/*|]*/;
}
// ==SCOPE::Extract to readonly field in class 'C'==
@@ -4,7 +4,7 @@ const i = 0;
class C {
M() {
for (let j = 0; j < 10; j++) {
x = i + 1;
x = /*[#|*/i + 1/*|]*/;
}
}
}
@@ -4,7 +4,7 @@ const i = 0;
class C {
M() {
for (let j = 0; j < 10; j++) {
x = i + 1;
x = /*[#|*/i + 1/*|]*/;
}
}
}
@@ -1,5 +1,5 @@
// ==ORIGINAL==
let x = 1;
let x = /*[#|*/1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
const newLocal = 1;
@@ -1,5 +1,5 @@
// ==ORIGINAL==
let x = 1;
let x = /*[#|*/1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
const newLocal = 1;
@@ -2,7 +2,7 @@
/// <reference path="path.js"/>
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -2,7 +2,7 @@
/// <reference path="path.js"/>
const x = 2 + 1;
const x = /*[#|*/2 + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
@@ -1,6 +1,6 @@
// ==ORIGINAL==
function F<T>(t: T) {
let x = t + 1;
let x = /*[#|*/t + 1/*|]*/;
}
// ==SCOPE::Extract to constant in enclosing scope==
function F<T>(t: T) {
@@ -1,6 +1,6 @@
// ==ORIGINAL==
const /*About A*/a = 1,
/*About B*/b = a + 1;
/*About B*/b = /*[#|*/a + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
const /*About A*/a = 1,
/*About B*/newLocal = a + 1, b = /*RENAME*/newLocal;
@@ -1,6 +1,6 @@
// ==ORIGINAL==
const /*About A*/a = 1,
/*About B*/b = a + 1;
/*About B*/b = /*[#|*/a + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
const /*About A*/a = 1,
/*About B*/newLocal = a + 1, b = /*RENAME*/newLocal;
@@ -1,4 +1,4 @@
// ==ORIGINAL==
const a = 1, b = a + 1;
const a = 1, b = /*[#|*/a + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
const a = 1, newLocal = a + 1, b = /*RENAME*/newLocal;
@@ -1,4 +1,4 @@
// ==ORIGINAL==
const a = 1, b = a + 1;
const a = 1, b = /*[#|*/a + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
const a = 1, newLocal = a + 1, b = /*RENAME*/newLocal;
@@ -1,4 +1,4 @@
// ==ORIGINAL==
let a = 1, b = a + 1;
let a = 1, b = /*[#|*/a + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
let a = 1, newLocal = a + 1, b = /*RENAME*/newLocal;
@@ -1,4 +1,4 @@
// ==ORIGINAL==
let a = 1, b = a + 1;
let a = 1, b = /*[#|*/a + 1/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
let a = 1, newLocal = a + 1, b = /*RENAME*/newLocal;
@@ -6,11 +6,11 @@ namespace A {
namespace B {
function a() {
let a = 1;
/*[#|*/
let y = 5;
let z = x;
a = y;
foo();
foo();/*|]*/
}
}
}
@@ -4,8 +4,8 @@ namespace A {
class C {
a() {
let z = 1;
let a1: I = { x: 1 };
return a1.x + 10;
/*[#|*/let a1: I = { x: 1 };
return a1.x + 10;/*|]*/
}
}
}
@@ -4,10 +4,10 @@ namespace A {
class C {
a() {
let z = 1;
let a1 = { x: 1 };
/*[#|*/let a1 = { x: 1 };
y = 10;
z = 42;
return a1.x + 10;
return a1.x + 10;/*|]*/
}
}
}
@@ -5,11 +5,11 @@ namespace A {
b() {}
a() {
let z = 1;
let a1 = { x: 1 };
/*[#|*/let a1 = { x: 1 };
y = 10;
z = 42;
this.b();
return a1.x + 10;
return a1.x + 10;/*|]*/
}
}
}
@@ -4,11 +4,11 @@
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
t1a.toString();
/*[#|*/t1a.toString();
t2a.toString();
u1a.toString();
u2a.toString();
u3a.toString();
u3a.toString();/*|]*/
}
}
}
@@ -1,8 +1,8 @@
// ==ORIGINAL==
function F<T>(t1: T) {
function G<T>(t2: T) {
t1.toString();
t2.toString();
/*[#|*/t1.toString();
t2.toString();/*|]*/
}
}
// ==SCOPE::Extract to inner function in function 'G'==
@@ -1,7 +1,7 @@
// ==ORIGINAL==
function F<T>(t1: T) {
function G<U extends T[]>(t2: U) {
t2.toString();
/*[#|*/t2.toString();/*|]*/
}
}
// ==SCOPE::Extract to inner function in function 'G'==
@@ -1,6 +1,6 @@
// ==ORIGINAL==
function F<T>() {
const array: T[] = [];
const array: T[] = /*[#|*/[]/*|]*/;
}
// ==SCOPE::Extract to inner function in function 'F'==
function F<T>() {
@@ -1,7 +1,7 @@
// ==ORIGINAL==
class C<T1, T2> {
M(t1: T1, t2: T2) {
t1.toString();
/*[#|*/t1.toString()/*|]*/;
}
}
// ==SCOPE::Extract to method in class 'C'==
@@ -1,7 +1,7 @@
// ==ORIGINAL==
class C {
M<T1, T2>(t1: T1, t2: T2) {
t1.toString();
/*[#|*/t1.toString()/*|]*/;
}
}
// ==SCOPE::Extract to method in class 'C'==
@@ -1,6 +1,6 @@
// ==ORIGINAL==
function F<T, U extends T[], V extends U[]>(v: V) {
v.toString();
/*[#|*/v.toString()/*|]*/;
}
// ==SCOPE::Extract to inner function in function 'F'==
function F<T, U extends T[], V extends U[]>(v: V) {
@@ -5,10 +5,10 @@ namespace A {
}
namespace B {
function a() {
/*[#|*/
let y = 5;
let z = x;
return foo();
return foo();/*|]*/
}
}
}
@@ -1,8 +1,8 @@
// ==ORIGINAL==
const _ = class {
a() {
let a1 = { x: 1 };
return a1.x + 10;
/*[#|*/let a1 = { x: 1 };
return a1.x + 10;/*|]*/
}
}
// ==SCOPE::Extract to method in anonymous class expression==
@@ -1,8 +1,8 @@
// ==ORIGINAL==
const _ = class {
a() {
let a1 = { x: 1 };
return a1.x + 10;
/*[#|*/let a1 = { x: 1 };
return a1.x + 10;/*|]*/
}
}
// ==SCOPE::Extract to method in anonymous class expression==
@@ -1,8 +1,8 @@
// ==ORIGINAL==
function foo() {
let x = 10;
x++;
return;
/*[#|*/x++;
return;/*|]*/
}
// ==SCOPE::Extract to inner function in function 'foo'==
function foo() {
@@ -1,8 +1,8 @@
// ==ORIGINAL==
function foo() {
let x = 10;
x++;
return;
/*[#|*/x++;
return;/*|]*/
}
// ==SCOPE::Extract to inner function in function 'foo'==
function foo() {
@@ -3,7 +3,7 @@ function test() {
try {
}
finally {
return 1;
/*[#|*/return 1;/*|]*/
}
}
// ==SCOPE::Extract to inner function in function 'test'==
@@ -3,7 +3,7 @@ function test() {
try {
}
finally {
return 1;
/*[#|*/return 1;/*|]*/
}
}
// ==SCOPE::Extract to inner function in function 'test'==
@@ -2,7 +2,7 @@
namespace NS {
function M1() { }
function M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
function M3() { }
}
@@ -2,7 +2,7 @@
function Outer() {
function M1() { }
function M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
function M3() { }
}
@@ -2,7 +2,7 @@
function Outer() {
function M1() { }
function M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
function M3() { }
}
@@ -1,7 +1,7 @@
// ==ORIGINAL==
function M1() { }
function M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
function M3() { }
// ==SCOPE::Extract to inner function in function 'M2'==
@@ -1,7 +1,7 @@
// ==ORIGINAL==
function M1() { }
function M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
function M3() { }
// ==SCOPE::Extract to inner function in function 'M2'==
@@ -2,7 +2,7 @@
class C {
M1() { }
M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
M3() { }
}
@@ -2,7 +2,7 @@
class C {
M1() { }
M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
M3() { }
}
@@ -2,7 +2,7 @@
class C {
M1() { }
M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
constructor() { }
M3() { }
@@ -2,7 +2,7 @@
class C {
M1() { }
M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
constructor() { }
M3() { }
@@ -2,7 +2,7 @@
class C {
M1() { }
M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
M3() { }
constructor() { }
@@ -2,7 +2,7 @@
class C {
M1() { }
M2() {
return 1;
/*[#|*/return 1;/*|]*/
}
M3() { }
constructor() { }
@@ -6,11 +6,11 @@ interface UnaryExpression {
}
function parseUnaryExpression(operator: string): UnaryExpression {
return {
/*[#|*/return {
kind: "Unary",
operator,
operand: parsePrimaryExpression(),
};
};/*|]*/
}
function parsePrimaryExpression(): any {
@@ -4,10 +4,10 @@ namespace A {
}
namespace B {
function* a(z: number) {
/*[#|*/
let y = 5;
yield z;
return foo();
return foo();/*|]*/
}
}
}
@@ -1,6 +1,6 @@
// ==ORIGINAL==
function F<T>() {
let t: T;
/*[#|*/let t: T;/*|]*/
}
// ==SCOPE::Extract to inner function in function 'F'==
function F<T>() {
@@ -5,9 +5,9 @@ namespace N {
() => {
var f: () => number;
f = function (): number {
/*[#|*/f = function (): number {
return value;
}
}/*|]*/
}
}
// ==SCOPE::Extract to function in namespace 'N'==
@@ -4,11 +4,11 @@ namespace N {
export const value = 1;
() => {
var c = class {
/*[#|*/var c = class {
M() {
return value;
}
}
}/*|]*/
}
}
// ==SCOPE::Extract to function in namespace 'N'==

Some files were not shown because too many files have changed in this diff Show More