/client/node_modules/grunt-ng-annotate/node_modules/ng-annotate/node_modules/acorn/test/tests.js

https://gitlab.com/yolile/fpuna-denguemaps · JavaScript · 2699 lines · 2662 code · 35 blank · 2 comment · 2 complexity · 8f7591b49ba51f78cdda118e3bc0274b MD5 · raw 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("..");
  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]/,
  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. testFail("(x) = 23", "Assigning to rvalue (1:0)", { preserveParens: true });
  398. test("x = []", {
  399. type: "Program",
  400. body: [
  401. {
  402. type: "ExpressionStatement",
  403. expression: {
  404. type: "AssignmentExpression",
  405. operator: "=",
  406. left: {
  407. type: "Identifier",
  408. name: "x",
  409. loc: {
  410. start: {
  411. line: 1,
  412. column: 0
  413. },
  414. end: {
  415. line: 1,
  416. column: 1
  417. }
  418. }
  419. },
  420. right: {
  421. type: "ArrayExpression",
  422. elements: [],
  423. loc: {
  424. start: {
  425. line: 1,
  426. column: 4
  427. },
  428. end: {
  429. line: 1,
  430. column: 6
  431. }
  432. }
  433. },
  434. loc: {
  435. start: {
  436. line: 1,
  437. column: 0
  438. },
  439. end: {
  440. line: 1,
  441. column: 6
  442. }
  443. }
  444. },
  445. loc: {
  446. start: {
  447. line: 1,
  448. column: 0
  449. },
  450. end: {
  451. line: 1,
  452. column: 6
  453. }
  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. test("x = [ ]", {
  469. type: "Program",
  470. body: [
  471. {
  472. type: "ExpressionStatement",
  473. expression: {
  474. type: "AssignmentExpression",
  475. operator: "=",
  476. left: {
  477. type: "Identifier",
  478. name: "x",
  479. loc: {
  480. start: {
  481. line: 1,
  482. column: 0
  483. },
  484. end: {
  485. line: 1,
  486. column: 1
  487. }
  488. }
  489. },
  490. right: {
  491. type: "ArrayExpression",
  492. elements: [],
  493. loc: {
  494. start: {
  495. line: 1,
  496. column: 4
  497. },
  498. end: {
  499. line: 1,
  500. column: 7
  501. }
  502. }
  503. },
  504. loc: {
  505. start: {
  506. line: 1,
  507. column: 0
  508. },
  509. end: {
  510. line: 1,
  511. column: 7
  512. }
  513. }
  514. },
  515. loc: {
  516. start: {
  517. line: 1,
  518. column: 0
  519. },
  520. end: {
  521. line: 1,
  522. column: 7
  523. }
  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. test("x = [ 42 ]", {
  539. type: "Program",
  540. body: [
  541. {
  542. type: "ExpressionStatement",
  543. expression: {
  544. type: "AssignmentExpression",
  545. operator: "=",
  546. left: {
  547. type: "Identifier",
  548. name: "x",
  549. loc: {
  550. start: {
  551. line: 1,
  552. column: 0
  553. },
  554. end: {
  555. line: 1,
  556. column: 1
  557. }
  558. }
  559. },
  560. right: {
  561. type: "ArrayExpression",
  562. elements: [
  563. {
  564. type: "Literal",
  565. value: 42,
  566. loc: {
  567. start: {
  568. line: 1,
  569. column: 6
  570. },
  571. end: {
  572. line: 1,
  573. column: 8
  574. }
  575. }
  576. }
  577. ],
  578. loc: {
  579. start: {
  580. line: 1,
  581. column: 4
  582. },
  583. end: {
  584. line: 1,
  585. column: 10
  586. }
  587. }
  588. },
  589. loc: {
  590. start: {
  591. line: 1,
  592. column: 0
  593. },
  594. end: {
  595. line: 1,
  596. column: 10
  597. }
  598. }
  599. },
  600. loc: {
  601. start: {
  602. line: 1,
  603. column: 0
  604. },
  605. end: {
  606. line: 1,
  607. column: 10
  608. }
  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. test("x = [ 42, ]", {
  624. type: "Program",
  625. body: [
  626. {
  627. type: "ExpressionStatement",
  628. expression: {
  629. type: "AssignmentExpression",
  630. operator: "=",
  631. left: {
  632. type: "Identifier",
  633. name: "x",
  634. loc: {
  635. start: {
  636. line: 1,
  637. column: 0
  638. },
  639. end: {
  640. line: 1,
  641. column: 1
  642. }
  643. }
  644. },
  645. right: {
  646. type: "ArrayExpression",
  647. elements: [
  648. {
  649. type: "Literal",
  650. value: 42,
  651. loc: {
  652. start: {
  653. line: 1,
  654. column: 6
  655. },
  656. end: {
  657. line: 1,
  658. column: 8
  659. }
  660. }
  661. }
  662. ],
  663. loc: {
  664. start: {
  665. line: 1,
  666. column: 4
  667. },
  668. end: {
  669. line: 1,
  670. column: 11
  671. }
  672. }
  673. },
  674. loc: {
  675. start: {
  676. line: 1,
  677. column: 0
  678. },
  679. end: {
  680. line: 1,
  681. column: 11
  682. }
  683. }
  684. },
  685. loc: {
  686. start: {
  687. line: 1,
  688. column: 0
  689. },
  690. end: {
  691. line: 1,
  692. column: 11
  693. }
  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. test("x = [ ,, 42 ]", {
  709. type: "Program",
  710. body: [
  711. {
  712. type: "ExpressionStatement",
  713. expression: {
  714. type: "AssignmentExpression",
  715. operator: "=",
  716. left: {
  717. type: "Identifier",
  718. name: "x",
  719. loc: {
  720. start: {
  721. line: 1,
  722. column: 0
  723. },
  724. end: {
  725. line: 1,
  726. column: 1
  727. }
  728. }
  729. },
  730. right: {
  731. type: "ArrayExpression",
  732. elements: [
  733. null,
  734. null,
  735. {
  736. type: "Literal",
  737. value: 42,
  738. loc: {
  739. start: {
  740. line: 1,
  741. column: 9
  742. },
  743. end: {
  744. line: 1,
  745. column: 11
  746. }
  747. }
  748. }
  749. ],
  750. loc: {
  751. start: {
  752. line: 1,
  753. column: 4
  754. },
  755. end: {
  756. line: 1,
  757. column: 13
  758. }
  759. }
  760. },
  761. loc: {
  762. start: {
  763. line: 1,
  764. column: 0
  765. },
  766. end: {
  767. line: 1,
  768. column: 13
  769. }
  770. }
  771. },
  772. loc: {
  773. start: {
  774. line: 1,
  775. column: 0
  776. },
  777. end: {
  778. line: 1,
  779. column: 13
  780. }
  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. test("x = [ 1, 2, 3, ]", {
  796. type: "Program",
  797. body: [
  798. {
  799. type: "ExpressionStatement",
  800. expression: {
  801. type: "AssignmentExpression",
  802. operator: "=",
  803. left: {
  804. type: "Identifier",
  805. name: "x",
  806. loc: {
  807. start: {
  808. line: 1,
  809. column: 0
  810. },
  811. end: {
  812. line: 1,
  813. column: 1
  814. }
  815. }
  816. },
  817. right: {
  818. type: "ArrayExpression",
  819. elements: [
  820. {
  821. type: "Literal",
  822. value: 1,
  823. loc: {
  824. start: {
  825. line: 1,
  826. column: 6
  827. },
  828. end: {
  829. line: 1,
  830. column: 7
  831. }
  832. }
  833. },
  834. {
  835. type: "Literal",
  836. value: 2,
  837. loc: {
  838. start: {
  839. line: 1,
  840. column: 9
  841. },
  842. end: {
  843. line: 1,
  844. column: 10
  845. }
  846. }
  847. },
  848. {
  849. type: "Literal",
  850. value: 3,
  851. loc: {
  852. start: {
  853. line: 1,
  854. column: 12
  855. },
  856. end: {
  857. line: 1,
  858. column: 13
  859. }
  860. }
  861. }
  862. ],
  863. loc: {
  864. start: {
  865. line: 1,
  866. column: 4
  867. },
  868. end: {
  869. line: 1,
  870. column: 16
  871. }
  872. }
  873. },
  874. loc: {
  875. start: {
  876. line: 1,
  877. column: 0
  878. },
  879. end: {
  880. line: 1,
  881. column: 16
  882. }
  883. }
  884. },
  885. loc: {
  886. start: {
  887. line: 1,
  888. column: 0
  889. },
  890. end: {
  891. line: 1,
  892. column: 16
  893. }
  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. test("x = [ 1, 2,, 3, ]", {
  909. type: "Program",
  910. body: [
  911. {
  912. type: "ExpressionStatement",
  913. expression: {
  914. type: "AssignmentExpression",
  915. operator: "=",
  916. left: {
  917. type: "Identifier",
  918. name: "x",
  919. loc: {
  920. start: {
  921. line: 1,
  922. column: 0
  923. },
  924. end: {
  925. line: 1,
  926. column: 1
  927. }
  928. }
  929. },
  930. right: {
  931. type: "ArrayExpression",
  932. elements: [
  933. {
  934. type: "Literal",
  935. value: 1,
  936. loc: {
  937. start: {
  938. line: 1,
  939. column: 6
  940. },
  941. end: {
  942. line: 1,
  943. column: 7
  944. }
  945. }
  946. },
  947. {
  948. type: "Literal",
  949. value: 2,
  950. loc: {
  951. start: {
  952. line: 1,
  953. column: 9
  954. },
  955. end: {
  956. line: 1,
  957. column: 10
  958. }
  959. }
  960. },
  961. null,
  962. {
  963. type: "Literal",
  964. value: 3,
  965. loc: {
  966. start: {
  967. line: 1,
  968. column: 13
  969. },
  970. end: {
  971. line: 1,
  972. column: 14
  973. }
  974. }
  975. }
  976. ],
  977. loc: {
  978. start: {
  979. line: 1,
  980. column: 4
  981. },
  982. end: {
  983. line: 1,
  984. column: 17
  985. }
  986. }
  987. },
  988. loc: {
  989. start: {
  990. line: 1,
  991. column: 0
  992. },
  993. end: {
  994. line: 1,
  995. column: 17
  996. }
  997. }
  998. },
  999. loc: {
  1000. start: {
  1001. line: 1,
  1002. column: 0
  1003. },
  1004. end: {
  1005. line: 1,
  1006. column: 17
  1007. }
  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. test("日本語 = []", {
  1023. type: "Program",
  1024. body: [
  1025. {
  1026. type: "ExpressionStatement",
  1027. expression: {
  1028. type: "AssignmentExpression",
  1029. operator: "=",
  1030. left: {
  1031. type: "Identifier",
  1032. name: "日本語",
  1033. loc: {
  1034. start: {
  1035. line: 1,
  1036. column: 0
  1037. },
  1038. end: {
  1039. line: 1,
  1040. column: 3
  1041. }
  1042. }
  1043. },
  1044. right: {
  1045. type: "ArrayExpression",
  1046. elements: [],
  1047. loc: {
  1048. start: {
  1049. line: 1,
  1050. column: 6
  1051. },
  1052. end: {
  1053. line: 1,
  1054. column: 8
  1055. }
  1056. }
  1057. },
  1058. loc: {
  1059. start: {
  1060. line: 1,
  1061. column: 0
  1062. },
  1063. end: {
  1064. line: 1,
  1065. column: 8
  1066. }
  1067. }
  1068. },
  1069. loc: {
  1070. start: {
  1071. line: 1,
  1072. column: 0
  1073. },
  1074. end: {
  1075. line: 1,
  1076. column: 8
  1077. }
  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. test("T‿ = []", {
  1093. type: "Program",
  1094. body: [
  1095. {
  1096. type: "ExpressionStatement",
  1097. expression: {
  1098. type: "AssignmentExpression",
  1099. operator: "=",
  1100. left: {
  1101. type: "Identifier",
  1102. name: "T‿",
  1103. loc: {
  1104. start: {
  1105. line: 1,
  1106. column: 0
  1107. },
  1108. end: {
  1109. line: 1,
  1110. column: 2
  1111. }
  1112. }
  1113. },
  1114. right: {
  1115. type: "ArrayExpression",
  1116. elements: [],
  1117. loc: {
  1118. start: {
  1119. line: 1,
  1120. column: 5
  1121. },
  1122. end: {
  1123. line: 1,
  1124. column: 7
  1125. }
  1126. }
  1127. },
  1128. loc: {
  1129. start: {
  1130. line: 1,
  1131. column: 0
  1132. },
  1133. end: {
  1134. line: 1,
  1135. column: 7
  1136. }
  1137. }
  1138. },
  1139. loc: {
  1140. start: {
  1141. line: 1,
  1142. column: 0
  1143. },
  1144. end: {
  1145. line: 1,
  1146. column: 7
  1147. }
  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. test("T‌ = []", {
  1163. type: "Program",
  1164. body: [
  1165. {
  1166. type: "ExpressionStatement",
  1167. expression: {
  1168. type: "AssignmentExpression",
  1169. operator: "=",
  1170. left: {
  1171. type: "Identifier",
  1172. name: "T‌",
  1173. loc: {
  1174. start: {
  1175. line: 1,
  1176. column: 0
  1177. },
  1178. end: {
  1179. line: 1,
  1180. column: 2
  1181. }
  1182. }
  1183. },
  1184. right: {
  1185. type: "ArrayExpression",
  1186. elements: [],
  1187. loc: {
  1188. start: {
  1189. line: 1,
  1190. column: 5
  1191. },
  1192. end: {
  1193. line: 1,
  1194. column: 7
  1195. }
  1196. }
  1197. },
  1198. loc: {
  1199. start: {
  1200. line: 1,
  1201. column: 0
  1202. },
  1203. end: {
  1204. line: 1,
  1205. column: 7
  1206. }
  1207. }
  1208. },
  1209. loc: {
  1210. start: {
  1211. line: 1,
  1212. column: 0
  1213. },
  1214. end: {
  1215. line: 1,
  1216. column: 7
  1217. }
  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. test("T‍ = []", {
  1233. type: "Program",
  1234. body: [
  1235. {
  1236. type: "ExpressionStatement",
  1237. expression: {
  1238. type: "AssignmentExpression",
  1239. operator: "=",
  1240. left: {
  1241. type: "Identifier",
  1242. name: "T‍",
  1243. loc: {
  1244. start: {
  1245. line: 1,
  1246. column: 0
  1247. },
  1248. end: {
  1249. line: 1,
  1250. column: 2
  1251. }
  1252. }
  1253. },
  1254. right: {
  1255. type: "ArrayExpression",
  1256. elements: [],
  1257. loc: {
  1258. start: {
  1259. line: 1,
  1260. column: 5
  1261. },
  1262. end: {
  1263. line: 1,
  1264. column: 7
  1265. }
  1266. }
  1267. },
  1268. loc: {
  1269. start: {
  1270. line: 1,
  1271. column: 0
  1272. },
  1273. end: {
  1274. line: 1,
  1275. column: 7
  1276. }
  1277. }
  1278. },
  1279. loc: {
  1280. start: {
  1281. line: 1,
  1282. column: 0
  1283. },
  1284. end: {
  1285. line: 1,
  1286. column: 7
  1287. }
  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. test("ⅣⅡ = []", {
  1303. type: "Program",
  1304. body: [
  1305. {
  1306. type: "ExpressionStatement",
  1307. expression: {
  1308. type: "AssignmentExpression",
  1309. operator: "=",
  1310. left: {
  1311. type: "Identifier",
  1312. name: "ⅣⅡ",
  1313. loc: {
  1314. start: {
  1315. line: 1,
  1316. column: 0
  1317. },
  1318. end: {
  1319. line: 1,
  1320. column: 2
  1321. }
  1322. }
  1323. },
  1324. right: {
  1325. type: "ArrayExpression",
  1326. elements: [],
  1327. loc: {
  1328. start: {
  1329. line: 1,
  1330. column: 5
  1331. },
  1332. end: {
  1333. line: 1,
  1334. column: 7
  1335. }
  1336. }
  1337. },
  1338. loc: {
  1339. start: {
  1340. line: 1,
  1341. column: 0
  1342. },
  1343. end: {
  1344. line: 1,
  1345. column: 7
  1346. }
  1347. }
  1348. },
  1349. loc: {
  1350. start: {
  1351. line: 1,
  1352. column: 0
  1353. },
  1354. end: {
  1355. line: 1,
  1356. column: 7
  1357. }
  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. test("ⅣⅡ = []", {
  1373. type: "Program",
  1374. body: [
  1375. {
  1376. type: "ExpressionStatement",
  1377. expression: {
  1378. type: "AssignmentExpression",
  1379. operator: "=",
  1380. left: {
  1381. type: "Identifier",
  1382. name: "ⅣⅡ",
  1383. loc: {
  1384. start: {
  1385. line: 1,
  1386. column: 0
  1387. },
  1388. end: {
  1389. line: 1,
  1390. column: 2
  1391. }
  1392. }
  1393. },
  1394. right: {
  1395. type: "ArrayExpression",
  1396. elements: [],
  1397. loc: {
  1398. start: {
  1399. line: 1,
  1400. column: 5
  1401. },
  1402. end: {
  1403. line: 1,
  1404. column: 7
  1405. }
  1406. }
  1407. },
  1408. loc: {
  1409. start: {
  1410. line: 1,
  1411. column: 0
  1412. },
  1413. end: {
  1414. line: 1,
  1415. column: 7
  1416. }
  1417. }
  1418. },
  1419. loc: {
  1420. start: {
  1421. line: 1,
  1422. column: 0
  1423. },
  1424. end: {
  1425. line: 1,
  1426. column: 7
  1427. }
  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. test("x = {}", {
  1443. type: "Program",
  1444. body: [
  1445. {
  1446. type: "ExpressionStatement",
  1447. expression: {
  1448. type: "AssignmentExpression",
  1449. operator: "=",
  1450. left: {
  1451. type: "Identifier",
  1452. name: "x",
  1453. loc: {
  1454. start: {
  1455. line: 1,
  1456. column: 0
  1457. },
  1458. end: {
  1459. line: 1,
  1460. column: 1
  1461. }
  1462. }
  1463. },
  1464. right: {
  1465. type: "ObjectExpression",
  1466. properties: [],
  1467. loc: {
  1468. start: {
  1469. line: 1,
  1470. column: 4
  1471. },
  1472. end: {
  1473. line: 1,
  1474. column: 6
  1475. }
  1476. }
  1477. },
  1478. loc: {
  1479. start: {
  1480. line: 1,
  1481. column: 0
  1482. },
  1483. end: {
  1484. line: 1,
  1485. column: 6
  1486. }
  1487. }
  1488. },
  1489. loc: {
  1490. start: {
  1491. line: 1,
  1492. column: 0
  1493. },
  1494. end: {
  1495. line: 1,
  1496. column: 6
  1497. }
  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. test("x = { }", {
  1513. type: "Program",
  1514. body: [
  1515. {
  1516. type: "ExpressionStatement",
  1517. expression: {
  1518. type: "AssignmentExpression",
  1519. operator: "=",
  1520. left: {
  1521. type: "Identifier",
  1522. name: "x",
  1523. loc: {
  1524. start: {
  1525. line: 1,
  1526. column: 0
  1527. },
  1528. end: {
  1529. line: 1,
  1530. column: 1
  1531. }
  1532. }
  1533. },
  1534. right: {
  1535. type: "ObjectExpression",
  1536. properties: [],
  1537. loc: {
  1538. start: {
  1539. line: 1,
  1540. column: 4
  1541. },
  1542. end: {
  1543. line: 1,
  1544. column: 7
  1545. }
  1546. }
  1547. },
  1548. loc: {
  1549. start: {
  1550. line: 1,
  1551. column: 0
  1552. },
  1553. end: {
  1554. line: 1,
  1555. column: 7
  1556. }
  1557. }
  1558. },
  1559. loc: {
  1560. start: {
  1561. line: 1,
  1562. column: 0
  1563. },
  1564. end: {
  1565. line: 1,
  1566. column: 7
  1567. }
  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. test("x = { answer: 42 }", {
  1583. type: "Program",
  1584. body: [
  1585. {
  1586. type: "ExpressionStatement",
  1587. expression: {
  1588. type: "AssignmentExpression",
  1589. operator: "=",
  1590. left: {
  1591. type: "Identifier",
  1592. name: "x",
  1593. loc: {
  1594. start: {
  1595. line: 1,
  1596. column: 0
  1597. },
  1598. end: {
  1599. line: 1,
  1600. column: 1
  1601. }
  1602. }
  1603. },
  1604. right: {
  1605. type: "ObjectExpression",
  1606. properties: [
  1607. {
  1608. type: "Property",
  1609. key: {
  1610. type: "Identifier",
  1611. name: "answer",
  1612. loc: {
  1613. start: {
  1614. line: 1,
  1615. column: 6
  1616. },
  1617. end: {
  1618. line: 1,
  1619. column: 12
  1620. }
  1621. }
  1622. },
  1623. value: {
  1624. type: "Literal",
  1625. value: 42,
  1626. loc: {
  1627. start: {
  1628. line: 1,
  1629. column: 14
  1630. },
  1631. end: {
  1632. line: 1,
  1633. column: 16
  1634. }
  1635. }
  1636. },
  1637. kind: "init"
  1638. }
  1639. ],
  1640. loc: {
  1641. start: {
  1642. line: 1,
  1643. column: 4
  1644. },
  1645. end: {
  1646. line: 1,
  1647. column: 18
  1648. }
  1649. }
  1650. },
  1651. loc: {
  1652. start: {
  1653. line: 1,
  1654. column: 0
  1655. },
  1656. end: {
  1657. line: 1,
  1658. column: 18
  1659. }
  1660. }
  1661. },
  1662. loc: {
  1663. start: {
  1664. line: 1,
  1665. column: 0
  1666. },
  1667. end: {
  1668. line: 1,
  1669. column: 18
  1670. }
  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. test("x = { if: 42 }", {
  1686. type: "Program",
  1687. body: [
  1688. {
  1689. type: "ExpressionStatement",
  1690. expression: {
  1691. type: "AssignmentExpression",
  1692. operator: "=",
  1693. left: {
  1694. type: "Identifier",
  1695. name: "x",
  1696. loc: {
  1697. start: {
  1698. line: 1,
  1699. column: 0
  1700. },
  1701. end: {
  1702. line: 1,
  1703. column: 1
  1704. }
  1705. }
  1706. },
  1707. right: {
  1708. type: "ObjectExpression",
  1709. properties: [
  1710. {
  1711. type: "Property",
  1712. key: {
  1713. type: "Identifier",
  1714. name: "if",
  1715. loc: {
  1716. start: {
  1717. line: 1,
  1718. column: 6
  1719. },
  1720. end: {
  1721. line: 1,
  1722. column: 8
  1723. }
  1724. }
  1725. },
  1726. value: {
  1727. type: "Literal",
  1728. value: 42,
  1729. loc: {
  1730. start: {
  1731. line: 1,
  1732. column: 10
  1733. },
  1734. end: {
  1735. line: 1,
  1736. column: 12
  1737. }
  1738. }
  1739. },
  1740. kind: "init"
  1741. }
  1742. ],
  1743. loc: {
  1744. start: {
  1745. line: 1,
  1746. column: 4
  1747. },
  1748. end: {
  1749. line: 1,
  1750. column: 14
  1751. }
  1752. }
  1753. },
  1754. loc: {
  1755. start: {
  1756. line: 1,
  1757. column: 0
  1758. },
  1759. end: {
  1760. line: 1,
  1761. column: 14
  1762. }
  1763. }
  1764. },
  1765. loc: {
  1766. start: {
  1767. line: 1,
  1768. column: 0
  1769. },
  1770. end: {
  1771. line: 1,
  1772. column: 14
  1773. }
  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. test("x = { true: 42 }", {
  1789. type: "Program",
  1790. body: [
  1791. {
  1792. type: "ExpressionStatement",
  1793. expression: {
  1794. type: "AssignmentExpression",
  1795. operator: "=",
  1796. left: {
  1797. type: "Identifier",
  1798. name: "x",
  1799. loc: {
  1800. start: {
  1801. line: 1,
  1802. column: 0
  1803. },
  1804. end: {
  1805. line: 1,
  1806. column: 1
  1807. }
  1808. }
  1809. },
  1810. right: {
  1811. type: "ObjectExpression",
  1812. properties: [
  1813. {
  1814. type: "Property",
  1815. key: {
  1816. type: "Identifier",
  1817. name: "true",
  1818. loc: {
  1819. start: {
  1820. line: 1,
  1821. column: 6
  1822. },
  1823. end: {
  1824. line: 1,
  1825. column: 10
  1826. }
  1827. }
  1828. },
  1829. value: {
  1830. type: "Literal",
  1831. value: 42,
  1832. loc: {
  1833. start: {
  1834. line: 1,
  1835. column: 12
  1836. },
  1837. end: {
  1838. line: 1,
  1839. column: 14
  1840. }
  1841. }
  1842. },
  1843. kind: "init"
  1844. }
  1845. ],
  1846. loc: {
  1847. start: {
  1848. line: 1,
  1849. column: 4
  1850. },
  1851. end: {
  1852. line: 1,
  1853. column: 16
  1854. }
  1855. }
  1856. },
  1857. loc: {
  1858. start: {
  1859. line: 1,
  1860. column: 0
  1861. },
  1862. end: {
  1863. line: 1,
  1864. column: 16
  1865. }
  1866. }
  1867. },
  1868. loc: {
  1869. start: {
  1870. line: 1,
  1871. column: 0
  1872. },
  1873. end: {
  1874. line: 1,
  1875. column: 16
  1876. }
  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. test("x = { false: 42 }", {
  1892. type: "Program",
  1893. body: [
  1894. {
  1895. type: "ExpressionStatement",
  1896. expression: {
  1897. type: "AssignmentExpression",
  1898. operator: "=",
  1899. left: {
  1900. type: "Identifier",
  1901. name: "x",
  1902. loc: {
  1903. start: {
  1904. line: 1,
  1905. column: 0
  1906. },
  1907. end: {
  1908. line: 1,
  1909. column: 1
  1910. }
  1911. }
  1912. },
  1913. right: {
  1914. type: "ObjectExpression",
  1915. properties: [
  1916. {
  1917. type: "Property",
  1918. key: {
  1919. type: "Identifier",
  1920. name: "false",
  1921. loc: {
  1922. start: {
  1923. line: 1,
  1924. column: 6
  1925. },
  1926. end: {
  1927. line: 1,
  1928. column: 11
  1929. }
  1930. }
  1931. },
  1932. value: {
  1933. type: "Literal",
  1934. value: 42,
  1935. loc: {
  1936. start: {
  1937. line: 1,
  1938. column: 13
  1939. },
  1940. end: {
  1941. line: 1,
  1942. column: 15
  1943. }
  1944. }
  1945. },
  1946. kind: "init"
  1947. }
  1948. ],
  1949. loc: {
  1950. start: {
  1951. line: 1,
  1952. column: 4
  1953. },
  1954. end: {
  1955. line: 1,
  1956. column: 17
  1957. }
  1958. }
  1959. },
  1960. loc: {
  1961. start: {
  1962. line: 1,
  1963. column: 0
  1964. },
  1965. end: {
  1966. line: 1,
  1967. column: 17
  1968. }
  1969. }
  1970. },
  1971. loc: {
  1972. start: {
  1973. line: 1,
  1974. column: 0
  1975. },
  1976. end: {
  1977. line: 1,
  1978. column: 17
  1979. }
  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. test("x = { null: 42 }", {
  1995. type: "Program",
  1996. body: [
  1997. {
  1998. type: "ExpressionStatement",
  1999. expression: {
  2000. type: "AssignmentExpression",
  2001. operator: "=",
  2002. left: {
  2003. type: "Identifier",
  2004. name: "x",
  2005. loc: {
  2006. start: {
  2007. line: 1,
  2008. column: 0
  2009. },
  2010. end: {
  2011. line: 1,
  2012. column: 1
  2013. }
  2014. }
  2015. },
  2016. right: {
  2017. type: "ObjectExpression",
  2018. properties: [
  2019. {
  2020. type: "Property",
  2021. key: {
  2022. type: "Identifier",
  2023. name: "null",
  2024. loc: {
  2025. start: {
  2026. line: 1,
  2027. column: 6
  2028. },
  2029. end: {
  2030. line: 1,
  2031. column: 10
  2032. }
  2033. }
  2034. },
  2035. value: {
  2036. type: "Literal",
  2037. value: 42,
  2038. loc: {
  2039. start: {
  2040. line: 1,
  2041. column: 12
  2042. },
  2043. end: {
  2044. line: 1,
  2045. column: 14
  2046. }
  2047. }
  2048. },
  2049. kind: "init"
  2050. }
  2051. ],
  2052. loc: {
  2053. start: {
  2054. line: 1,
  2055. column: 4
  2056. },
  2057. end: {
  2058. line: 1,
  2059. column: 16
  2060. }
  2061. }
  2062. },
  2063. loc: {
  2064. start: {
  2065. line: 1,
  2066. column: 0
  2067. },
  2068. end: {
  2069. line: 1,
  2070. column: 16
  2071. }
  2072. }
  2073. },
  2074. loc: {
  2075. start: {
  2076. line: 1,
  2077. column: 0
  2078. },
  2079. end: {
  2080. line: 1,
  2081. column: 16
  2082. }
  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. test("x = { \"answer\": 42 }", {
  2098. type: "Program",
  2099. body: [
  2100. {
  2101. type: "ExpressionStatement",
  2102. expression: {
  2103. type: "AssignmentExpression",
  2104. operator: "=",
  2105. left: {
  2106. type: "Identifier",
  2107. name: "x",
  2108. loc: {
  2109. start: {
  2110. line: 1,
  2111. column: 0
  2112. },
  2113. end: {
  2114. line: 1,
  2115. column: 1
  2116. }
  2117. }
  2118. },
  2119. right: {
  2120. type: "ObjectExpression",
  2121. properties: [
  2122. {
  2123. type: "Property",
  2124. key: {
  2125. type: "Literal",
  2126. value: "answer",
  2127. loc: {
  2128. start: {
  2129. line: 1,
  2130. column: 6
  2131. },
  2132. end: {
  2133. line: 1,
  2134. column: 14
  2135. }
  2136. }
  2137. },
  2138. value: {
  2139. type: "Literal",
  2140. value: 42,
  2141. loc: {
  2142. start: {
  2143. line: 1,
  2144. column: 16
  2145. },
  2146. end: {
  2147. line: 1,
  2148. column: 18
  2149. }
  2150. }
  2151. },
  2152. kind: "init"
  2153. }
  2154. ],
  2155. loc: {
  2156. start: {
  2157. line: 1,
  2158. column: 4
  2159. },
  2160. end: {
  2161. line: 1,
  2162. column: 20
  2163. }
  2164. }
  2165. },
  2166. loc: {
  2167. start: {
  2168. line: 1,
  2169. column: 0
  2170. },
  2171. end: {
  2172. line: 1,
  2173. column: 20
  2174. }
  2175. }
  2176. },
  2177. loc: {
  2178. start: {
  2179. line: 1,
  2180. column: 0
  2181. },
  2182. end: {
  2183. line: 1,
  2184. column: 20
  2185. }
  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. test("x = { x: 1, x: 2 }", {
  2201. type: "Program",
  2202. body: [
  2203. {
  2204. type: "ExpressionStatement",
  2205. expression: {
  2206. type: "AssignmentExpression",
  2207. operator: "=",
  2208. left: {
  2209. type: "Identifier",
  2210. name: "x",
  2211. loc: {
  2212. start: {
  2213. line: 1,
  2214. column: 0
  2215. },
  2216. end: {
  2217. line: 1,
  2218. column: 1
  2219. }
  2220. }
  2221. },
  2222. right: {
  2223. type: "ObjectExpression",
  2224. properties: [
  2225. {
  2226. type: "Property",
  2227. key: {
  2228. type: "Identifier",
  2229. name: "x",
  2230. loc: {
  2231. start: {
  2232. line: 1,
  2233. column: 6
  2234. },
  2235. end: {
  2236. line: 1,
  2237. column: 7
  2238. }
  2239. }
  2240. },
  2241. value: {
  2242. type: "Literal",
  2243. value: 1,
  2244. loc: {
  2245. start: {
  2246. line: 1,
  2247. column: 9
  2248. },
  2249. end: {
  2250. line: 1,
  2251. column: 10
  2252. }
  2253. }
  2254. },
  2255. kind: "init"
  2256. },
  2257. {
  2258. type: "Property",
  2259. key: {
  2260. type: "Identifier",
  2261. name: "x",
  2262. loc: {
  2263. start: {
  2264. line: 1,
  2265. column: 12
  2266. },
  2267. end: {
  2268. line: 1,
  2269. column: 13
  2270. }
  2271. }
  2272. },
  2273. value: {
  2274. type: "Literal",
  2275. value: 2,
  2276. loc: {
  2277. start: {
  2278. line: 1,
  2279. column: 15
  2280. },
  2281. end: {
  2282. line: 1,
  2283. column: 16
  2284. }
  2285. }
  2286. },
  2287. kind: "init"
  2288. }
  2289. ],
  2290. loc: {
  2291. start: {
  2292. line: 1,
  2293. column: 4
  2294. },
  2295. end: {
  2296. line: 1,
  2297. column: 18
  2298. }
  2299. }
  2300. },
  2301. loc: {
  2302. start: {
  2303. line: 1,
  2304. column: 0
  2305. },
  2306. end: {
  2307. line: 1,
  2308. column: 18
  2309. }
  2310. }
  2311. },
  2312. loc: {
  2313. start: {
  2314. line: 1,
  2315. column: 0
  2316. },
  2317. end: {
  2318. line: 1,
  2319. column: 18
  2320. }
  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. test("x = { get width() { return m_width } }", {
  2336. type: "Program",
  2337. body: [
  2338. {
  2339. type: "ExpressionStatement",
  2340. expression: {
  2341. type: "AssignmentExpression",
  2342. operator: "=",
  2343. left: {
  2344. type: "Identifier",
  2345. name: "x",
  2346. loc: {
  2347. start: {
  2348. line: 1,
  2349. column: 0
  2350. },
  2351. end: {
  2352. line: 1,
  2353. column: 1
  2354. }
  2355. }
  2356. },
  2357. right: {
  2358. type: "ObjectExpression",
  2359. properties: [
  2360. {
  2361. type: "Property",
  2362. key: {
  2363. type: "Identifier",
  2364. name: "width",
  2365. loc: {
  2366. start: {
  2367. line: 1,
  2368. column: 10
  2369. },
  2370. end: {
  2371. line: 1,
  2372. column: 15
  2373. }
  2374. }
  2375. },
  2376. kind: "get",
  2377. value: {
  2378. type: "FunctionExpression",
  2379. id: null,
  2380. params: [],
  2381. body: {
  2382. type: "BlockStatement",
  2383. body: [
  2384. {
  2385. type: "ReturnStatement",
  2386. argument: {
  2387. type: "Identifier",
  2388. name: "m_width",
  2389. loc: {
  2390. start: {
  2391. line: 1,
  2392. column: 27
  2393. },
  2394. end: {
  2395. line: 1,
  2396. column: 34
  2397. }
  2398. }
  2399. },
  2400. loc: {
  2401. start: {
  2402. line: 1,
  2403. column: 20
  2404. },
  2405. end: {
  2406. line: 1,
  2407. column: 34
  2408. }
  2409. }
  2410. }
  2411. ],
  2412. loc: {
  2413. start: {
  2414. line: 1,
  2415. column: 18
  2416. },
  2417. end: {
  2418. line: 1,
  2419. column: 36
  2420. }
  2421. }
  2422. },
  2423. loc: {
  2424. start: {
  2425. line: 1,
  2426. column: 15
  2427. },
  2428. end: {
  2429. line: 1,
  2430. column: 36
  2431. }
  2432. }
  2433. }
  2434. }
  2435. ],
  2436. loc: {
  2437. start: {
  2438. line: 1,
  2439. column: 4
  2440. },
  2441. end: {
  2442. line: 1,
  2443. column: 38
  2444. }
  2445. }
  2446. },
  2447. loc: {
  2448. start: {
  2449. line: 1,
  2450. column: 0
  2451. },
  2452. end: {
  2453. line: 1,
  2454. column: 38
  2455. }
  2456. }
  2457. },
  2458. loc: {
  2459. start: {
  2460. line: 1,
  2461. column: 0
  2462. },
  2463. end: {
  2464. line: 1,
  2465. column: 38
  2466. }
  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. test("x = { get undef() {} }", {
  2482. type: "Program",
  2483. body: [
  2484. {
  2485. type: "ExpressionStatement",
  2486. expression: {
  2487. type: "AssignmentExpression",
  2488. operator: "=",
  2489. left: {
  2490. type: "Identifier",
  2491. name: "x",
  2492. loc: {
  2493. start: {
  2494. line: 1,
  2495. column: 0
  2496. },
  2497. end: {
  2498. line: 1,
  2499. column: 1
  2500. }
  2501. }
  2502. },
  2503. right: {
  2504. type: "ObjectExpression",
  2505. properties: [
  2506. {
  2507. type: "Property",
  2508. key: {
  2509. type: "Identifier",
  2510. name: "undef",
  2511. loc: {
  2512. start: {
  2513. line: 1,
  2514. column: 10
  2515. },
  2516. end: {
  2517. line: 1,
  2518. column: 15
  2519. }
  2520. }
  2521. },
  2522. kind: "get",
  2523. value: {
  2524. type: "FunctionExpression",
  2525. id: null,
  2526. params: [],
  2527. body: {
  2528. type: "BlockStatement",
  2529. body: [],
  2530. loc: {
  2531. start: {
  2532. line: 1,
  2533. column: 18
  2534. },
  2535. end: {
  2536. line: 1,
  2537. column: 20
  2538. }
  2539. }
  2540. },
  2541. loc: {
  2542. start: {
  2543. line: 1,
  2544. column: 15
  2545. },
  2546. end: {
  2547. line: 1,
  2548. column: 20
  2549. }
  2550. }
  2551. }
  2552. }
  2553. ],
  2554. loc: {
  2555. start: {
  2556. line: 1,
  2557. column: 4
  2558. },
  2559. end: {
  2560. line: 1,
  2561. column: 22
  2562. }
  2563. }
  2564. },
  2565. loc: {
  2566. start: {
  2567. line: 1,
  2568. column: 0
  2569. },
  2570. end: {
  2571. line: 1,
  2572. column: 22
  2573. }
  2574. }
  2575. },
  2576. loc: {
  2577. start: {
  2578. line: 1,
  2579. column: 0
  2580. },
  2581. end: {
  2582. line: 1,
  2583. column: 22
  2584. }
  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. test("x = { get if() {} }", {
  2600. type: "Program",
  2601. body: [
  2602. {
  2603. type: "ExpressionStatement",
  2604. expression: {
  2605. type: "AssignmentExpression",
  2606. operator: "=",
  2607. left: {
  2608. type: "Identifier",
  2609. name: "x",
  2610. loc: {
  2611. start: {
  2612. line: 1,
  2613. column: 0
  2614. },
  2615. end: {
  2616. line: 1,
  2617. column: 1
  2618. }
  2619. }
  2620. },
  2621. right: {
  2622. type: "ObjectExpression",
  2623. properties: [
  2624. {
  2625. type: "Property",
  2626. key: {
  2627. type: "Identifier",
  2628. name: "if",
  2629. loc: {
  2630. start: {
  2631. line: 1,
  2632. column: 10
  2633. },
  2634. end: {
  2635. line: 1,
  2636. column: 12
  2637. }
  2638. }
  2639. },
  2640. kind: "get",
  2641. value: {
  2642. type: "FunctionExpression",
  2643. id: null,
  2644. params: [],
  2645. body: {
  2646. type: "BlockStatement",
  2647. body: [],
  2648. loc: {
  2649. start: {
  2650. line: 1,
  2651. column: 15
  2652. },
  2653. end: {
  2654. line: 1,
  2655. column: 17
  2656. }
  2657. }
  2658. },
  2659. loc: {
  2660. start: {
  2661. line: 1,
  2662. column: 12
  2663. },
  2664. end: {