1 //===- unittest/Format/FormatTestJS.cpp - Formatting unit tests for JS ----===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "FormatTestUtils.h" 11 #include "clang/Format/Format.h" 12 #include "llvm/Support/Debug.h" 13 #include "gtest/gtest.h" 14 15 #define DEBUG_TYPE "format-test" 16 17 namespace clang { 18 namespace format { 19 20 class FormatTestJS : public ::testing::Test { 21 protected: 22 static std::string format(llvm::StringRef Code, unsigned Offset, 23 unsigned Length, const FormatStyle &Style) { 24 DEBUG(llvm::errs() << "---\n"); 25 DEBUG(llvm::errs() << Code << "\n\n"); 26 std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length)); 27 tooling::Replacements Replaces = reformat(Style, Code, Ranges); 28 std::string Result = applyAllReplacements(Code, Replaces); 29 EXPECT_NE("", Result); 30 DEBUG(llvm::errs() << "\n" << Result << "\n\n"); 31 return Result; 32 } 33 34 static std::string format( 35 llvm::StringRef Code, 36 const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) { 37 return format(Code, 0, Code.size(), Style); 38 } 39 40 static FormatStyle getGoogleJSStyleWithColumns(unsigned ColumnLimit) { 41 FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript); 42 Style.ColumnLimit = ColumnLimit; 43 return Style; 44 } 45 46 static void verifyFormat( 47 llvm::StringRef Code, 48 const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) { 49 EXPECT_EQ(Code.str(), format(test::messUp(Code), Style)); 50 } 51 }; 52 53 TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) { 54 verifyFormat("a == = b;"); 55 verifyFormat("a != = b;"); 56 57 verifyFormat("a === b;"); 58 verifyFormat("aaaaaaa ===\n b;", getGoogleJSStyleWithColumns(10)); 59 verifyFormat("a !== b;"); 60 verifyFormat("aaaaaaa !==\n b;", getGoogleJSStyleWithColumns(10)); 61 verifyFormat("if (a + b + c +\n" 62 " d !==\n" 63 " e + f + g)\n" 64 " q();", 65 getGoogleJSStyleWithColumns(20)); 66 67 verifyFormat("a >> >= b;"); 68 69 verifyFormat("a >>> b;"); 70 verifyFormat("aaaaaaa >>>\n b;", getGoogleJSStyleWithColumns(10)); 71 verifyFormat("a >>>= b;"); 72 verifyFormat("aaaaaaa >>>=\n b;", getGoogleJSStyleWithColumns(10)); 73 verifyFormat("if (a + b + c +\n" 74 " d >>>\n" 75 " e + f + g)\n" 76 " q();", 77 getGoogleJSStyleWithColumns(20)); 78 verifyFormat("var x = aaaaaaaaaa ?\n" 79 " bbbbbb :\n" 80 " ccc;", 81 getGoogleJSStyleWithColumns(20)); 82 83 verifyFormat("var b = a.map((x) => x + 1);"); 84 verifyFormat("return ('aaa') in bbbb;"); 85 } 86 87 TEST_F(FormatTestJS, UnderstandsAmpAmp) { 88 verifyFormat("e && e.SomeFunction();"); 89 } 90 91 TEST_F(FormatTestJS, LiteralOperatorsCanBeKeywords) { 92 verifyFormat("not.and.or.not_eq = 1;"); 93 } 94 95 TEST_F(FormatTestJS, ES6DestructuringAssignment) { 96 verifyFormat("var [a, b, c] = [1, 2, 3];"); 97 verifyFormat("var {a, b} = {a: 1, b: 2};"); 98 } 99 100 TEST_F(FormatTestJS, ContainerLiterals) { 101 verifyFormat("return {\n" 102 " link: function() {\n" 103 " f(); //\n" 104 " }\n" 105 "};"); 106 verifyFormat("return {\n" 107 " a: a,\n" 108 " link: function() {\n" 109 " f(); //\n" 110 " }\n" 111 "};"); 112 verifyFormat("return {\n" 113 " a: a,\n" 114 " link: function() {\n" 115 " f(); //\n" 116 " },\n" 117 " link: function() {\n" 118 " f(); //\n" 119 " }\n" 120 "};"); 121 verifyFormat("var stuff = {\n" 122 " // comment for update\n" 123 " update: false,\n" 124 " // comment for modules\n" 125 " modules: false,\n" 126 " // comment for tasks\n" 127 " tasks: false\n" 128 "};"); 129 verifyFormat("return {\n" 130 " 'finish':\n" 131 " //\n" 132 " a\n" 133 "};"); 134 verifyFormat("var obj = {\n" 135 " fooooooooo: function(x) {\n" 136 " return x.zIsTooLongForOneLineWithTheDeclarationLine();\n" 137 " }\n" 138 "};"); 139 // Simple object literal, as opposed to enum style below. 140 verifyFormat("var obj = {a: 123};"); 141 // Enum style top level assignment. 142 verifyFormat("X = {\n a: 123\n};"); 143 verifyFormat("X.Y = {\n a: 123\n};"); 144 verifyFormat("x = foo && {a: 123};"); 145 } 146 147 TEST_F(FormatTestJS, SpacesInContainerLiterals) { 148 verifyFormat("var arr = [1, 2, 3];"); 149 verifyFormat("f({a: 1, b: 2, c: 3});"); 150 151 verifyFormat("var object_literal_with_long_name = {\n" 152 " a: 'aaaaaaaaaaaaaaaaaa',\n" 153 " b: 'bbbbbbbbbbbbbbbbbb'\n" 154 "};"); 155 156 verifyFormat("f({a: 1, b: 2, c: 3});", 157 getChromiumStyle(FormatStyle::LK_JavaScript)); 158 verifyFormat("f({'a': [{}]});"); 159 } 160 161 TEST_F(FormatTestJS, SingleQuoteStrings) { 162 verifyFormat("this.function('', true);"); 163 } 164 165 TEST_F(FormatTestJS, GoogScopes) { 166 verifyFormat("goog.scope(function() {\n" 167 "var x = a.b;\n" 168 "var y = c.d;\n" 169 "}); // goog.scope"); 170 verifyFormat("goog.scope(function() {\n" 171 "// test\n" 172 "var x = 0;\n" 173 "// test\n" 174 "});"); 175 } 176 177 TEST_F(FormatTestJS, GoogModules) { 178 verifyFormat("goog.module('this.is.really.absurdly.long');", 179 getGoogleJSStyleWithColumns(40)); 180 verifyFormat("goog.require('this.is.really.absurdly.long');", 181 getGoogleJSStyleWithColumns(40)); 182 verifyFormat("goog.provide('this.is.really.absurdly.long');", 183 getGoogleJSStyleWithColumns(40)); 184 verifyFormat("var long = goog.require('this.is.really.absurdly.long');", 185 getGoogleJSStyleWithColumns(40)); 186 187 // These should be wrapped normally. 188 verifyFormat( 189 "var MyLongClassName =\n" 190 " goog.module.get('my.long.module.name.followedBy.MyLongClassName');"); 191 } 192 193 TEST_F(FormatTestJS, FormatsFreestandingFunctions) { 194 verifyFormat("function outer1(a, b) {\n" 195 " function inner1(a, b) { return a; }\n" 196 " inner1(a, b);\n" 197 "}\n" 198 "function outer2(a, b) {\n" 199 " function inner2(a, b) { return a; }\n" 200 " inner2(a, b);\n" 201 "}"); 202 } 203 204 TEST_F(FormatTestJS, FunctionLiterals) { 205 verifyFormat("doFoo(function() {});"); 206 verifyFormat("doFoo(function() { return 1; });"); 207 verifyFormat("var func = function() {\n" 208 " return 1;\n" 209 "};"); 210 verifyFormat("return {\n" 211 " body: {\n" 212 " setAttribute: function(key, val) { this[key] = val; },\n" 213 " getAttribute: function(key) { return this[key]; },\n" 214 " style: {direction: ''}\n" 215 " }\n" 216 "};"); 217 EXPECT_EQ("abc = xyz ?\n" 218 " function() {\n" 219 " return 1;\n" 220 " } :\n" 221 " function() {\n" 222 " return -1;\n" 223 " };", 224 format("abc=xyz?function(){return 1;}:function(){return -1;};")); 225 226 verifyFormat("var closure = goog.bind(\n" 227 " function() { // comment\n" 228 " foo();\n" 229 " bar();\n" 230 " },\n" 231 " this, arg1IsReallyLongAndNeeedsLineBreaks,\n" 232 " arg3IsReallyLongAndNeeedsLineBreaks);"); 233 verifyFormat("var closure = goog.bind(function() { // comment\n" 234 " foo();\n" 235 " bar();\n" 236 "}, this);"); 237 verifyFormat("return {\n" 238 " a: 'E',\n" 239 " b: function() {\n" 240 " return function() {\n" 241 " f(); //\n" 242 " };\n" 243 " }\n" 244 "};"); 245 verifyFormat("{\n" 246 " var someVariable = function(x) {\n" 247 " return x.zIsTooLongForOneLineWithTheDeclarationLine();\n" 248 " };\n" 249 "}"); 250 251 verifyFormat("f({a: function() { return 1; }});", 252 getGoogleJSStyleWithColumns(33)); 253 verifyFormat("f({\n" 254 " a: function() { return 1; }\n" 255 "});", 256 getGoogleJSStyleWithColumns(32)); 257 258 verifyFormat("return {\n" 259 " a: function SomeFunction() {\n" 260 " // ...\n" 261 " return 1;\n" 262 " }\n" 263 "};"); 264 verifyFormat("this.someObject.doSomething(aaaaaaaaaaaaaaaaaaaaaaaaaa)\n" 265 " .then(goog.bind(function(aaaaaaaaaaa) {\n" 266 " someFunction();\n" 267 " someFunction();\n" 268 " }, this), aaaaaaaaaaaaaaaaa);"); 269 270 // FIXME: This is not ideal yet. 271 verifyFormat("someFunction(goog.bind(\n" 272 " function() {\n" 273 " doSomething();\n" 274 " doSomething();\n" 275 " },\n" 276 " this),\n" 277 " goog.bind(function() {\n" 278 " doSomething();\n" 279 " doSomething();\n" 280 " }, this));"); 281 } 282 283 TEST_F(FormatTestJS, InliningFunctionLiterals) { 284 FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript); 285 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; 286 verifyFormat("var func = function() {\n" 287 " return 1;\n" 288 "};", 289 Style); 290 verifyFormat("var func = doSomething(function() { return 1; });", Style); 291 verifyFormat("var outer = function() {\n" 292 " var inner = function() { return 1; }\n" 293 "};", 294 Style); 295 verifyFormat("function outer1(a, b) {\n" 296 " function inner1(a, b) { return a; }\n" 297 "}", 298 Style); 299 300 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All; 301 verifyFormat("var func = function() { return 1; };", Style); 302 verifyFormat("var func = doSomething(function() { return 1; });", Style); 303 verifyFormat( 304 "var outer = function() { var inner = function() { return 1; } };", 305 Style); 306 verifyFormat("function outer1(a, b) {\n" 307 " function inner1(a, b) { return a; }\n" 308 "}", 309 Style); 310 311 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None; 312 verifyFormat("var func = function() {\n" 313 " return 1;\n" 314 "};", 315 Style); 316 verifyFormat("var func = doSomething(function() {\n" 317 " return 1;\n" 318 "});", 319 Style); 320 verifyFormat("var outer = function() {\n" 321 " var inner = function() {\n" 322 " return 1;\n" 323 " }\n" 324 "};", 325 Style); 326 verifyFormat("function outer1(a, b) {\n" 327 " function inner1(a, b) {\n" 328 " return a;\n" 329 " }\n" 330 "}", 331 Style); 332 } 333 334 TEST_F(FormatTestJS, MultipleFunctionLiterals) { 335 verifyFormat("promise.then(\n" 336 " function success() {\n" 337 " doFoo();\n" 338 " doBar();\n" 339 " },\n" 340 " function error() {\n" 341 " doFoo();\n" 342 " doBaz();\n" 343 " },\n" 344 " []);\n"); 345 verifyFormat("promise.then(\n" 346 " function success() {\n" 347 " doFoo();\n" 348 " doBar();\n" 349 " },\n" 350 " [],\n" 351 " function error() {\n" 352 " doFoo();\n" 353 " doBaz();\n" 354 " });\n"); 355 // FIXME: Here, we should probably break right after the "(" for consistency. 356 verifyFormat("promise.then([],\n" 357 " function success() {\n" 358 " doFoo();\n" 359 " doBar();\n" 360 " },\n" 361 " function error() {\n" 362 " doFoo();\n" 363 " doBaz();\n" 364 " });\n"); 365 366 verifyFormat("getSomeLongPromise()\n" 367 " .then(function(value) { body(); })\n" 368 " .thenCatch(function(error) {\n" 369 " body();\n" 370 " body();\n" 371 " });"); 372 verifyFormat("getSomeLongPromise()\n" 373 " .then(function(value) {\n" 374 " body();\n" 375 " body();\n" 376 " })\n" 377 " .thenCatch(function(error) {\n" 378 " body();\n" 379 " body();\n" 380 " });"); 381 382 // FIXME: This is bad, but it used to be formatted correctly by accident. 383 verifyFormat("getSomeLongPromise().then(function(value) {\n" 384 " body();\n" 385 "}).thenCatch(function(error) { body(); });"); 386 } 387 388 TEST_F(FormatTestJS, ReturnStatements) { 389 verifyFormat("function() {\n" 390 " return [hello, world];\n" 391 "}"); 392 } 393 394 TEST_F(FormatTestJS, ClosureStyleComments) { 395 verifyFormat("var x = /** @type {foo} */ (bar);"); 396 } 397 398 TEST_F(FormatTestJS, TryCatch) { 399 verifyFormat("try {\n" 400 " f();\n" 401 "} catch (e) {\n" 402 " g();\n" 403 "} finally {\n" 404 " h();\n" 405 "}"); 406 407 // But, of course, "catch" is a perfectly fine function name in JavaScript. 408 verifyFormat("someObject.catch();"); 409 verifyFormat("someObject.new();"); 410 verifyFormat("someObject.delete();"); 411 } 412 413 TEST_F(FormatTestJS, StringLiteralConcatenation) { 414 verifyFormat("var literal = 'hello ' +\n" 415 " 'world';"); 416 } 417 418 TEST_F(FormatTestJS, RegexLiteralClassification) { 419 // Regex literals. 420 verifyFormat("var regex = /abc/;"); 421 verifyFormat("f(/abc/);"); 422 verifyFormat("f(abc, /abc/);"); 423 verifyFormat("some_map[/abc/];"); 424 verifyFormat("var x = a ? /abc/ : /abc/;"); 425 verifyFormat("for (var i = 0; /abc/.test(s[i]); i++) {\n}"); 426 verifyFormat("var x = !/abc/.test(y);"); 427 verifyFormat("var x = a && /abc/.test(y);"); 428 verifyFormat("var x = a || /abc/.test(y);"); 429 verifyFormat("var x = a + /abc/.search(y);"); 430 verifyFormat("var regexs = {/abc/, /abc/};"); 431 verifyFormat("return /abc/;"); 432 433 // Not regex literals. 434 verifyFormat("var a = a / 2 + b / 3;"); 435 } 436 437 TEST_F(FormatTestJS, RegexLiteralSpecialCharacters) { 438 verifyFormat("var regex = /a*/;"); 439 verifyFormat("var regex = /a+/;"); 440 verifyFormat("var regex = /a?/;"); 441 verifyFormat("var regex = /.a./;"); 442 verifyFormat("var regex = /a\\*/;"); 443 verifyFormat("var regex = /^a$/;"); 444 verifyFormat("var regex = /\\/a/;"); 445 verifyFormat("var regex = /(?:x)/;"); 446 verifyFormat("var regex = /x(?=y)/;"); 447 verifyFormat("var regex = /x(?!y)/;"); 448 verifyFormat("var regex = /x|y/;"); 449 verifyFormat("var regex = /a{2}/;"); 450 verifyFormat("var regex = /a{1,3}/;"); 451 verifyFormat("var regex = /[abc]/;"); 452 verifyFormat("var regex = /[^abc]/;"); 453 verifyFormat("var regex = /[\\b]/;"); 454 verifyFormat("var regex = /\\b/;"); 455 verifyFormat("var regex = /\\B/;"); 456 verifyFormat("var regex = /\\d/;"); 457 verifyFormat("var regex = /\\D/;"); 458 verifyFormat("var regex = /\\f/;"); 459 verifyFormat("var regex = /\\n/;"); 460 verifyFormat("var regex = /\\r/;"); 461 verifyFormat("var regex = /\\s/;"); 462 verifyFormat("var regex = /\\S/;"); 463 verifyFormat("var regex = /\\t/;"); 464 verifyFormat("var regex = /\\v/;"); 465 verifyFormat("var regex = /\\w/;"); 466 verifyFormat("var regex = /\\W/;"); 467 verifyFormat("var regex = /a(a)\\1/;"); 468 verifyFormat("var regex = /\\0/;"); 469 verifyFormat("var regex = /\\\\/g;"); 470 verifyFormat("var regex = /\\a\\\\/g;"); 471 verifyFormat("var regex = /\a\\//g;"); 472 verifyFormat("var regex = /a\\//;\n" 473 "var x = 0;"); 474 EXPECT_EQ("var regex = /\\/*/;\n" 475 "var x = 0;", 476 format("var regex = /\\/*/;\n" 477 "var x=0;")); 478 } 479 480 TEST_F(FormatTestJS, RegexLiteralModifiers) { 481 verifyFormat("var regex = /abc/g;"); 482 verifyFormat("var regex = /abc/i;"); 483 verifyFormat("var regex = /abc/m;"); 484 verifyFormat("var regex = /abc/y;"); 485 } 486 487 TEST_F(FormatTestJS, RegexLiteralLength) { 488 verifyFormat("var regex = /aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/;", 489 getGoogleJSStyleWithColumns(60)); 490 verifyFormat("var regex =\n" 491 " /aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/;", 492 getGoogleJSStyleWithColumns(60)); 493 verifyFormat("var regex = /\\xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/;", 494 getGoogleJSStyleWithColumns(50)); 495 } 496 497 TEST_F(FormatTestJS, RegexLiteralExamples) { 498 verifyFormat("var regex = search.match(/(?:\?|&)times=([^?&]+)/i);"); 499 } 500 501 TEST_F(FormatTestJS, TypeAnnotations) { 502 verifyFormat("var x: string;"); 503 verifyFormat("function x(): string {\n return 'x';\n}"); 504 verifyFormat("function x(y: string): string {\n return 'x';\n}"); 505 verifyFormat("for (var y: string in x) {\n x();\n}"); 506 verifyFormat("((a: string, b: number): string => a + b);"); 507 verifyFormat("var x: (y: number) => string;"); 508 verifyFormat("var x: P<string, (a: number) => string>;"); 509 } 510 511 TEST_F(FormatTestJS, ClassDeclarations) { 512 verifyFormat("class C {\n x: string = 12;\n}"); 513 verifyFormat("class C {\n x(): string => 12;\n}"); 514 verifyFormat("class C {\n ['x' + 2]: string = 12;\n}"); 515 verifyFormat("class C {\n private x: string = 12;\n}"); 516 verifyFormat("class C {\n private static x: string = 12;\n}"); 517 verifyFormat("class C {\n static x(): string { return 'asd'; }\n}"); 518 verifyFormat("class C extends P implements I {}"); 519 } 520 521 TEST_F(FormatTestJS, MetadataAnnotations) { 522 verifyFormat("@A\nclass C {\n}"); 523 verifyFormat("@A({arg: 'value'})\nclass C {\n}"); 524 verifyFormat("@A\n@B\nclass C {\n}"); 525 verifyFormat("class C {\n @A x: string;\n}"); 526 verifyFormat("class C {\n" 527 " @A\n" 528 " private x(): string {\n" 529 " return 'y';\n" 530 " }\n" 531 "}"); 532 verifyFormat("class X {}\n" 533 "class Y {}"); 534 } 535 536 TEST_F(FormatTestJS, Modules) { 537 verifyFormat("import SomeThing from 'some/module.js';"); 538 verifyFormat("import {X, Y} from 'some/module.js';"); 539 verifyFormat("import {\n" 540 " VeryLongImportsAreAnnoying,\n" 541 " VeryLongImportsAreAnnoying,\n" 542 " VeryLongImportsAreAnnoying,\n" 543 " VeryLongImportsAreAnnoying\n" 544 "} from 'some/module.js';"); 545 verifyFormat("import {\n" 546 " X,\n" 547 " Y,\n" 548 "} from 'some/module.js';"); 549 verifyFormat("import {\n" 550 " X,\n" 551 " Y,\n" 552 "} from 'some/long/module.js';", 553 getGoogleJSStyleWithColumns(20)); 554 verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';"); 555 verifyFormat("import * as lib from 'some/module.js';"); 556 verifyFormat("var x = {import: 1};\nx.import = 2;"); 557 558 verifyFormat("export function fn() {\n" 559 " return 'fn';\n" 560 "}"); 561 verifyFormat("export const x = 12;"); 562 verifyFormat("export default class X {}"); 563 verifyFormat("export {X, Y} from 'some/module.js';"); 564 verifyFormat("export {\n" 565 " X,\n" 566 " Y,\n" 567 "} from 'some/module.js';"); 568 verifyFormat("export class C {\n" 569 " x: number;\n" 570 " y: string;\n" 571 "}"); 572 verifyFormat("export class X { y: number; }"); 573 verifyFormat("export default class X { y: number }"); 574 verifyFormat("export default function() {\n return 1;\n}"); 575 verifyFormat("export var x = 12;"); 576 verifyFormat("export var x: number = 12;"); 577 verifyFormat("export const y = {\n" 578 " a: 1,\n" 579 " b: 2\n" 580 "};"); 581 } 582 583 TEST_F(FormatTestJS, TemplateStrings) { 584 // Keeps any whitespace/indentation within the template string. 585 EXPECT_EQ("var x = `hello\n" 586 " ${ name }\n" 587 " !`;", 588 format("var x = `hello\n" 589 " ${ name }\n" 590 " !`;")); 591 592 // FIXME: +1 / -1 offsets are to work around clang-format miscalculating 593 // widths for unknown tokens that are not whitespace (e.g. '`'). Remove when 594 // the code is corrected. 595 596 verifyFormat("var x =\n" 597 " `hello ${world}` >= some();", 598 getGoogleJSStyleWithColumns(34)); // Barely doesn't fit. 599 verifyFormat("var x = `hello ${world}` >= some();", 600 getGoogleJSStyleWithColumns(35 + 1)); // Barely fits. 601 EXPECT_EQ("var x = `hello\n" 602 " ${world}` >=\n" 603 " some();", 604 format("var x =\n" 605 " `hello\n" 606 " ${world}` >= some();", 607 getGoogleJSStyleWithColumns(21))); // Barely doesn't fit. 608 EXPECT_EQ("var x = `hello\n" 609 " ${world}` >= some();", 610 format("var x =\n" 611 " `hello\n" 612 " ${world}` >= some();", 613 getGoogleJSStyleWithColumns(22))); // Barely fits. 614 615 verifyFormat("var x =\n `h`;", getGoogleJSStyleWithColumns(13 - 1)); 616 EXPECT_EQ( 617 "var x =\n `multi\n line`;", 618 format("var x = `multi\n line`;", getGoogleJSStyleWithColumns(14 - 1))); 619 620 // Two template strings. 621 verifyFormat("var x = `hello` == `hello`;"); 622 } 623 624 TEST_F(FormatTestJS, CastSyntax) { 625 verifyFormat("var x = <type>foo;"); 626 } 627 628 TEST_F(FormatTestJS, TypeArguments) { 629 verifyFormat("class X<Y> {}"); 630 verifyFormat("new X<Y>();"); 631 verifyFormat("foo<Y>(a);"); 632 verifyFormat("var x: X<Y>[];"); 633 verifyFormat("class C extends D<E> implements F<G>, H<I> {}"); 634 } 635 636 } // end namespace tooling 637 } // end namespace clang 638