1
1
///<reference path="fourslash.ts"/>
2
2
3
- /////*InsertSpaceAfterCommaDelimiter */[1,2, 3];[ 72 , ];
4
- /////*InsertSpaceAfterSemicolonInForStatements */for (i = 0;i; i++);
5
- /////*InsertSpaceBeforeAndAfterBinaryOperators */1+2- 3
6
- /////*InsertSpaceAfterKeywordsInControlFlowStatements */if (true) { }
7
- /////*InsertSpaceAfterFunctionKeywordForAnonymousFunctions */(function () { })
8
- /////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis */(1 )
9
- /////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets */[1 ]; [ ]; []; [,];
10
- /////*InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces */`${1}`;`${ 1 }`
11
- /////*InsertSpaceAfterTypeAssertion */const bar = <Bar> Thing.getFoo();
12
- /////*PlaceOpenBraceOnNewLineForFunctions */class foo {
3
+ /////*insertSpaceAfterCommaDelimiter */[1,2, 3];[ 72 , ];
4
+ /////*insertSpaceAfterSemicolonInForStatements */for (i = 0;i; i++);
5
+ /////*insertSpaceBeforeAndAfterBinaryOperators */1+2- 3
6
+ /////*insertSpaceAfterKeywordsInControlFlowStatements */if (true) { }
7
+ /////*insertSpaceAfterFunctionKeywordForAnonymousFunctions */(function () { })
8
+ /////*insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis */(1 )
9
+ /////*insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets */[1 ]; [ ]; []; [,];
10
+ /////*insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces */`${1}`;`${ 1 }`
11
+ /////*insertSpaceAfterTypeAssertion */const bar = <Bar> Thing.getFoo();
12
+ /////*placeOpenBraceOnNewLineForFunctions */class foo {
13
13
//// }
14
- /////*PlaceOpenBraceOnNewLineForControlBlocks */if (true) {
14
+ /////*placeOpenBraceOnNewLineForControlBlocks */if (true) {
15
15
//// }
16
- /////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1};
17
-
18
- runTest ( "InsertSpaceAfterCommaDelimiter" , "[1, 2, 3];[72,];" , "[1,2,3];[72,];" ) ;
19
- runTest ( "InsertSpaceAfterSemicolonInForStatements" , "for (i = 0; i; i++);" , "for (i = 0;i;i++);" ) ;
20
- runTest ( "InsertSpaceBeforeAndAfterBinaryOperators" , "1 + 2 - 3" , "1+2-3" ) ;
21
- runTest ( "InsertSpaceAfterKeywordsInControlFlowStatements" , "if (true) { }" , "if(true) { }" ) ;
22
- runTest ( "InsertSpaceAfterFunctionKeywordForAnonymousFunctions" , "(function () { })" , "(function() { })" ) ;
23
- runTest ( "InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis" , " ( 1 )" , " (1)" ) ;
24
- runTest ( "InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets" , "[ 1 ];[];[];[ , ];" , "[1];[];[];[,];" ) ;
25
- runTest ( "InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces" , "`${ 1 }`; `${ 1 }`" , "`${1}`; `${1}`" ) ;
26
- runTest ( "InsertSpaceAfterTypeAssertion" , "const bar = <Bar> Thing.getFoo();" , "const bar = <Bar>Thing.getFoo();" ) ;
27
- runTest ( "PlaceOpenBraceOnNewLineForFunctions" , "class foo" , "class foo {" ) ;
28
- runTest ( "PlaceOpenBraceOnNewLineForControlBlocks" , "if ( true )" , "if ( true ) {" ) ;
29
- runTest ( "InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces" , "{ var t = 1 };" , "{var t = 1};" ) ;
30
-
16
+ /////*insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' };function f( { a, b}) { }
17
+
18
+ const defaultFormatOption = format . copyFormatOptions ( ) ;
19
+
20
+ runTest ( "insertSpaceAfterCommaDelimiter" , "[1, 2, 3];[72,];" , "[1,2,3];[72,];" ) ;
21
+ runTest ( "insertSpaceAfterSemicolonInForStatements" , "for (i = 0; i; i++);" , "for (i = 0;i;i++);" ) ;
22
+ runTest ( "insertSpaceBeforeAndAfterBinaryOperators" , "1 + 2 - 3" , "1+2-3" ) ;
23
+ runTest ( "insertSpaceAfterKeywordsInControlFlowStatements" , "if (true) { }" , "if(true) { }" ) ;
24
+ runTest ( "insertSpaceAfterFunctionKeywordForAnonymousFunctions" , "(function () { })" , "(function() { })" ) ;
25
+ runTest ( "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis" , " ( 1 )" , " (1)" ) ;
26
+ runTest ( "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets" , "[ 1 ];[];[];[ , ];" , "[1];[];[];[,];" ) ;
27
+ runTest ( "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces" , "`${ 1 }`; `${ 1 }`" , "`${1}`; `${1}`" ) ;
28
+ runTest ( "insertSpaceAfterTypeAssertion" , "const bar = <Bar> Thing.getFoo();" , "const bar = <Bar>Thing.getFoo();" ) ;
29
+ runTest ( "placeOpenBraceOnNewLineForFunctions" , "class foo" , "class foo {" ) ;
30
+ runTest ( "placeOpenBraceOnNewLineForControlBlocks" , "if (true)" , "if (true) {" ) ;
31
+ runTest ( "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces" , "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' }; function f({ a, b }) { }" , "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'}; function f({a, b}) {}" ) ;
31
32
32
33
function runTest ( propertyName : string , expectedStringWhenTrue : string , expectedStringWhenFalse : string ) {
33
34
// Go to the correct file
@@ -52,4 +53,6 @@ function runTest(propertyName: string, expectedStringWhenTrue: string, expectedS
52
53
// Verify
53
54
goTo . marker ( propertyName ) ;
54
55
verify . currentLineContentIs ( expectedStringWhenTrue ) ;
56
+
57
+ format . setOption ( propertyName , defaultFormatOption [ propertyName ] )
55
58
}
0 commit comments