/test/acorn/tests.js

https://bitbucket.org/cbruno/acorn-objj · JavaScript · 29128 lines · 28525 code · 581 blank · 22 comment · 6 complexity · e3a05b350c184c2285285d00b6c10b79 MD5 · raw file

Large files are truncated click here to view the full file

  1. // Tests largely based on those of Esprima
  2. // (http://esprima.org/test/)
  3. if (typeof exports != "undefined") {
  4. var driver = require("./driver.js");
  5. var test = driver.test, testFail = driver.testFail, testAssert = driver.testAssert, misMatch = driver.misMatch;
  6. var acorn = require("acorn");
  7. }
  8. test("this\n", {
  9. type: "Program",
  10. body: [
  11. {
  12. type: "ExpressionStatement",
  13. expression: {
  14. type: "ThisExpression",
  15. loc: {
  16. start: {
  17. line: 1,
  18. column: 0
  19. },
  20. end: {
  21. line: 1,
  22. column: 4
  23. }
  24. }
  25. },
  26. loc: {
  27. start: {
  28. line: 1,
  29. column: 0
  30. },
  31. end: {
  32. line: 1,
  33. column: 4
  34. }
  35. }
  36. }
  37. ],
  38. loc: {
  39. start: {
  40. line: 1,
  41. column: 0
  42. },
  43. end: {
  44. line: 2,
  45. column: 0
  46. }
  47. }
  48. });
  49. test("null\n", {
  50. type: "Program",
  51. body: [
  52. {
  53. type: "ExpressionStatement",
  54. expression: {
  55. type: "Literal",
  56. value: null,
  57. loc: {
  58. start: {
  59. line: 1,
  60. column: 0
  61. },
  62. end: {
  63. line: 1,
  64. column: 4
  65. }
  66. }
  67. },
  68. loc: {
  69. start: {
  70. line: 1,
  71. column: 0
  72. },
  73. end: {
  74. line: 1,
  75. column: 4
  76. }
  77. }
  78. }
  79. ],
  80. loc: {
  81. start: {
  82. line: 1,
  83. column: 0
  84. },
  85. end: {
  86. line: 2,
  87. column: 0
  88. }
  89. }
  90. });
  91. test("\n 42\n\n", {
  92. type: "Program",
  93. body: [
  94. {
  95. type: "ExpressionStatement",
  96. expression: {
  97. type: "Literal",
  98. value: 42,
  99. loc: {
  100. start: {
  101. line: 2,
  102. column: 4
  103. },
  104. end: {
  105. line: 2,
  106. column: 6
  107. }
  108. }
  109. },
  110. loc: {
  111. start: {
  112. line: 2,
  113. column: 4
  114. },
  115. end: {
  116. line: 2,
  117. column: 6
  118. }
  119. }
  120. }
  121. ],
  122. loc: {
  123. start: {
  124. line: 1,
  125. column: 0
  126. },
  127. end: {
  128. line: 4,
  129. column: 0
  130. }
  131. }
  132. });
  133. test("/foobar/", {
  134. type: "Program",
  135. body: [
  136. {
  137. type: "ExpressionStatement",
  138. expression: {
  139. type: "Literal",
  140. value: /foobar/,
  141. regex: {
  142. pattern: "foobar",
  143. flags: ""
  144. },
  145. loc: {
  146. start: {
  147. line: 1,
  148. column: 0
  149. },
  150. end: {
  151. line: 1,
  152. column: 8
  153. }
  154. }
  155. }
  156. }
  157. ]
  158. });
  159. test("/[a-z]/g", {
  160. type: "Program",
  161. body: [
  162. {
  163. type: "ExpressionStatement",
  164. expression: {
  165. type: "Literal",
  166. value: /[a-z]/g,
  167. regex: {
  168. pattern: "[a-z]",
  169. flags: "g"
  170. },
  171. loc: {
  172. start: {
  173. line: 1,
  174. column: 0
  175. },
  176. end: {
  177. line: 1,
  178. column: 8
  179. }
  180. }
  181. }
  182. }
  183. ]
  184. });
  185. test("(1 + 2 ) * 3", {
  186. type: "Program",
  187. body: [
  188. {
  189. type: "ExpressionStatement",
  190. expression: {
  191. type: "BinaryExpression",
  192. left: {
  193. type: "BinaryExpression",
  194. left: {
  195. type: "Literal",
  196. value: 1,
  197. loc: {
  198. start: {
  199. line: 1,
  200. column: 1
  201. },
  202. end: {
  203. line: 1,
  204. column: 2
  205. }
  206. }
  207. },
  208. operator: "+",
  209. right: {
  210. type: "Literal",
  211. value: 2,
  212. loc: {
  213. start: {
  214. line: 1,
  215. column: 5
  216. },
  217. end: {
  218. line: 1,
  219. column: 6
  220. }
  221. }
  222. },
  223. loc: {
  224. start: {
  225. line: 1,
  226. column: 1
  227. },
  228. end: {
  229. line: 1,
  230. column: 6
  231. }
  232. }
  233. },
  234. operator: "*",
  235. right: {
  236. type: "Literal",
  237. value: 3,
  238. loc: {
  239. start: {
  240. line: 1,
  241. column: 11
  242. },
  243. end: {
  244. line: 1,
  245. column: 12
  246. }
  247. }
  248. },
  249. loc: {
  250. start: {
  251. line: 1,
  252. column: 0
  253. },
  254. end: {
  255. line: 1,
  256. column: 12
  257. }
  258. }
  259. },
  260. loc: {
  261. start: {
  262. line: 1,
  263. column: 0
  264. },
  265. end: {
  266. line: 1,
  267. column: 12
  268. }
  269. }
  270. }
  271. ],
  272. loc: {
  273. start: {
  274. line: 1,
  275. column: 0
  276. },
  277. end: {
  278. line: 1,
  279. column: 12
  280. }
  281. }
  282. });
  283. test("(1 + 2 ) * 3", {
  284. type: "Program",
  285. body: [
  286. {
  287. type: "ExpressionStatement",
  288. expression: {
  289. type: "BinaryExpression",
  290. left: {
  291. type: "ParenthesizedExpression",
  292. expression: {
  293. type: "BinaryExpression",
  294. left: {
  295. type: "Literal",
  296. value: 1,
  297. loc: {
  298. start: {
  299. line: 1,
  300. column: 1
  301. },
  302. end: {
  303. line: 1,
  304. column: 2
  305. }
  306. }
  307. },
  308. operator: "+",
  309. right: {
  310. type: "Literal",
  311. value: 2,
  312. loc: {
  313. start: {
  314. line: 1,
  315. column: 5
  316. },
  317. end: {
  318. line: 1,
  319. column: 6
  320. }
  321. }
  322. },
  323. loc: {
  324. start: {
  325. line: 1,
  326. column: 1
  327. },
  328. end: {
  329. line: 1,
  330. column: 6
  331. }
  332. }
  333. },
  334. loc: {
  335. start: {
  336. line: 1,
  337. column: 0
  338. },
  339. end: {
  340. line: 1,
  341. column: 8
  342. }
  343. }
  344. },
  345. operator: "*",
  346. right: {
  347. type: "Literal",
  348. value: 3,
  349. loc: {
  350. start: {
  351. line: 1,
  352. column: 11
  353. },
  354. end: {
  355. line: 1,
  356. column: 12
  357. }
  358. }
  359. },
  360. loc: {
  361. start: {
  362. line: 1,
  363. column: 0
  364. },
  365. end: {
  366. line: 1,
  367. column: 12
  368. }
  369. }
  370. },
  371. loc: {
  372. start: {
  373. line: 1,
  374. column: 0
  375. },
  376. end: {
  377. line: 1,
  378. column: 12
  379. }
  380. }
  381. }
  382. ],
  383. loc: {
  384. start: {
  385. line: 1,
  386. column: 0
  387. },
  388. end: {
  389. line: 1,
  390. column: 12
  391. }
  392. }
  393. }, {
  394. locations: true,
  395. preserveParens: true
  396. });
  397. test("(x) = 23", {
  398. body: [
  399. {
  400. expression: {
  401. operator: "=",
  402. left: {
  403. expression: {
  404. name: "x",
  405. type: "Identifier",
  406. },
  407. type: "ParenthesizedExpression",
  408. },
  409. right: {
  410. value: 23,
  411. raw: "23",
  412. type: "Literal",
  413. },
  414. type: "AssignmentExpression",
  415. },
  416. type: "ExpressionStatement",
  417. }
  418. ],
  419. type: "Program",
  420. }, {preserveParens: true});
  421. test("x = []", {
  422. type: "Program",
  423. body: [
  424. {
  425. type: "ExpressionStatement",
  426. expression: {
  427. type: "AssignmentExpression",
  428. operator: "=",
  429. left: {
  430. type: "Identifier",
  431. name: "x",
  432. loc: {
  433. start: {
  434. line: 1,
  435. column: 0
  436. },
  437. end: {
  438. line: 1,
  439. column: 1
  440. }
  441. }
  442. },
  443. right: {
  444. type: "ArrayExpression",
  445. elements: [],
  446. loc: {
  447. start: {
  448. line: 1,
  449. column: 4
  450. },
  451. end: {
  452. line: 1,
  453. column: 6
  454. }
  455. }
  456. },
  457. loc: {
  458. start: {
  459. line: 1,
  460. column: 0
  461. },
  462. end: {
  463. line: 1,
  464. column: 6
  465. }
  466. }
  467. },
  468. loc: {
  469. start: {
  470. line: 1,
  471. column: 0
  472. },
  473. end: {
  474. line: 1,
  475. column: 6
  476. }
  477. }
  478. }
  479. ],
  480. loc: {
  481. start: {
  482. line: 1,
  483. column: 0
  484. },
  485. end: {
  486. line: 1,
  487. column: 6
  488. }
  489. }
  490. });
  491. test("x = [ ]", {
  492. type: "Program",
  493. body: [
  494. {
  495. type: "ExpressionStatement",
  496. expression: {
  497. type: "AssignmentExpression",
  498. operator: "=",
  499. left: {
  500. type: "Identifier",
  501. name: "x",
  502. loc: {
  503. start: {
  504. line: 1,
  505. column: 0
  506. },
  507. end: {
  508. line: 1,
  509. column: 1
  510. }
  511. }
  512. },
  513. right: {
  514. type: "ArrayExpression",
  515. elements: [],
  516. loc: {
  517. start: {
  518. line: 1,
  519. column: 4
  520. },
  521. end: {
  522. line: 1,
  523. column: 7
  524. }
  525. }
  526. },
  527. loc: {
  528. start: {
  529. line: 1,
  530. column: 0
  531. },
  532. end: {
  533. line: 1,
  534. column: 7
  535. }
  536. }
  537. },
  538. loc: {
  539. start: {
  540. line: 1,
  541. column: 0
  542. },
  543. end: {
  544. line: 1,
  545. column: 7
  546. }
  547. }
  548. }
  549. ],
  550. loc: {
  551. start: {
  552. line: 1,
  553. column: 0
  554. },
  555. end: {
  556. line: 1,
  557. column: 7
  558. }
  559. }
  560. });
  561. test("x = [ 42 ]", {
  562. type: "Program",
  563. body: [
  564. {
  565. type: "ExpressionStatement",
  566. expression: {
  567. type: "AssignmentExpression",
  568. operator: "=",
  569. left: {
  570. type: "Identifier",
  571. name: "x",
  572. loc: {
  573. start: {
  574. line: 1,
  575. column: 0
  576. },
  577. end: {
  578. line: 1,
  579. column: 1
  580. }
  581. }
  582. },
  583. right: {
  584. type: "ArrayExpression",
  585. elements: [
  586. {
  587. type: "Literal",
  588. value: 42,
  589. loc: {
  590. start: {
  591. line: 1,
  592. column: 6
  593. },
  594. end: {
  595. line: 1,
  596. column: 8
  597. }
  598. }
  599. }
  600. ],
  601. loc: {
  602. start: {
  603. line: 1,
  604. column: 4
  605. },
  606. end: {
  607. line: 1,
  608. column: 10
  609. }
  610. }
  611. },
  612. loc: {
  613. start: {
  614. line: 1,
  615. column: 0
  616. },
  617. end: {
  618. line: 1,
  619. column: 10
  620. }
  621. }
  622. },
  623. loc: {
  624. start: {
  625. line: 1,
  626. column: 0
  627. },
  628. end: {
  629. line: 1,
  630. column: 10
  631. }
  632. }
  633. }
  634. ],
  635. loc: {
  636. start: {
  637. line: 1,
  638. column: 0
  639. },
  640. end: {
  641. line: 1,
  642. column: 10
  643. }
  644. }
  645. });
  646. test("x = [ 42, ]", {
  647. type: "Program",
  648. body: [
  649. {
  650. type: "ExpressionStatement",
  651. expression: {
  652. type: "AssignmentExpression",
  653. operator: "=",
  654. left: {
  655. type: "Identifier",
  656. name: "x",
  657. loc: {
  658. start: {
  659. line: 1,
  660. column: 0
  661. },
  662. end: {
  663. line: 1,
  664. column: 1
  665. }
  666. }
  667. },
  668. right: {
  669. type: "ArrayExpression",
  670. elements: [
  671. {
  672. type: "Literal",
  673. value: 42,
  674. loc: {
  675. start: {
  676. line: 1,
  677. column: 6
  678. },
  679. end: {
  680. line: 1,
  681. column: 8
  682. }
  683. }
  684. }
  685. ],
  686. loc: {
  687. start: {
  688. line: 1,
  689. column: 4
  690. },
  691. end: {
  692. line: 1,
  693. column: 11
  694. }
  695. }
  696. },
  697. loc: {
  698. start: {
  699. line: 1,
  700. column: 0
  701. },
  702. end: {
  703. line: 1,
  704. column: 11
  705. }
  706. }
  707. },
  708. loc: {
  709. start: {
  710. line: 1,
  711. column: 0
  712. },
  713. end: {
  714. line: 1,
  715. column: 11
  716. }
  717. }
  718. }
  719. ],
  720. loc: {
  721. start: {
  722. line: 1,
  723. column: 0
  724. },
  725. end: {
  726. line: 1,
  727. column: 11
  728. }
  729. }
  730. });
  731. test("x = [ ,, 42 ]", {
  732. type: "Program",
  733. body: [
  734. {
  735. type: "ExpressionStatement",
  736. expression: {
  737. type: "AssignmentExpression",
  738. operator: "=",
  739. left: {
  740. type: "Identifier",
  741. name: "x",
  742. loc: {
  743. start: {
  744. line: 1,
  745. column: 0
  746. },
  747. end: {
  748. line: 1,
  749. column: 1
  750. }
  751. }
  752. },
  753. right: {
  754. type: "ArrayExpression",
  755. elements: [
  756. null,
  757. null,
  758. {
  759. type: "Literal",
  760. value: 42,
  761. loc: {
  762. start: {
  763. line: 1,
  764. column: 9
  765. },
  766. end: {
  767. line: 1,
  768. column: 11
  769. }
  770. }
  771. }
  772. ],
  773. loc: {
  774. start: {
  775. line: 1,
  776. column: 4
  777. },
  778. end: {
  779. line: 1,
  780. column: 13
  781. }
  782. }
  783. },
  784. loc: {
  785. start: {
  786. line: 1,
  787. column: 0
  788. },
  789. end: {
  790. line: 1,
  791. column: 13
  792. }
  793. }
  794. },
  795. loc: {
  796. start: {
  797. line: 1,
  798. column: 0
  799. },
  800. end: {
  801. line: 1,
  802. column: 13
  803. }
  804. }
  805. }
  806. ],
  807. loc: {
  808. start: {
  809. line: 1,
  810. column: 0
  811. },
  812. end: {
  813. line: 1,
  814. column: 13
  815. }
  816. }
  817. });
  818. test("x = [ 1, 2, 3, ]", {
  819. type: "Program",
  820. body: [
  821. {
  822. type: "ExpressionStatement",
  823. expression: {
  824. type: "AssignmentExpression",
  825. operator: "=",
  826. left: {
  827. type: "Identifier",
  828. name: "x",
  829. loc: {
  830. start: {
  831. line: 1,
  832. column: 0
  833. },
  834. end: {
  835. line: 1,
  836. column: 1
  837. }
  838. }
  839. },
  840. right: {
  841. type: "ArrayExpression",
  842. elements: [
  843. {
  844. type: "Literal",
  845. value: 1,
  846. loc: {
  847. start: {
  848. line: 1,
  849. column: 6
  850. },
  851. end: {
  852. line: 1,
  853. column: 7
  854. }
  855. }
  856. },
  857. {
  858. type: "Literal",
  859. value: 2,
  860. loc: {
  861. start: {
  862. line: 1,
  863. column: 9
  864. },
  865. end: {
  866. line: 1,
  867. column: 10
  868. }
  869. }
  870. },
  871. {
  872. type: "Literal",
  873. value: 3,
  874. loc: {
  875. start: {
  876. line: 1,
  877. column: 12
  878. },
  879. end: {
  880. line: 1,
  881. column: 13
  882. }
  883. }
  884. }
  885. ],
  886. loc: {
  887. start: {
  888. line: 1,
  889. column: 4
  890. },
  891. end: {
  892. line: 1,
  893. column: 16
  894. }
  895. }
  896. },
  897. loc: {
  898. start: {
  899. line: 1,
  900. column: 0
  901. },
  902. end: {
  903. line: 1,
  904. column: 16
  905. }
  906. }
  907. },
  908. loc: {
  909. start: {
  910. line: 1,
  911. column: 0
  912. },
  913. end: {
  914. line: 1,
  915. column: 16
  916. }
  917. }
  918. }
  919. ],
  920. loc: {
  921. start: {
  922. line: 1,
  923. column: 0
  924. },
  925. end: {
  926. line: 1,
  927. column: 16
  928. }
  929. }
  930. });
  931. test("x = [ 1, 2,, 3, ]", {
  932. type: "Program",
  933. body: [
  934. {
  935. type: "ExpressionStatement",
  936. expression: {
  937. type: "AssignmentExpression",
  938. operator: "=",
  939. left: {
  940. type: "Identifier",
  941. name: "x",
  942. loc: {
  943. start: {
  944. line: 1,
  945. column: 0
  946. },
  947. end: {
  948. line: 1,
  949. column: 1
  950. }
  951. }
  952. },
  953. right: {
  954. type: "ArrayExpression",
  955. elements: [
  956. {
  957. type: "Literal",
  958. value: 1,
  959. loc: {
  960. start: {
  961. line: 1,
  962. column: 6
  963. },
  964. end: {
  965. line: 1,
  966. column: 7
  967. }
  968. }
  969. },
  970. {
  971. type: "Literal",
  972. value: 2,
  973. loc: {
  974. start: {
  975. line: 1,
  976. column: 9
  977. },
  978. end: {
  979. line: 1,
  980. column: 10
  981. }
  982. }
  983. },
  984. null,
  985. {
  986. type: "Literal",
  987. value: 3,
  988. loc: {
  989. start: {
  990. line: 1,
  991. column: 13
  992. },
  993. end: {
  994. line: 1,
  995. column: 14
  996. }
  997. }
  998. }
  999. ],
  1000. loc: {
  1001. start: {
  1002. line: 1,
  1003. column: 4
  1004. },
  1005. end: {
  1006. line: 1,
  1007. column: 17
  1008. }
  1009. }
  1010. },
  1011. loc: {
  1012. start: {
  1013. line: 1,
  1014. column: 0
  1015. },
  1016. end: {
  1017. line: 1,
  1018. column: 17
  1019. }
  1020. }
  1021. },
  1022. loc: {
  1023. start: {
  1024. line: 1,
  1025. column: 0
  1026. },
  1027. end: {
  1028. line: 1,
  1029. column: 17
  1030. }
  1031. }
  1032. }
  1033. ],
  1034. loc: {
  1035. start: {
  1036. line: 1,
  1037. column: 0
  1038. },
  1039. end: {
  1040. line: 1,
  1041. column: 17
  1042. }
  1043. }
  1044. });
  1045. test("日本語 = []", {
  1046. type: "Program",
  1047. body: [
  1048. {
  1049. type: "ExpressionStatement",
  1050. expression: {
  1051. type: "AssignmentExpression",
  1052. operator: "=",
  1053. left: {
  1054. type: "Identifier",
  1055. name: "日本語",
  1056. loc: {
  1057. start: {
  1058. line: 1,
  1059. column: 0
  1060. },
  1061. end: {
  1062. line: 1,
  1063. column: 3
  1064. }
  1065. }
  1066. },
  1067. right: {
  1068. type: "ArrayExpression",
  1069. elements: [],
  1070. loc: {
  1071. start: {
  1072. line: 1,
  1073. column: 6
  1074. },
  1075. end: {
  1076. line: 1,
  1077. column: 8
  1078. }
  1079. }
  1080. },
  1081. loc: {
  1082. start: {
  1083. line: 1,
  1084. column: 0
  1085. },
  1086. end: {
  1087. line: 1,
  1088. column: 8
  1089. }
  1090. }
  1091. },
  1092. loc: {
  1093. start: {
  1094. line: 1,
  1095. column: 0
  1096. },
  1097. end: {
  1098. line: 1,
  1099. column: 8
  1100. }
  1101. }
  1102. }
  1103. ],
  1104. loc: {
  1105. start: {
  1106. line: 1,
  1107. column: 0
  1108. },
  1109. end: {
  1110. line: 1,
  1111. column: 8
  1112. }
  1113. }
  1114. });
  1115. test("T‿ = []", {
  1116. type: "Program",
  1117. body: [
  1118. {
  1119. type: "ExpressionStatement",
  1120. expression: {
  1121. type: "AssignmentExpression",
  1122. operator: "=",
  1123. left: {
  1124. type: "Identifier",
  1125. name: "T‿",
  1126. loc: {
  1127. start: {
  1128. line: 1,
  1129. column: 0
  1130. },
  1131. end: {
  1132. line: 1,
  1133. column: 2
  1134. }
  1135. }
  1136. },
  1137. right: {
  1138. type: "ArrayExpression",
  1139. elements: [],
  1140. loc: {
  1141. start: {
  1142. line: 1,
  1143. column: 5
  1144. },
  1145. end: {
  1146. line: 1,
  1147. column: 7
  1148. }
  1149. }
  1150. },
  1151. loc: {
  1152. start: {
  1153. line: 1,
  1154. column: 0
  1155. },
  1156. end: {
  1157. line: 1,
  1158. column: 7
  1159. }
  1160. }
  1161. },
  1162. loc: {
  1163. start: {
  1164. line: 1,
  1165. column: 0
  1166. },
  1167. end: {
  1168. line: 1,
  1169. column: 7
  1170. }
  1171. }
  1172. }
  1173. ],
  1174. loc: {
  1175. start: {
  1176. line: 1,
  1177. column: 0
  1178. },
  1179. end: {
  1180. line: 1,
  1181. column: 7
  1182. }
  1183. }
  1184. });
  1185. test("T‌ = []", {
  1186. type: "Program",
  1187. body: [
  1188. {
  1189. type: "ExpressionStatement",
  1190. expression: {
  1191. type: "AssignmentExpression",
  1192. operator: "=",
  1193. left: {
  1194. type: "Identifier",
  1195. name: "T‌",
  1196. loc: {
  1197. start: {
  1198. line: 1,
  1199. column: 0
  1200. },
  1201. end: {
  1202. line: 1,
  1203. column: 2
  1204. }
  1205. }
  1206. },
  1207. right: {
  1208. type: "ArrayExpression",
  1209. elements: [],
  1210. loc: {
  1211. start: {
  1212. line: 1,
  1213. column: 5
  1214. },
  1215. end: {
  1216. line: 1,
  1217. column: 7
  1218. }
  1219. }
  1220. },
  1221. loc: {
  1222. start: {
  1223. line: 1,
  1224. column: 0
  1225. },
  1226. end: {
  1227. line: 1,
  1228. column: 7
  1229. }
  1230. }
  1231. },
  1232. loc: {
  1233. start: {
  1234. line: 1,
  1235. column: 0
  1236. },
  1237. end: {
  1238. line: 1,
  1239. column: 7
  1240. }
  1241. }
  1242. }
  1243. ],
  1244. loc: {
  1245. start: {
  1246. line: 1,
  1247. column: 0
  1248. },
  1249. end: {
  1250. line: 1,
  1251. column: 7
  1252. }
  1253. }
  1254. });
  1255. test("T‍ = []", {
  1256. type: "Program",
  1257. body: [
  1258. {
  1259. type: "ExpressionStatement",
  1260. expression: {
  1261. type: "AssignmentExpression",
  1262. operator: "=",
  1263. left: {
  1264. type: "Identifier",
  1265. name: "T‍",
  1266. loc: {
  1267. start: {
  1268. line: 1,
  1269. column: 0
  1270. },
  1271. end: {
  1272. line: 1,
  1273. column: 2
  1274. }
  1275. }
  1276. },
  1277. right: {
  1278. type: "ArrayExpression",
  1279. elements: [],
  1280. loc: {
  1281. start: {
  1282. line: 1,
  1283. column: 5
  1284. },
  1285. end: {
  1286. line: 1,
  1287. column: 7
  1288. }
  1289. }
  1290. },
  1291. loc: {
  1292. start: {
  1293. line: 1,
  1294. column: 0
  1295. },
  1296. end: {
  1297. line: 1,
  1298. column: 7
  1299. }
  1300. }
  1301. },
  1302. loc: {
  1303. start: {
  1304. line: 1,
  1305. column: 0
  1306. },
  1307. end: {
  1308. line: 1,
  1309. column: 7
  1310. }
  1311. }
  1312. }
  1313. ],
  1314. loc: {
  1315. start: {
  1316. line: 1,
  1317. column: 0
  1318. },
  1319. end: {
  1320. line: 1,
  1321. column: 7
  1322. }
  1323. }
  1324. });
  1325. test("ⅣⅡ = []", {
  1326. type: "Program",
  1327. body: [
  1328. {
  1329. type: "ExpressionStatement",
  1330. expression: {
  1331. type: "AssignmentExpression",
  1332. operator: "=",
  1333. left: {
  1334. type: "Identifier",
  1335. name: "ⅣⅡ",
  1336. loc: {
  1337. start: {
  1338. line: 1,
  1339. column: 0
  1340. },
  1341. end: {
  1342. line: 1,
  1343. column: 2
  1344. }
  1345. }
  1346. },
  1347. right: {
  1348. type: "ArrayExpression",
  1349. elements: [],
  1350. loc: {
  1351. start: {
  1352. line: 1,
  1353. column: 5
  1354. },
  1355. end: {
  1356. line: 1,
  1357. column: 7
  1358. }
  1359. }
  1360. },
  1361. loc: {
  1362. start: {
  1363. line: 1,
  1364. column: 0
  1365. },
  1366. end: {
  1367. line: 1,
  1368. column: 7
  1369. }
  1370. }
  1371. },
  1372. loc: {
  1373. start: {
  1374. line: 1,
  1375. column: 0
  1376. },
  1377. end: {
  1378. line: 1,
  1379. column: 7
  1380. }
  1381. }
  1382. }
  1383. ],
  1384. loc: {
  1385. start: {
  1386. line: 1,
  1387. column: 0
  1388. },
  1389. end: {
  1390. line: 1,
  1391. column: 7
  1392. }
  1393. }
  1394. });
  1395. test("ⅣⅡ = []", {
  1396. type: "Program",
  1397. body: [
  1398. {
  1399. type: "ExpressionStatement",
  1400. expression: {
  1401. type: "AssignmentExpression",
  1402. operator: "=",
  1403. left: {
  1404. type: "Identifier",
  1405. name: "ⅣⅡ",
  1406. loc: {
  1407. start: {
  1408. line: 1,
  1409. column: 0
  1410. },
  1411. end: {
  1412. line: 1,
  1413. column: 2
  1414. }
  1415. }
  1416. },
  1417. right: {
  1418. type: "ArrayExpression",
  1419. elements: [],
  1420. loc: {
  1421. start: {
  1422. line: 1,
  1423. column: 5
  1424. },
  1425. end: {
  1426. line: 1,
  1427. column: 7
  1428. }
  1429. }
  1430. },
  1431. loc: {
  1432. start: {
  1433. line: 1,
  1434. column: 0
  1435. },
  1436. end: {
  1437. line: 1,
  1438. column: 7
  1439. }
  1440. }
  1441. },
  1442. loc: {
  1443. start: {
  1444. line: 1,
  1445. column: 0
  1446. },
  1447. end: {
  1448. line: 1,
  1449. column: 7
  1450. }
  1451. }
  1452. }
  1453. ],
  1454. loc: {
  1455. start: {
  1456. line: 1,
  1457. column: 0
  1458. },
  1459. end: {
  1460. line: 1,
  1461. column: 7
  1462. }
  1463. }
  1464. });
  1465. test("x = {}", {
  1466. type: "Program",
  1467. body: [
  1468. {
  1469. type: "ExpressionStatement",
  1470. expression: {
  1471. type: "AssignmentExpression",
  1472. operator: "=",
  1473. left: {
  1474. type: "Identifier",
  1475. name: "x",
  1476. loc: {
  1477. start: {
  1478. line: 1,
  1479. column: 0
  1480. },
  1481. end: {
  1482. line: 1,
  1483. column: 1
  1484. }
  1485. }
  1486. },
  1487. right: {
  1488. type: "ObjectExpression",
  1489. properties: [],
  1490. loc: {
  1491. start: {
  1492. line: 1,
  1493. column: 4
  1494. },
  1495. end: {
  1496. line: 1,
  1497. column: 6
  1498. }
  1499. }
  1500. },
  1501. loc: {
  1502. start: {
  1503. line: 1,
  1504. column: 0
  1505. },
  1506. end: {
  1507. line: 1,
  1508. column: 6
  1509. }
  1510. }
  1511. },
  1512. loc: {
  1513. start: {
  1514. line: 1,
  1515. column: 0
  1516. },
  1517. end: {
  1518. line: 1,
  1519. column: 6
  1520. }
  1521. }
  1522. }
  1523. ],
  1524. loc: {
  1525. start: {
  1526. line: 1,
  1527. column: 0
  1528. },
  1529. end: {
  1530. line: 1,
  1531. column: 6
  1532. }
  1533. }
  1534. });
  1535. test("x = { }", {
  1536. type: "Program",
  1537. body: [
  1538. {
  1539. type: "ExpressionStatement",
  1540. expression: {
  1541. type: "AssignmentExpression",
  1542. operator: "=",
  1543. left: {
  1544. type: "Identifier",
  1545. name: "x",
  1546. loc: {
  1547. start: {
  1548. line: 1,
  1549. column: 0
  1550. },
  1551. end: {
  1552. line: 1,
  1553. column: 1
  1554. }
  1555. }
  1556. },
  1557. right: {
  1558. type: "ObjectExpression",
  1559. properties: [],
  1560. loc: {
  1561. start: {
  1562. line: 1,
  1563. column: 4
  1564. },
  1565. end: {
  1566. line: 1,
  1567. column: 7
  1568. }
  1569. }
  1570. },
  1571. loc: {
  1572. start: {
  1573. line: 1,
  1574. column: 0
  1575. },
  1576. end: {
  1577. line: 1,
  1578. column: 7
  1579. }
  1580. }
  1581. },
  1582. loc: {
  1583. start: {
  1584. line: 1,
  1585. column: 0
  1586. },
  1587. end: {
  1588. line: 1,
  1589. column: 7
  1590. }
  1591. }
  1592. }
  1593. ],
  1594. loc: {
  1595. start: {
  1596. line: 1,
  1597. column: 0
  1598. },
  1599. end: {
  1600. line: 1,
  1601. column: 7
  1602. }
  1603. }
  1604. });
  1605. test("x = { answer: 42 }", {
  1606. type: "Program",
  1607. body: [
  1608. {
  1609. type: "ExpressionStatement",
  1610. expression: {
  1611. type: "AssignmentExpression",
  1612. operator: "=",
  1613. left: {
  1614. type: "Identifier",
  1615. name: "x",
  1616. loc: {
  1617. start: {
  1618. line: 1,
  1619. column: 0
  1620. },
  1621. end: {
  1622. line: 1,
  1623. column: 1
  1624. }
  1625. }
  1626. },
  1627. right: {
  1628. type: "ObjectExpression",
  1629. properties: [
  1630. {
  1631. type: "Property",
  1632. key: {
  1633. type: "Identifier",
  1634. name: "answer",
  1635. loc: {
  1636. start: {
  1637. line: 1,
  1638. column: 6
  1639. },
  1640. end: {
  1641. line: 1,
  1642. column: 12
  1643. }
  1644. }
  1645. },
  1646. value: {
  1647. type: "Literal",
  1648. value: 42,
  1649. loc: {
  1650. start: {
  1651. line: 1,
  1652. column: 14
  1653. },
  1654. end: {
  1655. line: 1,
  1656. column: 16
  1657. }
  1658. }
  1659. },
  1660. kind: "init"
  1661. }
  1662. ],
  1663. loc: {
  1664. start: {
  1665. line: 1,
  1666. column: 4
  1667. },
  1668. end: {
  1669. line: 1,
  1670. column: 18
  1671. }
  1672. }
  1673. },
  1674. loc: {
  1675. start: {
  1676. line: 1,
  1677. column: 0
  1678. },
  1679. end: {
  1680. line: 1,
  1681. column: 18
  1682. }
  1683. }
  1684. },
  1685. loc: {
  1686. start: {
  1687. line: 1,
  1688. column: 0
  1689. },
  1690. end: {
  1691. line: 1,
  1692. column: 18
  1693. }
  1694. }
  1695. }
  1696. ],
  1697. loc: {
  1698. start: {
  1699. line: 1,
  1700. column: 0
  1701. },
  1702. end: {
  1703. line: 1,
  1704. column: 18
  1705. }
  1706. }
  1707. });
  1708. test("x = { if: 42 }", {
  1709. type: "Program",
  1710. body: [
  1711. {
  1712. type: "ExpressionStatement",
  1713. expression: {
  1714. type: "AssignmentExpression",
  1715. operator: "=",
  1716. left: {
  1717. type: "Identifier",
  1718. name: "x",
  1719. loc: {
  1720. start: {
  1721. line: 1,
  1722. column: 0
  1723. },
  1724. end: {
  1725. line: 1,
  1726. column: 1
  1727. }
  1728. }
  1729. },
  1730. right: {
  1731. type: "ObjectExpression",
  1732. properties: [
  1733. {
  1734. type: "Property",
  1735. key: {
  1736. type: "Identifier",
  1737. name: "if",
  1738. loc: {
  1739. start: {
  1740. line: 1,
  1741. column: 6
  1742. },
  1743. end: {
  1744. line: 1,
  1745. column: 8
  1746. }
  1747. }
  1748. },
  1749. value: {
  1750. type: "Literal",
  1751. value: 42,
  1752. loc: {
  1753. start: {
  1754. line: 1,
  1755. column: 10
  1756. },
  1757. end: {
  1758. line: 1,
  1759. column: 12
  1760. }
  1761. }
  1762. },
  1763. kind: "init"
  1764. }
  1765. ],
  1766. loc: {
  1767. start: {
  1768. line: 1,
  1769. column: 4
  1770. },
  1771. end: {
  1772. line: 1,
  1773. column: 14
  1774. }
  1775. }
  1776. },
  1777. loc: {
  1778. start: {
  1779. line: 1,
  1780. column: 0
  1781. },
  1782. end: {
  1783. line: 1,
  1784. column: 14
  1785. }
  1786. }
  1787. },
  1788. loc: {
  1789. start: {
  1790. line: 1,
  1791. column: 0
  1792. },
  1793. end: {
  1794. line: 1,
  1795. column: 14
  1796. }
  1797. }
  1798. }
  1799. ],
  1800. loc: {
  1801. start: {
  1802. line: 1,
  1803. column: 0
  1804. },
  1805. end: {
  1806. line: 1,
  1807. column: 14
  1808. }
  1809. }
  1810. });
  1811. test("x = { true: 42 }", {
  1812. type: "Program",
  1813. body: [
  1814. {
  1815. type: "ExpressionStatement",
  1816. expression: {
  1817. type: "AssignmentExpression",
  1818. operator: "=",
  1819. left: {
  1820. type: "Identifier",
  1821. name: "x",
  1822. loc: {
  1823. start: {
  1824. line: 1,
  1825. column: 0
  1826. },
  1827. end: {
  1828. line: 1,
  1829. column: 1
  1830. }
  1831. }
  1832. },
  1833. right: {
  1834. type: "ObjectExpression",
  1835. properties: [
  1836. {
  1837. type: "Property",
  1838. key: {
  1839. type: "Identifier",
  1840. name: "true",
  1841. loc: {
  1842. start: {
  1843. line: 1,
  1844. column: 6
  1845. },
  1846. end: {
  1847. line: 1,
  1848. column: 10
  1849. }
  1850. }
  1851. },
  1852. value: {
  1853. type: "Literal",
  1854. value: 42,
  1855. loc: {
  1856. start: {
  1857. line: 1,
  1858. column: 12
  1859. },
  1860. end: {
  1861. line: 1,
  1862. column: 14
  1863. }
  1864. }
  1865. },
  1866. kind: "init"
  1867. }
  1868. ],
  1869. loc: {
  1870. start: {
  1871. line: 1,
  1872. column: 4
  1873. },
  1874. end: {
  1875. line: 1,
  1876. column: 16
  1877. }
  1878. }
  1879. },
  1880. loc: {
  1881. start: {
  1882. line: 1,
  1883. column: 0
  1884. },
  1885. end: {
  1886. line: 1,
  1887. column: 16
  1888. }
  1889. }
  1890. },
  1891. loc: {
  1892. start: {
  1893. line: 1,
  1894. column: 0
  1895. },
  1896. end: {
  1897. line: 1,
  1898. column: 16
  1899. }
  1900. }
  1901. }
  1902. ],
  1903. loc: {
  1904. start: {
  1905. line: 1,
  1906. column: 0
  1907. },
  1908. end: {
  1909. line: 1,
  1910. column: 16
  1911. }
  1912. }
  1913. });
  1914. test("x = { false: 42 }", {
  1915. type: "Program",
  1916. body: [
  1917. {
  1918. type: "ExpressionStatement",
  1919. expression: {
  1920. type: "AssignmentExpression",
  1921. operator: "=",
  1922. left: {
  1923. type: "Identifier",
  1924. name: "x",
  1925. loc: {
  1926. start: {
  1927. line: 1,
  1928. column: 0
  1929. },
  1930. end: {
  1931. line: 1,
  1932. column: 1
  1933. }
  1934. }
  1935. },
  1936. right: {
  1937. type: "ObjectExpression",
  1938. properties: [
  1939. {
  1940. type: "Property",
  1941. key: {
  1942. type: "Identifier",
  1943. name: "false",
  1944. loc: {
  1945. start: {
  1946. line: 1,
  1947. column: 6
  1948. },
  1949. end: {
  1950. line: 1,
  1951. column: 11
  1952. }
  1953. }
  1954. },
  1955. value: {
  1956. type: "Literal",
  1957. value: 42,
  1958. loc: {
  1959. start: {
  1960. line: 1,
  1961. column: 13
  1962. },
  1963. end: {
  1964. line: 1,
  1965. column: 15
  1966. }
  1967. }
  1968. },
  1969. kind: "init"
  1970. }
  1971. ],
  1972. loc: {
  1973. start: {
  1974. line: 1,
  1975. column: 4
  1976. },
  1977. end: {
  1978. line: 1,
  1979. column: 17
  1980. }
  1981. }
  1982. },
  1983. loc: {
  1984. start: {
  1985. line: 1,
  1986. column: 0
  1987. },
  1988. end: {
  1989. line: 1,
  1990. column: 17
  1991. }
  1992. }
  1993. },
  1994. loc: {
  1995. start: {
  1996. line: 1,
  1997. column: 0
  1998. },
  1999. end: {
  2000. line: 1,
  2001. column: 17
  2002. }
  2003. }
  2004. }
  2005. ],
  2006. loc: {
  2007. start: {
  2008. line: 1,
  2009. column: 0
  2010. },
  2011. end: {
  2012. line: 1,
  2013. column: 17
  2014. }
  2015. }
  2016. });
  2017. test("x = { null: 42 }", {
  2018. type: "Program",
  2019. body: [
  2020. {
  2021. type: "ExpressionStatement",
  2022. expression: {
  2023. type: "AssignmentExpression",
  2024. operator: "=",
  2025. left: {
  2026. type: "Identifier",
  2027. name: "x",
  2028. loc: {
  2029. start: {
  2030. line: 1,
  2031. column: 0
  2032. },
  2033. end: {
  2034. line: 1,
  2035. column: 1
  2036. }
  2037. }
  2038. },
  2039. right: {
  2040. type: "ObjectExpression",
  2041. properties: [
  2042. {
  2043. type: "Property",
  2044. key: {
  2045. type: "Identifier",
  2046. name: "null",
  2047. loc: {
  2048. start: {
  2049. line: 1,
  2050. column: 6
  2051. },
  2052. end: {
  2053. line: 1,
  2054. column: 10
  2055. }
  2056. }
  2057. },
  2058. value: {
  2059. type: "Literal",
  2060. value: 42,
  2061. loc: {
  2062. start: {
  2063. line: 1,
  2064. column: 12
  2065. },
  2066. end: {
  2067. line: 1,
  2068. column: 14
  2069. }
  2070. }
  2071. },
  2072. kind: "init"
  2073. }
  2074. ],
  2075. loc: {
  2076. start: {
  2077. line: 1,
  2078. column: 4
  2079. },
  2080. end: {
  2081. line: 1,
  2082. column: 16
  2083. }
  2084. }
  2085. },
  2086. loc: {
  2087. start: {
  2088. line: 1,
  2089. column: 0
  2090. },
  2091. end: {
  2092. line: 1,
  2093. column: 16
  2094. }
  2095. }
  2096. },
  2097. loc: {
  2098. start: {
  2099. line: 1,
  2100. column: 0
  2101. },
  2102. end: {
  2103. line: 1,
  2104. column: 16
  2105. }
  2106. }
  2107. }
  2108. ],
  2109. loc: {
  2110. start: {
  2111. line: 1,
  2112. column: 0
  2113. },
  2114. end: {
  2115. line: 1,
  2116. column: 16
  2117. }
  2118. }
  2119. });
  2120. test("x = { \"answer\": 42 }", {
  2121. type: "Program",
  2122. body: [
  2123. {
  2124. type: "ExpressionStatement",
  2125. expression: {
  2126. type: "AssignmentExpression",
  2127. operator: "=",
  2128. left: {
  2129. type: "Identifier",
  2130. name: "x",
  2131. loc: {
  2132. start: {
  2133. line: 1,
  2134. column: 0
  2135. },
  2136. end: {
  2137. line: 1,
  2138. column: 1
  2139. }
  2140. }
  2141. },
  2142. right: {
  2143. type: "ObjectExpression",
  2144. properties: [
  2145. {
  2146. type: "Property",
  2147. key: {
  2148. type: "Literal",
  2149. value: "answer",
  2150. loc: {
  2151. start: {
  2152. line: 1,
  2153. column: 6
  2154. },
  2155. end: {
  2156. line: 1,
  2157. column: 14
  2158. }
  2159. }
  2160. },
  2161. value: {
  2162. type: "Literal",
  2163. value: 42,
  2164. loc: {
  2165. start: {
  2166. line: 1,
  2167. column: 16
  2168. },
  2169. end: {
  2170. line: 1,
  2171. column: 18
  2172. }
  2173. }
  2174. },
  2175. kind: "init"
  2176. }
  2177. ],
  2178. loc: {
  2179. start: {
  2180. line: 1,
  2181. column: 4
  2182. },
  2183. end: {
  2184. line: 1,
  2185. column: 20
  2186. }
  2187. }
  2188. },
  2189. loc: {
  2190. start: {
  2191. line: 1,
  2192. column: 0
  2193. },
  2194. end: {
  2195. line: 1,
  2196. column: 20
  2197. }
  2198. }
  2199. },
  2200. loc: {
  2201. start: {
  2202. line: 1,
  2203. column: 0
  2204. },
  2205. end: {
  2206. line: 1,
  2207. column: 20
  2208. }
  2209. }
  2210. }
  2211. ],
  2212. loc: {
  2213. start: {
  2214. line: 1,
  2215. column: 0
  2216. },
  2217. end: {
  2218. line: 1,
  2219. column: 20
  2220. }
  2221. }
  2222. });
  2223. test("x = { x: 1, x: 2 }", {
  2224. type: "Program",
  2225. body: [
  2226. {
  2227. type: "ExpressionStatement",
  2228. expression: {
  2229. type: "AssignmentExpression",
  2230. operator: "=",
  2231. left: {
  2232. type: "Identifier",
  2233. name: "x",
  2234. loc: {
  2235. start: {
  2236. line: 1,
  2237. column: 0
  2238. },
  2239. end: {
  2240. line: 1,
  2241. column: 1
  2242. }
  2243. }
  2244. },
  2245. right: {
  2246. type: "ObjectExpression",
  2247. properties: [
  2248. {
  2249. type: "Property",
  2250. key: {
  2251. type: "Identifier",
  2252. name: "x",
  2253. loc: {
  2254. start: {
  2255. line: 1,
  2256. column: 6
  2257. },
  2258. end: {
  2259. line: 1,
  2260. column: 7
  2261. }
  2262. }
  2263. },
  2264. value: {
  2265. type: "Literal",
  2266. value: 1,
  2267. loc: {
  2268. start: {
  2269. line: 1,
  2270. column: 9
  2271. },
  2272. end: {
  2273. line: 1,
  2274. column: 10
  2275. }
  2276. }
  2277. },
  2278. kind: "init"
  2279. },
  2280. {
  2281. type: "Property",
  2282. key: {
  2283. type: "Identifier",
  2284. name: "x",
  2285. loc: {
  2286. start: {
  2287. line: 1,
  2288. column: 12
  2289. },
  2290. end: {
  2291. line: 1,
  2292. column: 13
  2293. }
  2294. }
  2295. },
  2296. value: {
  2297. type: "Literal",
  2298. value: 2,
  2299. loc: {
  2300. start: {
  2301. line: 1,
  2302. column: 15
  2303. },
  2304. end: {
  2305. line: 1,
  2306. column: 16
  2307. }
  2308. }
  2309. },
  2310. kind: "init"
  2311. }
  2312. ],
  2313. loc: {
  2314. start: {
  2315. line: 1,
  2316. column: 4
  2317. },
  2318. end: {
  2319. line: 1,
  2320. column: 18
  2321. }
  2322. }
  2323. },
  2324. loc: {
  2325. start: {
  2326. line: 1,
  2327. column: 0
  2328. },
  2329. end: {
  2330. line: 1,
  2331. column: 18
  2332. }
  2333. }
  2334. },
  2335. loc: {
  2336. start: {
  2337. line: 1,
  2338. column: 0
  2339. },
  2340. end: {
  2341. line: 1,
  2342. column: 18
  2343. }
  2344. }
  2345. }
  2346. ],
  2347. loc: {
  2348. start: {
  2349. line: 1,
  2350. column: 0
  2351. },
  2352. end: {
  2353. line: 1,
  2354. column: 18
  2355. }
  2356. }
  2357. });
  2358. test("x = { get width() { return m_width } }", {
  2359. type: "Program",
  2360. body: [
  2361. {
  2362. type: "ExpressionStatement",
  2363. expression: {
  2364. type: "AssignmentExpression",
  2365. operator: "=",
  2366. left: {
  2367. type: "Identifier",
  2368. name: "x",
  2369. loc: {
  2370. start: {
  2371. line: 1,
  2372. column: 0
  2373. },
  2374. end: {
  2375. line: 1,
  2376. column: 1
  2377. }
  2378. }
  2379. },
  2380. right: {
  2381. type: "ObjectExpression",
  2382. properties: [
  2383. {
  2384. type: "Property",
  2385. key: {
  2386. type: "Identifier",
  2387. name: "width",
  2388. loc: {
  2389. start: {
  2390. line: 1,
  2391. column: 10
  2392. },
  2393. end: {
  2394. line: 1,
  2395. column: 15
  2396. }
  2397. }
  2398. },
  2399. kind: "get",
  2400. value: {
  2401. type: "FunctionExpression",
  2402. id: null,
  2403. params: [],
  2404. body: {
  2405. type: "BlockStatement",
  2406. body: [
  2407. {
  2408. type: "ReturnStatement",
  2409. argument: {
  2410. type: "Identifier",
  2411. name: "m_width",
  2412. loc: {
  2413. start: {
  2414. line: 1,
  2415. column: 27
  2416. },
  2417. end: {
  2418. line: 1,
  2419. column: 34
  2420. }
  2421. }
  2422. },
  2423. loc: {
  2424. start: {
  2425. line: 1,
  2426. column: 20
  2427. },
  2428. end: {
  2429. line: 1,
  2430. column: 34
  2431. }
  2432. }
  2433. }
  2434. ],
  2435. loc: {
  2436. start: {
  2437. line: 1,
  2438. column: 18
  2439. },
  2440. end: {
  2441. line: 1,
  2442. column: 36
  2443. }
  2444. }
  2445. },
  2446. loc: {
  2447. start: {
  2448. line: 1,
  2449. column: 15
  2450. },
  2451. end: {
  2452. line: 1,
  2453. column: 36
  2454. }
  2455. }
  2456. }
  2457. }
  2458. ],
  2459. loc: {
  2460. start: {
  2461. line: 1,
  2462. column: 4
  2463. },
  2464. end: {
  2465. line: 1,
  2466. column: 38
  2467. }
  2468. }
  2469. },
  2470. loc: {
  2471. start: {
  2472. line: 1,
  2473. column: 0
  2474. },
  2475. end: {
  2476. line: 1,
  2477. column: 38
  2478. }
  2479. }
  2480. },
  2481. loc: {
  2482. start: {
  2483. line: 1,
  2484. column: 0
  2485. },
  2486. end: {
  2487. line: 1,
  2488. column: 38
  2489. }
  2490. }
  2491. }
  2492. ],
  2493. loc: {
  2494. start: {
  2495. line: 1,
  2496. column: 0
  2497. },
  2498. end: {
  2499. line: 1,
  2500. column: 38
  2501. }
  2502. }
  2503. });
  2504. test("x = { get undef() {} }", {
  2505. type: "Program",
  2506. body: [
  2507. {
  2508. type: "ExpressionStatement",
  2509. expression: {
  2510. type: "AssignmentExpression",
  2511. operator: "=",
  2512. left: {
  2513. type: "Identifier",
  2514. name: "x",
  2515. loc: {
  2516. start: {
  2517. line: 1,
  2518. column: 0
  2519. },
  2520. end: {
  2521. line: 1,
  2522. column: 1
  2523. }
  2524. }
  2525. },
  2526. right: {
  2527. type: "ObjectExpression",
  2528. properties: [
  2529. {
  2530. type: "Property",
  2531. key: {
  2532. type: "Identifier",
  2533. name: "undef",
  2534. loc: {
  2535. start: {
  2536. line: 1,
  2537. column: 10
  2538. },
  2539. end: {
  2540. line: 1,
  2541. column: 15
  2542. }
  2543. }
  2544. },
  2545. kind: "get",
  2546. value: {
  2547. type: "FunctionExpression",
  2548. id: null,
  2549. params: [],
  2550. body: {
  2551. type: "BlockStatement",
  2552. body: [],
  2553. loc: {
  2554. start: {
  2555. line: 1,
  2556. column: 18
  2557. },
  2558. end: {
  2559. line: 1,
  2560. column: 20
  2561. }
  2562. }
  2563. },
  2564. loc: {
  2565. start: {
  2566. line: 1,
  2567. column: 15
  2568. },
  2569. end: {
  2570. line: 1,
  2571. column: 20
  2572. }
  2573. }
  2574. }
  2575. }
  2576. ],
  2577. loc: {
  2578. start: {
  2579. line: 1,
  2580. column: 4
  2581. },
  2582. end: {
  2583. line: 1,
  2584. column: 22
  2585. }
  2586. }
  2587. },
  2588. loc: {
  2589. start: {
  2590. line: 1,
  2591. column: 0
  2592. },
  2593. end: {
  2594. line: 1,
  2595. column: 22
  2596. }
  2597. }
  2598. },
  2599. loc: {
  2600. start: {
  2601. line: 1,
  2602. column: 0
  2603. },
  2604. end: {
  2605. line: 1,
  2606. column: 22
  2607. }
  2608. }
  2609. }
  2610. ],
  2611. loc: {
  2612. start: {
  2613. line: 1,
  2614. column: 0
  2615. },
  2616. end: {
  2617. line: 1,
  2618. column: 22
  2619. }
  2620. }
  2621. });
  2622. test("x = { get if() {} }", {
  2623. type: "Program",
  2624. body: [
  2625. {
  2626. type: "ExpressionStatement",
  2627. expression: {
  2628. type: "AssignmentExpression",
  2629. operator: "=",
  2630. left: {
  2631. type: "Identifier",
  2632. name: "x",
  2633. loc: {
  2634. start: {
  2635. line: 1,
  2636. column: 0
  2637. },
  2638. end: {
  2639. line: 1,
  2640. column: 1
  2641. }
  2642. }
  2643. },
  2644. right: {
  2645. type: "ObjectExpression",
  2646. properties: [
  2647. {
  2648. type: "Property",
  2649. key: {
  2650. type: "Identifier",
  2651. name: "if",
  2652. loc: {
  2653. start: {
  2654. line: 1,
  2655. column: 10
  2656. },
  2657. end: {
  2658. line: 1,
  2659. column: 12
  2660. }
  2661. }
  2662. },
  2663. kind: "get",
  2664. value: {
  2665. type: "FunctionExpression",
  2666. id: null,
  2667. params: [],
  2668. body: {
  2669. type: "BlockStatement",
  2670. body: [],
  2671. loc: {
  2672. s