Copy smartSelect tests to fourslash

This commit is contained in:
Andrew Branch
2019-04-23 16:41:59 -07:00
parent 6fc2e4a32e
commit e28b9b2ba2
29 changed files with 852 additions and 1 deletions

View File

@@ -1529,7 +1529,7 @@ Actual: ${stringify(fullActual)}`);
baselineContent.push(masked);
selectionRange = selectionRange.parent;
}
return baselineContent.join(n);
return baselineContent.join(fileContent.includes("\n") ? n + n : n);
}).join(n.repeat(2) + "=".repeat(80) + n.repeat(2));
Harness.Baseline.runBaseline(baselineFile, text);

View File

@@ -0,0 +1,30 @@
// Not a JSDoc comment
/**
* @param {number} x The number to square
*/
function /**/square(x) {
return x * x;
}
square
function square(x) {
return x * x;
}
/**
* @param {number} x The number to square
*/
function square(x) {
return x * x;
}
// Not a JSDoc comment
/**
* @param {number} x The number to square
*/
function square(x) {
return x * x;
}

View File

@@ -0,0 +1,4 @@
let/**/ x: string
let
let x: string

View File

@@ -0,0 +1,27 @@
const { /**/x, y: a, ...zs = {} } = {};
x
x, y: a, ...zs = {}
{ x, y: a, ...zs = {} }
const { x, y: a, ...zs = {} } = {};
================================================================================
const { x, y: /**/a, ...zs = {} } = {};
a
y: a
x, y: a, ...zs = {}
{ x, y: a, ...zs = {} }
const { x, y: a, ...zs = {} } = {};
================================================================================
const { x, y: a, .../**/zs = {} } = {};
zs
...zs
...zs = {}
x, y: a, ...zs = {}
{ x, y: a, ...zs = {} }
const { x, y: a, ...zs = {} } = {};

View File

@@ -0,0 +1,12 @@
type X<T, P> = IsExactlyAny<P> extends true ? T : ({ [K in keyof P]: IsExactlyAny<P[K]> extends true ? K extends keyof T ? T[K] : P[/**/K] : P[K]; } & Pick<T, Exclude<keyof T, keyof P>>)
K
P[K]
K extends keyof T ? T[K] : P[K]
IsExactlyAny<P[K]> extends true ? K extends keyof T ? T[K] : P[K] : P[K]
[K in keyof P]: IsExactlyAny<P[K]> extends true ? K extends keyof T ? T[K] : P[K] : P[K];
{ [K in keyof P]: IsExactlyAny<P[K]> extends true ? K extends keyof T ? T[K] : P[K] : P[K]; }
{ [K in keyof P]: IsExactlyAny<P[K]> extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick<T, Exclude<keyof T, keyof P>>
({ [K in keyof P]: IsExactlyAny<P[K]> extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick<T, Exclude<keyof T, keyof P>>)
IsExactlyAny<P> extends true ? T : ({ [K in keyof P]: IsExactlyAny<P[K]> extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick<T, Exclude<keyof T, keyof P>>)
type X<T, P> = IsExactlyAny<P> extends true ? T : ({ [K in keyof P]: IsExactlyAny<P[K]> extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick<T, Exclude<keyof T, keyof P>>)

View File

@@ -0,0 +1,140 @@
class HomePage {
componentDidMount(/**/) {
if (this.props.username) {
return '';
}
}
}
)
componentDidMount() {
if (this.props.username) {
return '';
}
}
••componentDidMount() {
if (this.props.username) {
return '';
}
}↲
class HomePage {
componentDidMount() {
if (this.props.username) {
return '';
}
}
}
================================================================================
class HomePage {
componentDidMount() {
if (this.props.username/**/) {
return '';
}
}
}
)
if (this.props.username) {
return '';
}
••••if (this.props.username) {
return '';
}↲
••
componentDidMount() {
if (this.props.username) {
return '';
}
}
••componentDidMount() {
if (this.props.username) {
return '';
}
}↲
class HomePage {
componentDidMount() {
if (this.props.username) {
return '';
}
}
}
================================================================================
class HomePage {
componentDidMount() {
if (this.props.username) {
return '/**/';
}
}
}
''
return '';
••••••return '';↲
••••
if (this.props.username) {
return '';
}
••••if (this.props.username) {
return '';
}↲
••
componentDidMount() {
if (this.props.username) {
return '';
}
}
••componentDidMount() {
if (this.props.username) {
return '';
}
}↲
class HomePage {
componentDidMount() {
if (this.props.username) {
return '';
}
}
}

View File

@@ -0,0 +1,25 @@
function f(/**/p, q?, ...r: any[] = []) {}
p
p, q?, ...r: any[] = []
function f(p, q?, ...r: any[] = []) {}
================================================================================
function f(p, /**/q?, ...r: any[] = []) {}
q
q?
p, q?, ...r: any[] = []
function f(p, q?, ...r: any[] = []) {}
================================================================================
function f(p, q?, /**/...r: any[] = []) {}
...
...r
...r: any[]
...r: any[] = []
p, q?, ...r: any[] = []
function f(p, q?, ...r: any[] = []) {}

View File

@@ -0,0 +1,18 @@
function f(
a,
/**/b
) {}
b
••a,
b↲
function f(
a,
b
) {}

View File

@@ -0,0 +1,29 @@
import { /**/x as y, z } from './z';
import { b } from './';
console.log(1);
x
x as y
x as y, z
{ x as y, z }
import { x as y, z } from './z';
import { x as y, z } from './z';
import { b } from './';
import { x as y, z } from './z';
import { b } from './';
console.log(1);

View File

@@ -0,0 +1,4 @@
const /**/x = 3;
x
const x = 3;

View File

@@ -0,0 +1,65 @@
type M = { /**/-readonly [K in keyof any]-?: any };
-
-readonly
-readonly [K in keyof any]-?
-readonly [K in keyof any]-?: any
{ -readonly [K in keyof any]-?: any }
type M = { -readonly [K in keyof any]-?: any };
================================================================================
type M = { -re/**/adonly [K in keyof any]-?: any };
readonly
-readonly
-readonly [K in keyof any]-?
-readonly [K in keyof any]-?: any
{ -readonly [K in keyof any]-?: any }
type M = { -readonly [K in keyof any]-?: any };
================================================================================
type M = { -readonly /**/[K in keyof any]-?: any };
[
[K in keyof any]
-readonly [K in keyof any]-?
-readonly [K in keyof any]-?: any
{ -readonly [K in keyof any]-?: any }
type M = { -readonly [K in keyof any]-?: any };
================================================================================
type M = { -readonly [K in ke/**/yof any]-?: any };
keyof
keyof any
K in keyof any
[K in keyof any]
-readonly [K in keyof any]-?
-readonly [K in keyof any]-?: any
{ -readonly [K in keyof any]-?: any }
type M = { -readonly [K in keyof any]-?: any };
================================================================================
type M = { -readonly [K in keyof any]/**/-?: any };
-
-?
-readonly [K in keyof any]-?
-readonly [K in keyof any]-?: any
{ -readonly [K in keyof any]-?: any }
type M = { -readonly [K in keyof any]-?: any };
================================================================================
type M = { -readonly [K in keyof any]-/**/?: any };
?
-?
-readonly [K in keyof any]-?
-readonly [K in keyof any]-?: any
{ -readonly [K in keyof any]-?: any }
type M = { -readonly [K in keyof any]-?: any };

View File

@@ -0,0 +1,174 @@
type X = {
/**/foo?: string;
readonly bar: { x: number };
meh
}
foo
foo?
foo?: string;
••foo?: string;
readonly bar: { x: number };
meh↲
{
foo?: string;
readonly bar: { x: number };
meh
}
type X = {
foo?: string;
readonly bar: { x: number };
meh
}
================================================================================
type X = {
foo?: string;
/**/readonly bar: { x: number };
meh
}
readonly
readonly bar
readonly bar: { x: number };
••foo?: string;
readonly bar: { x: number };
meh↲
{
foo?: string;
readonly bar: { x: number };
meh
}
type X = {
foo?: string;
readonly bar: { x: number };
meh
}
================================================================================
type X = {
foo?: string;
readonly /**/bar: { x: number };
meh
}
bar
readonly bar
readonly bar: { x: number };
••foo?: string;
readonly bar: { x: number };
meh↲
{
foo?: string;
readonly bar: { x: number };
meh
}
type X = {
foo?: string;
readonly bar: { x: number };
meh
}
================================================================================
type X = {
foo?: string;
readonly bar: { x: num/**/ber };
meh
}
number
x: number
{ x: number }
readonly bar: { x: number };
••foo?: string;
readonly bar: { x: number };
meh↲
{
foo?: string;
readonly bar: { x: number };
meh
}
type X = {
foo?: string;
readonly bar: { x: number };
meh
}
================================================================================
type X = {
foo?: string;
readonly bar: { x: number };
/**/meh
}
meh
••foo?: string;
readonly bar: { x: number };
meh↲
{
foo?: string;
readonly bar: { x: number };
meh
}
type X = {
foo?: string;
readonly bar: { x: number };
meh
}

View File

@@ -0,0 +1,116 @@
class Foo {
bar(a, b) {
if (/**/a === b) {
return true;
}
return false;
}
}
a
a === b
if (a === b) {
return true;
}
••••••if (a === b) {
return true;
}
return false;↲
••
bar(a, b) {
if (a === b) {
return true;
}
return false;
}
••bar(a, b) {
if (a === b) {
return true;
}
return false;
}↲
class Foo {
bar(a, b) {
if (a === b) {
return true;
}
return false;
}
}
================================================================================
class Foo {
bar(a, b) {
if (a === b) {
return tr/**/ue;
}
return false;
}
}
true
return true;
••••••••••return true;↲
••••••
if (a === b) {
return true;
}
••••••if (a === b) {
return true;
}
return false;↲
••
bar(a, b) {
if (a === b) {
return true;
}
return false;
}
••bar(a, b) {
if (a === b) {
return true;
}
return false;
}↲
class Foo {
bar(a, b) {
if (a === b) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,63 @@
export interface IService {
_serviceBrand: any;
open(ho/**/st: number, data: any): Promise<any>;
bar(): void
}
host
host: number
host: number, data: any
open(host: number, data: any): Promise<any>;
••_serviceBrand: any;
open(host: number, data: any): Promise<any>;
bar(): void↲
export interface IService {
_serviceBrand: any;
open(host: number, data: any): Promise<any>;
bar(): void
}
================================================================================
export interface IService {
_serviceBrand: any;
open(host: number, data: any): Promise<any>;
bar(): void/**/
}
void
bar(): void
••_serviceBrand: any;
open(host: number, data: any): Promise<any>;
bar(): void↲
export interface IService {
_serviceBrand: any;
open(host: number, data: any): Promise<any>;
bar(): void
}

View File

@@ -0,0 +1,37 @@
`a /**/b ${
'c'
} d`
a b ${
'c'
} d
`a b ${
'c'
} d`
================================================================================
`a b ${
'/**/c'
} d`
c
'c'
${
'c'
}
a b ${
'c'
} d
`a b ${
'c'
} d`

View File

@@ -0,0 +1,11 @@
/// <reference path="fourslash.ts" />
////// Not a JSDoc comment
/////**
//// * @param {number} x The number to square
//// */
////function /**/square(x) {
//// return x * x;
////}
verify.baselineSmartSelection();

View File

@@ -0,0 +1,6 @@
/// <reference path="fourslash.ts" />
////let/**/ x: string
// Verifies that the selection goes to 'let' first even though its behind the caret
verify.baselineSmartSelection();

View File

@@ -0,0 +1,5 @@
/// <reference path="fourslash.ts" />
////const { /*1*/x, y: /*2*/a, .../*3*/zs = {} } = {};
verify.baselineSmartSelection();

View File

@@ -0,0 +1,5 @@
/// <reference path="fourslash.ts" />
////type X<T, P> = IsExactlyAny<P> extends true ? T : ({ [K in keyof P]: IsExactlyAny<P[K]> extends true ? K extends keyof T ? T[K] : P[/**/K] : P[K]; } & Pick<T, Exclude<keyof T, keyof P>>)
verify.baselineSmartSelection();

View File

@@ -0,0 +1,11 @@
/// <reference path="fourslash.ts" />
////class HomePage {
//// componentDidMount(/*1*/) {
//// if (this.props.username/*2*/) {
//// return '/*3*/';
//// }
//// }
////}
verify.baselineSmartSelection();

View File

@@ -0,0 +1,5 @@
/// <reference path="fourslash.ts" />
////function f(/*1*/p, /*2*/q?, /*3*/...r: any[] = []) {}
verify.baselineSmartSelection();

View File

@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////function f(
//// a,
//// /**/b
////) {}
verify.baselineSmartSelection();

View File

@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////import { /**/x as y, z } from './z';
////import { b } from './';
////
////console.log(1);
verify.baselineSmartSelection();

View File

@@ -0,0 +1,5 @@
/// <reference path="fourslash.ts" />
////const /**/x = 3;
verify.baselineSmartSelection();

View File

@@ -0,0 +1,5 @@
/// <reference path="fourslash.ts" />
////type M = { /*1*/-re/*2*/adonly /*3*/[K in ke/*4*/yof any]/*5*/-/*6*/?: any };
verify.baselineSmartSelection();

View File

@@ -0,0 +1,9 @@
/// <reference path="fourslash.ts" />
////type X = {
//// /*1*/foo?: string;
//// /*2*/readonly /*3*/bar: { x: num/*4*/ber };
//// /*5*/meh
////}
verify.baselineSmartSelection();

View File

@@ -0,0 +1,12 @@
/// <reference path="fourslash.ts" />
////class Foo {
//// bar(a, b) {
//// if (/*1*/a === b) {
//// return tr/*2*/ue;
//// }
//// return false;
//// }
////}
verify.baselineSmartSelection();

View File

@@ -0,0 +1,10 @@
/// <reference path="fourslash.ts" />
////export interface IService {
//// _serviceBrand: any;
////
//// open(ho/*1*/st: number, data: any): Promise<any>;
//// bar(): void/*2*/
////}
verify.baselineSmartSelection();

View File

@@ -0,0 +1,7 @@
/// <reference path="fourslash.ts" />
////`a /*1*/b ${
//// '/*2*/c'
////} d`
verify.baselineSmartSelection();