11///<reference path="fourslash.ts"/>
22
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 {
1313//// }
14- /////*PlaceOpenBraceOnNewLineForControlBlocks */if (true) {
14+ /////*placeOpenBraceOnNewLineForControlBlocks */if (true) {
1515//// }
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}) {}" ) ;
3132
3233function runTest ( propertyName : string , expectedStringWhenTrue : string , expectedStringWhenFalse : string ) {
3334 // Go to the correct file
@@ -52,4 +53,6 @@ function runTest(propertyName: string, expectedStringWhenTrue: string, expectedS
5253 // Verify
5354 goTo . marker ( propertyName ) ;
5455 verify . currentLineContentIs ( expectedStringWhenTrue ) ;
56+
57+ format . setOption ( propertyName , defaultFormatOption [ propertyName ] )
5558}
0 commit comments