jsfmt.spec.js.snap 18 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409
  1. // Jest Snapshot v1, https://goo.gl/fbAQLP
  2. exports[`comments.js 1`] = `
  3. let error = new Error(response.statusText);
  4. // comment
  5. (error: any).response = response
  6. x;
  7. /* comment */ (error: any).response = response
  8. x;
  9. (error: any).response = response; /* comment */
  10. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. let error = new Error(response.statusText);
  12. // comment
  13. (error: any).response = response;
  14. x;
  15. /* comment */ (error: any).response = response;
  16. x;
  17. (error: any).response = response; /* comment */
  18. `;
  19. exports[`comments.js 2`] = `
  20. let error = new Error(response.statusText);
  21. // comment
  22. (error: any).response = response
  23. x;
  24. /* comment */ (error: any).response = response
  25. x;
  26. (error: any).response = response; /* comment */
  27. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. let error = new Error(response.statusText)
  29. // comment
  30. ;(error: any).response = response
  31. x
  32. /* comment */ ;(error: any).response = response
  33. x
  34. ;(error: any).response = response /* comment */
  35. `;
  36. exports[`comments.js 3`] = `
  37. let error = new Error(response.statusText);
  38. // comment
  39. (error: any).response = response
  40. x;
  41. /* comment */ (error: any).response = response
  42. x;
  43. (error: any).response = response; /* comment */
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. let error = new Error(response.statusText)
  46. // comment
  47. ;(error: any).response = response
  48. x
  49. /* comment */ ;(error: any).response = response
  50. x
  51. ;(error: any).response = response /* comment */
  52. `;
  53. exports[`flow-interfaces.js 1`] = `
  54. declare class A {
  55. one: boolean;
  56. two: { three: string }
  57. | number;
  58. }
  59. // NOTE: Flow and Babylon both fail to apply ASI here
  60. // declare class B {
  61. // one: boolean
  62. // two: { three: string }
  63. // | number
  64. // }
  65. declare interface C {
  66. one: boolean;
  67. two: { three: string }
  68. | number;
  69. }
  70. // NOTE: Flow and Babylon both fail to apply ASI here
  71. // declare interface D {
  72. // one: boolean
  73. // two: { three: string }
  74. // | number
  75. // }
  76. interface E {
  77. one: boolean;
  78. two: { three: string }
  79. | number;
  80. }
  81. // NOTE: Flow and Babylon both fail to apply ASI here
  82. // interface F {
  83. // one: boolean
  84. // two: { three: string }
  85. // | number
  86. // }
  87. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. declare class A {
  89. one: boolean;
  90. two: { three: string } | number;
  91. }
  92. // NOTE: Flow and Babylon both fail to apply ASI here
  93. // declare class B {
  94. // one: boolean
  95. // two: { three: string }
  96. // | number
  97. // }
  98. declare interface C {
  99. one: boolean;
  100. two: { three: string } | number;
  101. }
  102. // NOTE: Flow and Babylon both fail to apply ASI here
  103. // declare interface D {
  104. // one: boolean
  105. // two: { three: string }
  106. // | number
  107. // }
  108. interface E {
  109. one: boolean;
  110. two: { three: string } | number;
  111. }
  112. // NOTE: Flow and Babylon both fail to apply ASI here
  113. // interface F {
  114. // one: boolean
  115. // two: { three: string }
  116. // | number
  117. // }
  118. `;
  119. exports[`flow-interfaces.js 2`] = `
  120. declare class A {
  121. one: boolean;
  122. two: { three: string }
  123. | number;
  124. }
  125. // NOTE: Flow and Babylon both fail to apply ASI here
  126. // declare class B {
  127. // one: boolean
  128. // two: { three: string }
  129. // | number
  130. // }
  131. declare interface C {
  132. one: boolean;
  133. two: { three: string }
  134. | number;
  135. }
  136. // NOTE: Flow and Babylon both fail to apply ASI here
  137. // declare interface D {
  138. // one: boolean
  139. // two: { three: string }
  140. // | number
  141. // }
  142. interface E {
  143. one: boolean;
  144. two: { three: string }
  145. | number;
  146. }
  147. // NOTE: Flow and Babylon both fail to apply ASI here
  148. // interface F {
  149. // one: boolean
  150. // two: { three: string }
  151. // | number
  152. // }
  153. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  154. declare class A {
  155. one: boolean;
  156. two: { three: string } | number;
  157. }
  158. // NOTE: Flow and Babylon both fail to apply ASI here
  159. // declare class B {
  160. // one: boolean
  161. // two: { three: string }
  162. // | number
  163. // }
  164. declare interface C {
  165. one: boolean;
  166. two: { three: string } | number;
  167. }
  168. // NOTE: Flow and Babylon both fail to apply ASI here
  169. // declare interface D {
  170. // one: boolean
  171. // two: { three: string }
  172. // | number
  173. // }
  174. interface E {
  175. one: boolean;
  176. two: { three: string } | number;
  177. }
  178. // NOTE: Flow and Babylon both fail to apply ASI here
  179. // interface F {
  180. // one: boolean
  181. // two: { three: string }
  182. // | number
  183. // }
  184. `;
  185. exports[`flow-interfaces.js 3`] = `
  186. declare class A {
  187. one: boolean;
  188. two: { three: string }
  189. | number;
  190. }
  191. // NOTE: Flow and Babylon both fail to apply ASI here
  192. // declare class B {
  193. // one: boolean
  194. // two: { three: string }
  195. // | number
  196. // }
  197. declare interface C {
  198. one: boolean;
  199. two: { three: string }
  200. | number;
  201. }
  202. // NOTE: Flow and Babylon both fail to apply ASI here
  203. // declare interface D {
  204. // one: boolean
  205. // two: { three: string }
  206. // | number
  207. // }
  208. interface E {
  209. one: boolean;
  210. two: { three: string }
  211. | number;
  212. }
  213. // NOTE: Flow and Babylon both fail to apply ASI here
  214. // interface F {
  215. // one: boolean
  216. // two: { three: string }
  217. // | number
  218. // }
  219. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  220. declare class A {
  221. one: boolean;
  222. two: { three: string } | number;
  223. }
  224. // NOTE: Flow and Babylon both fail to apply ASI here
  225. // declare class B {
  226. // one: boolean
  227. // two: { three: string }
  228. // | number
  229. // }
  230. declare interface C {
  231. one: boolean;
  232. two: { three: string } | number;
  233. }
  234. // NOTE: Flow and Babylon both fail to apply ASI here
  235. // declare interface D {
  236. // one: boolean
  237. // two: { three: string }
  238. // | number
  239. // }
  240. interface E {
  241. one: boolean;
  242. two: { three: string } | number;
  243. }
  244. // NOTE: Flow and Babylon both fail to apply ASI here
  245. // interface F {
  246. // one: boolean
  247. // two: { three: string }
  248. // | number
  249. // }
  250. `;
  251. exports[`issue2006.js 1`] = `
  252. switch (n) {
  253. case 11:
  254. var c = a.e;
  255. (i.a += Ga(c.e)), F(i, c.i, 0);
  256. }
  257. var c = a.e;
  258. (i.a += Ga(c.e)), F(i, c.i, 0);
  259. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  260. switch (n) {
  261. case 11:
  262. var c = a.e;
  263. (i.a += Ga(c.e)), F(i, c.i, 0);
  264. }
  265. var c = a.e;
  266. (i.a += Ga(c.e)), F(i, c.i, 0);
  267. `;
  268. exports[`issue2006.js 2`] = `
  269. switch (n) {
  270. case 11:
  271. var c = a.e;
  272. (i.a += Ga(c.e)), F(i, c.i, 0);
  273. }
  274. var c = a.e;
  275. (i.a += Ga(c.e)), F(i, c.i, 0);
  276. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  277. switch (n) {
  278. case 11:
  279. var c = a.e
  280. ;(i.a += Ga(c.e)), F(i, c.i, 0)
  281. }
  282. var c = a.e
  283. ;(i.a += Ga(c.e)), F(i, c.i, 0)
  284. `;
  285. exports[`issue2006.js 3`] = `
  286. switch (n) {
  287. case 11:
  288. var c = a.e;
  289. (i.a += Ga(c.e)), F(i, c.i, 0);
  290. }
  291. var c = a.e;
  292. (i.a += Ga(c.e)), F(i, c.i, 0);
  293. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  294. switch (n) {
  295. case 11:
  296. var c = a.e
  297. ;(i.a += Ga(c.e)), F(i, c.i, 0)
  298. }
  299. var c = a.e
  300. ;(i.a += Ga(c.e)), F(i, c.i, 0)
  301. `;
  302. exports[`no-semi.js 1`] = `
  303. // with preexisting semi
  304. x; [1, 2, 3].forEach(fn)
  305. x; [a, b, ...c] = [1, 2]
  306. x; /r/i.test('r')
  307. x; +1
  308. x; - 1
  309. x; ('h' + 'i').repeat(10)
  310. x; (1, 2)
  311. x; (() => {})()
  312. x; ({ a: 1 }).entries()
  313. x; ({ a: 1 }).entries()
  314. x; <Hello />
  315. x; \`string\`
  316. x; (x, y) => x
  317. // doesn't have to be preceded by a semicolon
  318. class X {} [1, 2, 3].forEach(fn)
  319. // TODO: upgrade parser
  320. // class A {
  321. // async; // The semicolon is *not* necessary
  322. // x(){}
  323. // }
  324. // class B {
  325. // static; // The semicolon *is* necessary
  326. // x(){}
  327. // }
  328. class C {
  329. get; // The semicolon *is* necessary
  330. x(){}
  331. }
  332. class C {
  333. get = () => {}; // The semicolon is *not* necessary
  334. x(){}
  335. }
  336. class C {
  337. set; // The semicolon *is* necessary
  338. x(){}
  339. }
  340. class C {
  341. set = () => {}; // The semicolon is *not* necessary
  342. x(){}
  343. }
  344. // don't semicolon if it doesn't start statement
  345. if (true) (() => {})()
  346. class A {
  347. a = 0;
  348. [b](){}
  349. c = 0;
  350. *d(){}
  351. e = 0;
  352. [f] = 0
  353. // none of the semicolons above this comment can be omitted.
  354. // none of the semicolons below this comment are necessary.
  355. q() {};
  356. [h](){}
  357. p() {};
  358. *i(){}
  359. a = 1;
  360. get ['y']() {}
  361. a = 1;
  362. static ['y']() {}
  363. a = 1;
  364. set ['z'](z) {}
  365. a = 1;
  366. async ['a']() {}
  367. a = 1;
  368. async *g() {}
  369. a = 0;
  370. b = 1;
  371. }
  372. // being first/last shouldn't break things
  373. class G {
  374. x = 1
  375. }
  376. class G {
  377. x() {}
  378. }
  379. class G {
  380. *x() {}
  381. }
  382. class G {
  383. [x] = 1
  384. }
  385. // check indentation
  386. if (true) {
  387. x; (() => {})()
  388. }
  389. // flow
  390. (x: void);
  391. (y: void)
  392. // check statement clauses
  393. do break; while (false)
  394. if (true) do break; while (false)
  395. if (true) 1; else 2
  396. for (;;) ;
  397. for (x of y) ;
  398. debugger
  399. // check that it doesn't break non-ASI
  400. 1
  401. - 1
  402. 1
  403. + 1
  404. 1
  405. / 1
  406. arr
  407. [0]
  408. fn
  409. (x)
  410. !1
  411. 1
  412. < 1
  413. tag
  414. \`string\`
  415. x; x => x
  416. x; (a || b).c++
  417. x; ++(a || b).c
  418. while (false)
  419. (function(){}())
  420. aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
  421. (b + c)
  422. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  423. // with preexisting semi
  424. x;
  425. [1, 2, 3].forEach(fn);
  426. x;
  427. [a, b, ...c] = [1, 2];
  428. x;
  429. /r/i.test("r");
  430. x;
  431. +1;
  432. x;
  433. -1;
  434. x;
  435. ("h" + "i").repeat(10);
  436. x;
  437. 1, 2;
  438. x;
  439. (() => {})();
  440. x;
  441. ({ a: 1 }.entries());
  442. x;
  443. ({ a: 1 }.entries());
  444. x;
  445. <Hello />;
  446. x;
  447. \`string\`;
  448. x;
  449. (x, y) => x;
  450. // doesn't have to be preceded by a semicolon
  451. class X {}
  452. [1, 2, 3].forEach(fn);
  453. // TODO: upgrade parser
  454. // class A {
  455. // async; // The semicolon is *not* necessary
  456. // x(){}
  457. // }
  458. // class B {
  459. // static; // The semicolon *is* necessary
  460. // x(){}
  461. // }
  462. class C {
  463. get; // The semicolon *is* necessary
  464. x() {}
  465. }
  466. class C {
  467. get = () => {}; // The semicolon is *not* necessary
  468. x() {}
  469. }
  470. class C {
  471. set; // The semicolon *is* necessary
  472. x() {}
  473. }
  474. class C {
  475. set = () => {}; // The semicolon is *not* necessary
  476. x() {}
  477. }
  478. // don't semicolon if it doesn't start statement
  479. if (true) (() => {})();
  480. class A {
  481. a = 0;
  482. [b]() {}
  483. c = 0;
  484. *d() {}
  485. e = 0;
  486. [f] = 0;
  487. // none of the semicolons above this comment can be omitted.
  488. // none of the semicolons below this comment are necessary.
  489. q() {}
  490. [h]() {}
  491. p() {}
  492. *i() {}
  493. a = 1;
  494. get ["y"]() {}
  495. a = 1;
  496. static ["y"]() {}
  497. a = 1;
  498. set ["z"](z) {}
  499. a = 1;
  500. async ["a"]() {}
  501. a = 1;
  502. async *g() {}
  503. a = 0;
  504. b = 1;
  505. }
  506. // being first/last shouldn't break things
  507. class G {
  508. x = 1;
  509. }
  510. class G {
  511. x() {}
  512. }
  513. class G {
  514. *x() {}
  515. }
  516. class G {
  517. [x] = 1;
  518. }
  519. // check indentation
  520. if (true) {
  521. x;
  522. (() => {})();
  523. }
  524. // flow
  525. (x: void);
  526. (y: void);
  527. // check statement clauses
  528. do break;
  529. while (false);
  530. if (true)
  531. do break;
  532. while (false);
  533. if (true) 1;
  534. else 2;
  535. for (;;);
  536. for (x of y);
  537. debugger;
  538. // check that it doesn't break non-ASI
  539. 1 - 1;
  540. 1 + 1;
  541. 1 / 1;
  542. arr[0];
  543. fn(x);
  544. !1;
  545. 1 < 1;
  546. tag\`string\`;
  547. x;
  548. x => x;
  549. x;
  550. (a || b).c++;
  551. x;
  552. ++(a || b).c;
  553. while (false) (function() {})();
  554. aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
  555. (b + c);
  556. `;
  557. exports[`no-semi.js 2`] = `
  558. // with preexisting semi
  559. x; [1, 2, 3].forEach(fn)
  560. x; [a, b, ...c] = [1, 2]
  561. x; /r/i.test('r')
  562. x; +1
  563. x; - 1
  564. x; ('h' + 'i').repeat(10)
  565. x; (1, 2)
  566. x; (() => {})()
  567. x; ({ a: 1 }).entries()
  568. x; ({ a: 1 }).entries()
  569. x; <Hello />
  570. x; \`string\`
  571. x; (x, y) => x
  572. // doesn't have to be preceded by a semicolon
  573. class X {} [1, 2, 3].forEach(fn)
  574. // TODO: upgrade parser
  575. // class A {
  576. // async; // The semicolon is *not* necessary
  577. // x(){}
  578. // }
  579. // class B {
  580. // static; // The semicolon *is* necessary
  581. // x(){}
  582. // }
  583. class C {
  584. get; // The semicolon *is* necessary
  585. x(){}
  586. }
  587. class C {
  588. get = () => {}; // The semicolon is *not* necessary
  589. x(){}
  590. }
  591. class C {
  592. set; // The semicolon *is* necessary
  593. x(){}
  594. }
  595. class C {
  596. set = () => {}; // The semicolon is *not* necessary
  597. x(){}
  598. }
  599. // don't semicolon if it doesn't start statement
  600. if (true) (() => {})()
  601. class A {
  602. a = 0;
  603. [b](){}
  604. c = 0;
  605. *d(){}
  606. e = 0;
  607. [f] = 0
  608. // none of the semicolons above this comment can be omitted.
  609. // none of the semicolons below this comment are necessary.
  610. q() {};
  611. [h](){}
  612. p() {};
  613. *i(){}
  614. a = 1;
  615. get ['y']() {}
  616. a = 1;
  617. static ['y']() {}
  618. a = 1;
  619. set ['z'](z) {}
  620. a = 1;
  621. async ['a']() {}
  622. a = 1;
  623. async *g() {}
  624. a = 0;
  625. b = 1;
  626. }
  627. // being first/last shouldn't break things
  628. class G {
  629. x = 1
  630. }
  631. class G {
  632. x() {}
  633. }
  634. class G {
  635. *x() {}
  636. }
  637. class G {
  638. [x] = 1
  639. }
  640. // check indentation
  641. if (true) {
  642. x; (() => {})()
  643. }
  644. // flow
  645. (x: void);
  646. (y: void)
  647. // check statement clauses
  648. do break; while (false)
  649. if (true) do break; while (false)
  650. if (true) 1; else 2
  651. for (;;) ;
  652. for (x of y) ;
  653. debugger
  654. // check that it doesn't break non-ASI
  655. 1
  656. - 1
  657. 1
  658. + 1
  659. 1
  660. / 1
  661. arr
  662. [0]
  663. fn
  664. (x)
  665. !1
  666. 1
  667. < 1
  668. tag
  669. \`string\`
  670. x; x => x
  671. x; (a || b).c++
  672. x; ++(a || b).c
  673. while (false)
  674. (function(){}())
  675. aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
  676. (b + c)
  677. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  678. // with preexisting semi
  679. x
  680. ;[1, 2, 3].forEach(fn)
  681. x
  682. ;[a, b, ...c] = [1, 2]
  683. x
  684. ;/r/i.test("r")
  685. x
  686. ;+1
  687. x
  688. ;-1
  689. x
  690. ;("h" + "i").repeat(10)
  691. x
  692. 1, 2
  693. x
  694. ;(() => {})()
  695. x
  696. ;({ a: 1 }.entries())
  697. x
  698. ;({ a: 1 }.entries())
  699. x
  700. ;<Hello />
  701. x
  702. ;\`string\`
  703. x
  704. ;(x, y) => x
  705. // doesn't have to be preceded by a semicolon
  706. class X {}
  707. ;[1, 2, 3].forEach(fn)
  708. // TODO: upgrade parser
  709. // class A {
  710. // async; // The semicolon is *not* necessary
  711. // x(){}
  712. // }
  713. // class B {
  714. // static; // The semicolon *is* necessary
  715. // x(){}
  716. // }
  717. class C {
  718. get; // The semicolon *is* necessary
  719. x() {}
  720. }
  721. class C {
  722. get = () => {} // The semicolon is *not* necessary
  723. x() {}
  724. }
  725. class C {
  726. set; // The semicolon *is* necessary
  727. x() {}
  728. }
  729. class C {
  730. set = () => {} // The semicolon is *not* necessary
  731. x() {}
  732. }
  733. // don't semicolon if it doesn't start statement
  734. if (true) (() => {})()
  735. class A {
  736. a = 0;
  737. [b]() {}
  738. c = 0;
  739. *d() {}
  740. e = 0;
  741. [f] = 0
  742. // none of the semicolons above this comment can be omitted.
  743. // none of the semicolons below this comment are necessary.
  744. q() {}
  745. [h]() {}
  746. p() {}
  747. *i() {}
  748. a = 1
  749. get ["y"]() {}
  750. a = 1
  751. static ["y"]() {}
  752. a = 1
  753. set ["z"](z) {}
  754. a = 1
  755. async ["a"]() {}
  756. a = 1
  757. async *g() {}
  758. a = 0
  759. b = 1
  760. }
  761. // being first/last shouldn't break things
  762. class G {
  763. x = 1
  764. }
  765. class G {
  766. x() {}
  767. }
  768. class G {
  769. *x() {}
  770. }
  771. class G {
  772. [x] = 1
  773. }
  774. // check indentation
  775. if (true) {
  776. x
  777. ;(() => {})()
  778. }
  779. // flow
  780. ;(x: void)
  781. ;(y: void)
  782. // check statement clauses
  783. do break
  784. while (false)
  785. if (true)
  786. do break
  787. while (false)
  788. if (true) 1
  789. else 2
  790. for (;;);
  791. for (x of y);
  792. debugger
  793. // check that it doesn't break non-ASI
  794. 1 - 1
  795. 1 + 1
  796. 1 / 1
  797. arr[0]
  798. fn(x)
  799. !1
  800. 1 < 1
  801. tag\`string\`
  802. x
  803. x => x
  804. x
  805. ;(a || b).c++
  806. x
  807. ++(a || b).c
  808. while (false) (function() {})()
  809. aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
  810. (b + c)
  811. `;
  812. exports[`no-semi.js 3`] = `
  813. // with preexisting semi
  814. x; [1, 2, 3].forEach(fn)
  815. x; [a, b, ...c] = [1, 2]
  816. x; /r/i.test('r')
  817. x; +1
  818. x; - 1
  819. x; ('h' + 'i').repeat(10)
  820. x; (1, 2)
  821. x; (() => {})()
  822. x; ({ a: 1 }).entries()
  823. x; ({ a: 1 }).entries()
  824. x; <Hello />
  825. x; \`string\`
  826. x; (x, y) => x
  827. // doesn't have to be preceded by a semicolon
  828. class X {} [1, 2, 3].forEach(fn)
  829. // TODO: upgrade parser
  830. // class A {
  831. // async; // The semicolon is *not* necessary
  832. // x(){}
  833. // }
  834. // class B {
  835. // static; // The semicolon *is* necessary
  836. // x(){}
  837. // }
  838. class C {
  839. get; // The semicolon *is* necessary
  840. x(){}
  841. }
  842. class C {
  843. get = () => {}; // The semicolon is *not* necessary
  844. x(){}
  845. }
  846. class C {
  847. set; // The semicolon *is* necessary
  848. x(){}
  849. }
  850. class C {
  851. set = () => {}; // The semicolon is *not* necessary
  852. x(){}
  853. }
  854. // don't semicolon if it doesn't start statement
  855. if (true) (() => {})()
  856. class A {
  857. a = 0;
  858. [b](){}
  859. c = 0;
  860. *d(){}
  861. e = 0;
  862. [f] = 0
  863. // none of the semicolons above this comment can be omitted.
  864. // none of the semicolons below this comment are necessary.
  865. q() {};
  866. [h](){}
  867. p() {};
  868. *i(){}
  869. a = 1;
  870. get ['y']() {}
  871. a = 1;
  872. static ['y']() {}
  873. a = 1;
  874. set ['z'](z) {}
  875. a = 1;
  876. async ['a']() {}
  877. a = 1;
  878. async *g() {}
  879. a = 0;
  880. b = 1;
  881. }
  882. // being first/last shouldn't break things
  883. class G {
  884. x = 1
  885. }
  886. class G {
  887. x() {}
  888. }
  889. class G {
  890. *x() {}
  891. }
  892. class G {
  893. [x] = 1
  894. }
  895. // check indentation
  896. if (true) {
  897. x; (() => {})()
  898. }
  899. // flow
  900. (x: void);
  901. (y: void)
  902. // check statement clauses
  903. do break; while (false)
  904. if (true) do break; while (false)
  905. if (true) 1; else 2
  906. for (;;) ;
  907. for (x of y) ;
  908. debugger
  909. // check that it doesn't break non-ASI
  910. 1
  911. - 1
  912. 1
  913. + 1
  914. 1
  915. / 1
  916. arr
  917. [0]
  918. fn
  919. (x)
  920. !1
  921. 1
  922. < 1
  923. tag
  924. \`string\`
  925. x; x => x
  926. x; (a || b).c++
  927. x; ++(a || b).c
  928. while (false)
  929. (function(){}())
  930. aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
  931. (b + c)
  932. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  933. // with preexisting semi
  934. x
  935. ;[1, 2, 3].forEach(fn)
  936. x
  937. ;[a, b, ...c] = [1, 2]
  938. x
  939. ;/r/i.test("r")
  940. x
  941. ;+1
  942. x
  943. ;-1
  944. x
  945. ;("h" + "i").repeat(10)
  946. x
  947. 1, 2
  948. x
  949. ;(() => {})()
  950. x
  951. ;({ a: 1 }.entries())
  952. x
  953. ;({ a: 1 }.entries())
  954. x
  955. ;<Hello />
  956. x
  957. ;\`string\`
  958. x
  959. ;(x, y) => x
  960. // doesn't have to be preceded by a semicolon
  961. class X {}
  962. ;[1, 2, 3].forEach(fn)
  963. // TODO: upgrade parser
  964. // class A {
  965. // async; // The semicolon is *not* necessary
  966. // x(){}
  967. // }
  968. // class B {
  969. // static; // The semicolon *is* necessary
  970. // x(){}
  971. // }
  972. class C {
  973. get; // The semicolon *is* necessary
  974. x() {}
  975. }
  976. class C {
  977. get = () => {} // The semicolon is *not* necessary
  978. x() {}
  979. }
  980. class C {
  981. set; // The semicolon *is* necessary
  982. x() {}
  983. }
  984. class C {
  985. set = () => {} // The semicolon is *not* necessary
  986. x() {}
  987. }
  988. // don't semicolon if it doesn't start statement
  989. if (true) (() => {})()
  990. class A {
  991. a = 0;
  992. [b]() {}
  993. c = 0;
  994. *d() {}
  995. e = 0;
  996. [f] = 0
  997. // none of the semicolons above this comment can be omitted.
  998. // none of the semicolons below this comment are necessary.
  999. q() {}
  1000. [h]() {}
  1001. p() {}
  1002. *i() {}
  1003. a = 1
  1004. get ["y"]() {}
  1005. a = 1
  1006. static ["y"]() {}
  1007. a = 1
  1008. set ["z"](z) {}
  1009. a = 1
  1010. async ["a"]() {}
  1011. a = 1
  1012. async *g() {}
  1013. a = 0
  1014. b = 1
  1015. }
  1016. // being first/last shouldn't break things
  1017. class G {
  1018. x = 1
  1019. }
  1020. class G {
  1021. x() {}
  1022. }
  1023. class G {
  1024. *x() {}
  1025. }
  1026. class G {
  1027. [x] = 1
  1028. }
  1029. // check indentation
  1030. if (true) {
  1031. x
  1032. ;(() => {})()
  1033. }
  1034. // flow
  1035. ;(x: void)
  1036. ;(y: void)
  1037. // check statement clauses
  1038. do break
  1039. while (false)
  1040. if (true)
  1041. do break
  1042. while (false)
  1043. if (true) 1
  1044. else 2
  1045. for (;;);
  1046. for (x of y);
  1047. debugger
  1048. // check that it doesn't break non-ASI
  1049. 1 - 1
  1050. 1 + 1
  1051. 1 / 1
  1052. arr[0]
  1053. fn(x)
  1054. !1
  1055. 1 < 1
  1056. tag\`string\`
  1057. x
  1058. x => x
  1059. x
  1060. ;(a || b).c++
  1061. x
  1062. ++(a || b).c
  1063. while (false) (function() {})()
  1064. aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
  1065. (b + c)
  1066. `;