├── .gitignore ├── .gitmodules ├── .travis.yml ├── Cargo.toml ├── LAYOUT.md ├── LICENSE ├── README.md ├── benches └── bench.rs ├── build.rs ├── crates ├── binjs_es6 │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── ast.rs │ │ ├── io.rs │ │ ├── lazy.rs │ │ ├── lib.rs │ │ ├── scopes.rs │ │ └── sublanguages.rs ├── binjs_generate_library │ ├── Cargo.toml │ ├── README.md │ ├── examples │ │ └── generate_library.rs │ └── src │ │ └── lib.rs ├── binjs_generic │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── es6.rs │ │ ├── lib.rs │ │ ├── pick.rs │ │ └── util.rs ├── binjs_io │ ├── Cargo.toml │ └── src │ │ ├── binjs_json │ │ ├── mod.rs │ │ ├── read.rs │ │ └── write.rs │ │ ├── bytes │ │ ├── atoms.rs │ │ ├── bool.rs │ │ ├── compress.rs │ │ ├── decoders.rs │ │ ├── float.rs │ │ ├── lengthwriter.rs │ │ ├── mod.rs │ │ ├── serialize.rs │ │ ├── strings.rs │ │ └── varnum.rs │ │ ├── context │ │ ├── format.rs │ │ ├── huffman.rs │ │ ├── mod.rs │ │ ├── strings.rs │ │ └── varnum.rs │ │ ├── entropy │ │ ├── baseline.rs │ │ ├── dictionary.rs │ │ ├── format.rs │ │ ├── mod.rs │ │ ├── predict.rs │ │ ├── probabilities.rs │ │ ├── read │ │ │ ├── content_decoders.rs │ │ │ ├── mod.rs │ │ │ └── prelude_decoders.rs │ │ ├── rw.rs │ │ ├── util.rs │ │ └── write │ │ │ ├── lazy_stream.rs │ │ │ └── mod.rs │ │ ├── escaped_wtf8.rs │ │ ├── io │ │ ├── deprecated.rs │ │ ├── mod.rs │ │ └── statistics.rs │ │ ├── lib.rs │ │ ├── multipart │ │ ├── mod.rs │ │ ├── read.rs │ │ └── write.rs │ │ ├── simple.rs │ │ ├── util.rs │ │ └── xml.rs ├── binjs_meta │ ├── Cargo.toml │ ├── README.md │ ├── examples │ │ └── generate_spidermonkey.rs │ └── src │ │ ├── export.rs │ │ ├── import.rs │ │ ├── lib.rs │ │ ├── spec.rs │ │ └── util.rs └── binjs_shared │ ├── Cargo.toml │ └── src │ ├── ast.rs │ ├── lib.rs │ ├── mru.rs │ └── shared_string.rs ├── doc └── AST.md ├── examples ├── compare_compression.rs ├── generate.rs ├── investigate_streams.rs └── sample_directory.rs ├── fbssdc ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── ast.py ├── bits.py ├── bpy.py ├── encode.py ├── es6.webidl ├── format.py ├── idl.py ├── lazy.py ├── model.py ├── opt.py ├── strings.py ├── test-data │ ├── test.dict │ ├── three.min.js.dump │ ├── y5R7cnYctJv.js.dump │ └── yRA0kDZHvwL.js.dump ├── test.py ├── test.sh └── tycheck.py ├── package-lock.json ├── package.json ├── size_benchmarks ├── README.md ├── earlyflush │ ├── SAMPLE.txt │ ├── ef-2019-01-02 │ │ ├── 1il57kzux4m8oc4s.pkg.js │ │ ├── 29yyovy82e1w8080.pkg.js │ │ ├── 9ah15wskkvgo048c.pkg.js │ │ ├── 9vmkl4636e8kkk80.pkg.js │ │ ├── e1yio9hnu9s008k4.pkg.js │ │ ├── e83irp28nps84kgo.pkg.js │ │ └── eeuzfvmyypwg88o8.pkg.js │ ├── ef-2019-01-03 │ │ ├── 412r6fumc3ok884c.pkg.js │ │ ├── 7xfu0tlqxo08c0co.pkg.js │ │ ├── bvi3lo6qz5cs08sw.pkg.js │ │ ├── e83irp28nps84kgo.pkg.js │ │ └── eeuzfvmyypwg88o8.pkg.js │ ├── ef-2019-01-04 │ │ ├── 412r6fumc3ok884c.pkg.js │ │ ├── 7xfu0tlqxo08c0co.pkg.js │ │ ├── bvi3lo6qz5cs08sw.pkg.js │ │ ├── e83irp28nps84kgo.pkg.js │ │ └── eeuzfvmyypwg88o8.pkg.js │ ├── ef-2019-01-10 │ │ ├── 412r6fumc3ok884c.pkg.js │ │ ├── 8wp8z9inaacc4gcs.pkg.js │ │ ├── cha4l6ro774sssso.pkg.js │ │ ├── e1yio9hnu9s008k4.pkg.js │ │ ├── e83irp28nps84kgo.pkg.js │ │ └── eeuzfvmyypwg88o8.pkg.js │ ├── ef-2019-01-16 │ │ ├── 1nidw2y1glno8so0.pkg.js │ │ ├── 2trfpy2qqwu8o00w.pkg.js │ │ ├── 368qcy0nxnokkw8o.pkg.js │ │ ├── 3z8xi3ob8yuccs80.pkg.js │ │ ├── 412r6fumc3ok884c.pkg.js │ │ ├── 58nuksoao1s0kkwg.pkg.js │ │ ├── 5hwmza7i6ewwg88w.pkg.js │ │ ├── 7vpwwxafdxc0kcko.pkg.js │ │ ├── 8hwej60sc4ws0w8s.pkg.js │ │ ├── 9ns3shgv69s0w8c4.pkg.js │ │ ├── a0qvub32dgoo8kgo.pkg.js │ │ ├── ch23xtf7bjswsgcw.pkg.js │ │ ├── cjiweuf5ixkcogk8.pkg.js │ │ ├── dskz70yeorsok0oo.pkg.js │ │ ├── e9ismbbxu48wwwwk.pkg.js │ │ ├── els9xrlxxm8ss8co.pkg.js │ │ └── f1h86x9tfs0kc8k4.pkg.js │ └── ef-2019-02-01 │ │ ├── 412r6fumc3ok884c.pkg.js │ │ ├── 4l10ng089tkw4cow.pkg.js │ │ ├── 4y3wq56re4soos84.pkg.js │ │ ├── 9nzhl2gksn400ck4.pkg.js │ │ ├── b7ca05ydphwsgwow.pkg.js │ │ └── xrzjeswn5lc84s4w.pkg.js ├── fb_bench_files └── sizes.py ├── spec ├── context.md ├── entropy.md ├── es6-extension.webidl ├── es6.webidl └── old-context.md ├── src ├── bin │ ├── convert_from_json.rs │ ├── decode.rs │ ├── dump.rs │ ├── encode.rs │ └── generate_dictionary.rs ├── lib.rs └── source │ ├── .prettierrc │ ├── codegen.js │ ├── from-shift.js │ ├── mod.rs │ ├── parse_file.js │ ├── parse_str.js │ ├── parser.rs │ ├── shift.rs │ ├── start-json-stream.js │ └── to-shift.js ├── tests ├── data │ ├── facebook │ │ ├── concat.js │ │ └── single │ │ │ ├── 09PWOD-iG7U.js │ │ │ ├── 0FL4yAxztNI.js │ │ │ ├── 0OShvvyv_0H.js │ │ │ ├── 0QMTlI7NH0s.js │ │ │ ├── 0YyVL58RB73.js │ │ │ ├── 0_6_wz_uelN.js │ │ │ ├── 0gVBItN8Q5A.js │ │ │ ├── 0nNPGdaD0nT.js │ │ │ ├── 0z7SVtqevWh.js │ │ │ ├── 10x6WBItZMj.js │ │ │ ├── 13JTyxJ1fHu.js │ │ │ ├── 16RV_DNduLc.js │ │ │ ├── 1E98iSLpnkH.js │ │ │ ├── 1Fs4jyLrDMS.js │ │ │ ├── 1PqKM6bvJiO.js │ │ │ ├── 1Q7Vw4LF2Yr.js │ │ │ ├── 1WkLWwGfQa2.js │ │ │ ├── 1XzqGa3bKC9.js │ │ │ ├── 1YrwUhW-w5Y.js │ │ │ ├── 1eOj1Brg5D4.js │ │ │ ├── 1iFRg9BeNmg.js │ │ │ ├── 1kL74PTQCjO.js │ │ │ ├── 1sUao0c2PEe.js │ │ │ ├── 1vzDGthwISY.js │ │ │ ├── 22K2uaUdQmP.js │ │ │ ├── 26eXFdywVMp.js │ │ │ ├── 2CDhOMRpesE.js │ │ │ ├── 2YodW0RnyTo.js │ │ │ ├── 2cMJ_CbnBwW.js │ │ │ ├── 2qyyFNJaP7C.js │ │ │ ├── 2rIE9zLrbX9.js │ │ │ ├── 2yFnUvKYcZ7.js │ │ │ ├── 3Iqnhvm-T6s.js │ │ │ ├── 3MHDDokKiln.js │ │ │ ├── 3QDMSHmYtRk.js │ │ │ ├── 3cgkC0EM0Qf.js │ │ │ ├── 3uldL8ZjFT8.js │ │ │ ├── 3vNGxNuOcut.js │ │ │ ├── 45TkpKn2ofu.js │ │ │ ├── 4ezU-xdFZQt.js │ │ │ ├── 4zUTiRaESYw.js │ │ │ ├── 5HSUKQwIwZt.js │ │ │ ├── 5IFSfwj8om.js │ │ │ ├── 5KxTRfcMxIH.js │ │ │ ├── 5sRTpHOwAvc.js │ │ │ ├── 5vYiLw_dYIF.js │ │ │ ├── 61p7yiXht2-.js │ │ │ ├── 6JKpDbYzLnb.js │ │ │ ├── 6JZhzyeEuCN.js │ │ │ ├── 6KqUnE7jc9w.js │ │ │ ├── 6O_ojd0SniS.js │ │ │ ├── 6Vy5PMpF0Hg.js │ │ │ ├── 6ZZ10cZ35bZ.js │ │ │ ├── 6a1yJ8iDr5v.js │ │ │ ├── 6d2pPNdw-Fq.js │ │ │ ├── 6hfgpC9ic8F.js │ │ │ ├── 6jeb8HxgHlP.js │ │ │ ├── 794N6IR9E7.js │ │ │ ├── 7BqLUPAKWMh.js │ │ │ ├── 7E0Ot8Dy3-C.js │ │ │ ├── 7HZgnEwNixO.js │ │ │ ├── 7MLXMaSCgdy.js │ │ │ ├── 7PfcIxnQ0TM.js │ │ │ ├── 7SV69-MJz9d.js │ │ │ ├── 7T4iM3nQFrv.js │ │ │ ├── 7W2Y_j7-8XV.js │ │ │ ├── 7d0Fr09BxRl.js │ │ │ ├── 7hz53UCKK6t.js │ │ │ ├── 7nilCjXkDsN.js │ │ │ ├── 7rt70qPQEE4.js │ │ │ ├── 80KtybBJSRq.js │ │ │ ├── 8T10qOu6hA8.js │ │ │ ├── 8YVRjv66YWN.js │ │ │ ├── 8jdRgzkLyxN.js │ │ │ ├── 8vg_aNX2LTW.js │ │ │ ├── 8yfRZjdcRpr.js │ │ │ ├── 90KwH4neHw.js │ │ │ ├── 93De-Q7NIMj.js │ │ │ ├── 93PYB5GrxKi.js │ │ │ ├── 99ZfiTBQjrD.js │ │ │ ├── 9VUoI5Y8zgw.js │ │ │ ├── 9itjkYhSqT7.js │ │ │ ├── 9qcdbQ6N0vz.js │ │ │ ├── A0nTvOA7SMq.js │ │ │ ├── ABozWUlfQQa.js │ │ │ ├── AhZnjAVEyh4.js │ │ │ ├── BSATYrRdEqw.js │ │ │ ├── BVuxfJBYYOy.js │ │ │ ├── BXCJygZcXT7.js │ │ │ ├── Ba5Z-3IbMrL.js │ │ │ ├── BdohC8uCF68.js │ │ │ ├── BhyGRBQE_ho.js │ │ │ ├── C0qPzI366B5.js │ │ │ ├── C4OnEvf_nsQ.js │ │ │ ├── C4ZhzGqwQ96.js │ │ │ ├── CUH2YLmBB-4.js │ │ │ ├── Cq1EP4fUDbJ.js │ │ │ ├── CqyQckU2yo-.js │ │ │ ├── CvrtsqyNpWn.js │ │ │ ├── D4_q4AHaGdu.js │ │ │ ├── DBK4UL3WBG8.js │ │ │ ├── DGbUzkF4VDV.js │ │ │ ├── DJPPrzy7ff0.js │ │ │ ├── DJoMe0pettz.js │ │ │ ├── DKXUXo55mVb.js │ │ │ ├── DMoeyukxtiM.js │ │ │ ├── Dl0PcFY34M0.js │ │ │ ├── Dt-P-nVSHp5.js │ │ │ ├── E6NydFiqMUh.js │ │ │ ├── EHU1s5cIT8a.js │ │ │ ├── EKPd8PWN5Sp.js │ │ │ ├── ES-H08hCe4R.js │ │ │ ├── ESNQ6wg-wVN.js │ │ │ ├── EXzH2oCF_WG.js │ │ │ ├── EenddqKIgxS.js │ │ │ ├── Em3Kwiq345.js │ │ │ ├── EszNqiGd7DO.js │ │ │ ├── F13y1-OWrnG.js │ │ │ ├── FJbKFvWbYaR.js │ │ │ ├── FKhLGLrBw1b.js │ │ │ ├── FMmQ8tLHqBs.js │ │ │ ├── Fd1U8zdftY3.js │ │ │ ├── FhECec447P7.js │ │ │ ├── FkHFmz2MgoW.js │ │ │ ├── FncnEVXq99f.js │ │ │ ├── FrMEaAgWus2.js │ │ │ ├── FtuH2CvvurL.js │ │ │ ├── FxBP7B2sGBz.js │ │ │ ├── G5FY0VSm5rb.js │ │ │ ├── GDWAoyDy3hk.js │ │ │ ├── GIvAi-mB56o.js │ │ │ ├── GMRb_AMn-2p.js │ │ │ ├── GWsQFO08Vaf.js │ │ │ ├── GZCn_tb8T0E.js │ │ │ ├── GbIFnbD5Hv3.js │ │ │ ├── Gj7hCH1JioK.js │ │ │ ├── GjhkPHrsA8I.js │ │ │ ├── Gr9UAc7ZBc_.js │ │ │ ├── Gw9cK2Tuwl9.js │ │ │ ├── Gwob1yTgNVa.js │ │ │ ├── Gzn5CpwLcFS.js │ │ │ ├── H0uohApc3Wi.js │ │ │ ├── H9yXsupYfcw.js │ │ │ ├── HJ9V2pE20_V.js │ │ │ ├── HKfkAAAZWLi.js │ │ │ ├── HNpOKWxxC6P.js │ │ │ ├── HUooP0yYGcn.js │ │ │ ├── HZ7rSN33iS3.js │ │ │ ├── Hckh2Rwyksb.js │ │ │ ├── HixpLV37dk5.js │ │ │ ├── Hn7pnMt7VJh.js │ │ │ ├── Htir4jq4jA2.js │ │ │ ├── IO4DIs8nJvq.js │ │ │ ├── IPYcVQm46mM.js │ │ │ ├── Ic0YY_ezK2_.js │ │ │ ├── Isozbn0R2c4.js │ │ │ ├── J3DZf3he5wl.js │ │ │ ├── JfqV8F6NUEv.js │ │ │ ├── JoKRIsLB0xX.js │ │ │ ├── Jyt80_jhkWr.js │ │ │ ├── K5NL9ldpeQ3.js │ │ │ ├── K66_o184Q7u.js │ │ │ ├── KOF4Tki1I_F.js │ │ │ ├── KjsolWwRYEq.js │ │ │ ├── Kkz0EfPx878.js │ │ │ ├── Ktjd_zCDiuX.js │ │ │ ├── Ktjh1pUNe33.js │ │ │ ├── Kzw0nPC0dcW.js │ │ │ ├── L7jog_bXY11.js │ │ │ ├── LIaBBJHFKhS.js │ │ │ ├── LMWFQY0i5pg.js │ │ │ ├── LNGlQuUqYFf.js │ │ │ ├── LbdkYWnUPHH.js │ │ │ ├── LnPHIQfkPgJ.js │ │ │ ├── LquvhDYHVN_.js │ │ │ ├── M2wrki-9YRq.js │ │ │ ├── M4oEcTjMPIq.js │ │ │ ├── M6KutcQQx1J.js │ │ │ ├── MaQq-zjKQ9b.js │ │ │ ├── Mk-Oc98fTbS.js │ │ │ ├── MwM-eWv6gvY.js │ │ │ ├── N7JSRkYI74q.js │ │ │ ├── N8rUHyk5FDI.js │ │ │ ├── NEMgFJiGr4m.js │ │ │ ├── NP0I7Z0wjpg.js │ │ │ ├── NQRnhW7HDwe.js │ │ │ ├── NhNKyiBLxFg.js │ │ │ ├── NjPxAnvhaki.js │ │ │ ├── Nk1WKHlapUy.js │ │ │ ├── NpdlEKtiuKA.js │ │ │ ├── O0D5wz4enLV.js │ │ │ ├── O4w_IQdYWJc.js │ │ │ ├── OBF7Dw0EY2M.js │ │ │ ├── OTbMrmdj35V.js │ │ │ ├── OfXHPJrGMDY.js │ │ │ ├── P67MB8xnjDM.js │ │ │ ├── PQ2A0ClEJeK.js │ │ │ ├── PRW6RA4PqsI.js │ │ │ ├── PikWb-DRclC.js │ │ │ ├── Q-wSNUwkAAw.js │ │ │ ├── Q0bfmxur30T.js │ │ │ ├── QWha_PeC1CG.js │ │ │ ├── QYPVIGjITMs.js │ │ │ ├── QjHlKARx4Jl.js │ │ │ ├── QnG5Ibr3nN0.js │ │ │ ├── R2saIb6hdbu.js │ │ │ ├── RYStwPOyGt_.js │ │ │ ├── RixyttL2E_J.js │ │ │ ├── RwNV_ZmMYXx.js │ │ │ ├── SEFS3r1PhQT.js │ │ │ ├── SK1wkfeDq_h.js │ │ │ ├── SXpXdn7Gm3h.js │ │ │ ├── SaMs8YKhI12.js │ │ │ ├── Sat5Kefz26k.js │ │ │ ├── Sls0fuKBDLY.js │ │ │ ├── Stwps2pjgwA.js │ │ │ ├── T1SAR34A6Ia.js │ │ │ ├── TG5ISf94Tpi.js │ │ │ ├── TNaDhPViNKe.js │ │ │ ├── TQ2Bb_pkfns.js │ │ │ ├── TRjk530Uq-4.js │ │ │ ├── TWZbP8KTL1Y.js │ │ │ ├── TX5joFGrGzI.js │ │ │ ├── TZauC440LtG.js │ │ │ ├── Tl6W2-vTx42.js │ │ │ ├── TmjxlwXMF5n.js │ │ │ ├── Tn6It5Tj6cj.js │ │ │ ├── TpuLn4b3sfe.js │ │ │ ├── U7Q-LP06v2T.js │ │ │ ├── UG4i5MCq6gc.js │ │ │ ├── UNo8Jh862bD.js │ │ │ ├── US5MebMc5rZ.js │ │ │ ├── UrEYIrNxED2.js │ │ │ ├── V70FxA0Lwxv.js │ │ │ ├── VC34lfZRcL-.js │ │ │ ├── VICqwwD8Kdu.js │ │ │ ├── VJwyx7mgPzM.js │ │ │ ├── VM49E-CNN5.js │ │ │ ├── VZ1-qzzy-qS.js │ │ │ ├── VdWwIQ0QYkA.js │ │ │ ├── VfL_uzuaCDL.js │ │ │ ├── VkGQgXkt7PT.js │ │ │ ├── VlyqIhqDfTj.js │ │ │ ├── VmHp78YPiBO.js │ │ │ ├── VnfzLsPn6WI.js │ │ │ ├── VqKl4ypOdsk.js │ │ │ ├── VzTqr5yULRw.js │ │ │ ├── W26NPhE5J26.js │ │ │ ├── W_OjOIf_p9e.js │ │ │ ├── Wboj_Y1w3Yu.js │ │ │ ├── WdEpJk_Tabb.js │ │ │ ├── WhA-dvAnZjd.js │ │ │ ├── WjlhBpoVp6U.js │ │ │ ├── Wm9D4-HKkyS.js │ │ │ ├── WwrtoTdWMcs.js │ │ │ ├── Wy7ru1prJ9p.js │ │ │ ├── WyHjBg4RHih.js │ │ │ ├── X6ft_Rw2FGg.js │ │ │ ├── X6xoI89q7wL.js │ │ │ ├── X70FmpmPl6U.js │ │ │ ├── X9KwaXAh8OA.js │ │ │ ├── XCZjSu6H2x6.js │ │ │ ├── XCaeFT9FnaM.js │ │ │ ├── XEfmAEzPxw5.js │ │ │ ├── XJJST1rrUzj.js │ │ │ ├── Xajl4Z-HMDd.js │ │ │ ├── XvJRVgBJV33.js │ │ │ ├── XyxjBO0E-Ae.js │ │ │ ├── Y1-O927cK2t.js │ │ │ ├── Y2wwAspvKK7.js │ │ │ ├── YB2lc13pFUI.js │ │ │ ├── YHDRl984zRW.js │ │ │ ├── YJgePE2Auby.js │ │ │ ├── YUkQ93LjurT.js │ │ │ ├── Yg3McEltNjp.js │ │ │ ├── YjDPNITqxhG.js │ │ │ ├── Z14o104Q29.js │ │ │ ├── Z2Kbh46LXZZ.js │ │ │ ├── Z5QGTLkc9kz.js │ │ │ ├── ZOeRtUIf90F.js │ │ │ ├── ZZfnEdoRgj0.js │ │ │ ├── ZbAYJatCyNZ.js │ │ │ ├── _0Gjqmw4Koo.js │ │ │ ├── _3UqloxC0CW.js │ │ │ ├── _5tA9NCCPxQ.js │ │ │ ├── _HRTS9FAj70.js │ │ │ ├── _Kp2t1yMvG5.js │ │ │ ├── _obLyhmNwMA.js │ │ │ ├── _poPb23m2lW.js │ │ │ ├── a1OMwkLkxJy.js │ │ │ ├── a4sxR7Xqudt.js │ │ │ ├── aCUxlUPri-u.js │ │ │ ├── aCkKlOuYdAY.js │ │ │ ├── aVmpARAebEj.js │ │ │ ├── afJUg3Oi2lo.js │ │ │ ├── ahTNFjdbHPj.js │ │ │ ├── akZ6romKPXS.js │ │ │ ├── aoGTCgaRyfh.js │ │ │ ├── bj2quEws0mS.js │ │ │ ├── bjY7glcVhij.js │ │ │ ├── bkspEohDWXI.js │ │ │ ├── bujNxQtqJfH.js │ │ │ ├── c0Qh0douchE.js │ │ │ ├── c4s5MUgdk4p.js │ │ │ ├── cEJxYmeVQFY.js │ │ │ ├── cLLmKH52bRw.js │ │ │ ├── cM2rbC5wYIj.js │ │ │ ├── ctOKVDJPRdx.js │ │ │ ├── d1P6nQfYXKD.js │ │ │ ├── d3u2FAOQCGP.js │ │ │ ├── dQuPAucPva9.js │ │ │ ├── dhzIxMhJmUQ.js │ │ │ ├── dijW0z0ucm-.js │ │ │ ├── dr6aBMYM2V2.js │ │ │ ├── drJc7buhOtE.js │ │ │ ├── e7ra_72iXdV.js │ │ │ ├── eIJD4bQ5h-1.js │ │ │ ├── eZjQt87u8t1.js │ │ │ ├── eop6dvOMLTq.js │ │ │ ├── f2TlpbviZca.js │ │ │ ├── f53VGV2iT0I.js │ │ │ ├── fB_MiIP7NHd.js │ │ │ ├── fG-u4hmOE3Q.js │ │ │ ├── fLczu6LzRHG.js │ │ │ ├── fNXDCJu-V4g.js │ │ │ ├── fSg_zxv_Kod.js │ │ │ ├── fVXETrH3Cq8.js │ │ │ ├── fW2Il-BeJSj.js │ │ │ ├── fws9yWG1beh.js │ │ │ ├── g-8q9Q5HAct.js │ │ │ ├── gDiLJ3Nh5Qk.js │ │ │ ├── gKycf5rW4sU.js │ │ │ ├── gN5Uk4UvOZT.js │ │ │ ├── gV8VMvIotf7.js │ │ │ ├── gvMgr3QKvQ8.js │ │ │ ├── gvv_dhImewC.js │ │ │ ├── h-DmjvKXmR3.js │ │ │ ├── hNVa87u4kKS.js │ │ │ ├── hZKxYrkgzm4.js │ │ │ ├── hba0DhGeB63.js │ │ │ ├── hgw22H68N_l.js │ │ │ ├── hrAa4KpUxy3.js │ │ │ ├── huzeXy9rojb.js │ │ │ ├── i-G9J9_yx_.js │ │ │ ├── i-WhEfiHI2C.js │ │ │ ├── i0Ny6SirQCR.js │ │ │ ├── i1qU3JKPcMP.js │ │ │ ├── i6YOUjNhJvc.js │ │ │ ├── iEgP7Vv3MrH.js │ │ │ ├── iIIyGDRwUkJ.js │ │ │ ├── iLiXoQia_Hl.js │ │ │ ├── iOxfHlfLzMO.js │ │ │ ├── iVpq6no1sbf.js │ │ │ ├── ibLV5-CufiC.js │ │ │ ├── ie0_9cKR_JF.js │ │ │ ├── igvPVIqEFTP.js │ │ │ ├── jbEWliZOUvS.js │ │ │ ├── jgEfwJ3Zhg9.js │ │ │ ├── joglmeAu8Qv.js │ │ │ ├── jtWi6ZdW2bb.js │ │ │ ├── kKvdSscVFrv.js │ │ │ ├── kPs479ufKyg.js │ │ │ ├── kZto1c9w8wC.js │ │ │ ├── kfpHN646tDg.js │ │ │ ├── lVlq0lDwsF8.js │ │ │ ├── lVt5GmUyc2l.js │ │ │ ├── lg3_xIkYYKW.js │ │ │ ├── llDDV2rQ1Rz.js │ │ │ ├── lqQs_yLOe3X.js │ │ │ ├── mCXECSTwhF8.js │ │ │ ├── mWseK_aEOAs.js │ │ │ ├── mcqy6o0Vfti.js │ │ │ ├── mtYekkRCibq.js │ │ │ ├── n9Nfrfb5B_x.js │ │ │ ├── nI5PnHjEJyf.js │ │ │ ├── nMMjSesfBr4.js │ │ │ ├── nsO8_i4Z7F5.js │ │ │ ├── o7BSlkO7w7m.js │ │ │ ├── o7G0EczmD-6.js │ │ │ ├── o7wHnb8FJMh.js │ │ │ ├── oBpvYNZ2__3.js │ │ │ ├── oPUD9dTegEK.js │ │ │ ├── ocuLS-3Ixa4.js │ │ │ ├── odqwSDzA1Jh.js │ │ │ ├── op6CSGtgdwj.js │ │ │ ├── p4ThgvBjGnC.js │ │ │ ├── pDkCdAFgfot.js │ │ │ ├── pJi5pUFExsr.js │ │ │ ├── q1aykcXg1rv.js │ │ │ ├── q77Ec0mnQGL.js │ │ │ ├── q7gCUANZcPB.js │ │ │ ├── q9l7bWgIkZv.js │ │ │ ├── qH44GCO2FNp.js │ │ │ ├── qMTnOD4x9ke.js │ │ │ ├── qWlf3ZNfI4H.js │ │ │ ├── q_nM_ysfdDG.js │ │ │ ├── qbjgvCcmoa9.js │ │ │ ├── qwqtBhLzQ8Y.js │ │ │ ├── qzNly4KQTtU.js │ │ │ ├── r37ueZKpGKr.js │ │ │ ├── rL4GrOjmDqx.js │ │ │ ├── rc8ZmQFeS-7.js │ │ │ ├── rcq57bhogFy.js │ │ │ ├── rlnOA5ljgx-.js │ │ │ ├── sDDEkC3xfE8.js │ │ │ ├── sON6H-TQTSe.js │ │ │ ├── sa9HdQH-ogl.js │ │ │ ├── su4qR9fQIup.js │ │ │ ├── szg5Oa3h81p.js │ │ │ ├── t6u1v8nErjo.js │ │ │ ├── tJSUYmYnSG7.js │ │ │ ├── tPmvSn_H54o.js │ │ │ ├── tTkC-lq6BfZ.js │ │ │ ├── t_FKyKc7pIv.js │ │ │ ├── tia2K7wPxLm.js │ │ │ ├── tjI9cfQd8sN.js │ │ │ ├── tyuO9ARb66s.js │ │ │ ├── uH6g_g6fsUY.js │ │ │ ├── uHyvALTm4SZ.js │ │ │ ├── uMjfl_iCR.js │ │ │ ├── uil7OtZB_-S.js │ │ │ ├── ujVr5juu70U.js │ │ │ ├── unVYcbptooG.js │ │ │ ├── v-e81b_ymxI.js │ │ │ ├── v7nEa2wTc3k.js │ │ │ ├── v8xeS_mshuc.js │ │ │ ├── vJA96NEnKK9.js │ │ │ ├── vYjO33iDmup.js │ │ │ ├── v_23FSndsFZ.js │ │ │ ├── vdc-skgedI5.js │ │ │ ├── vrkEs5HVSSU.js │ │ │ ├── w04cnnPb3Tg.js │ │ │ ├── w4Vt3niBWH1.js │ │ │ ├── wTxM8iBz3c2.js │ │ │ ├── wfQF2RfxAkc.js │ │ │ ├── whJhzNwHJHe.js │ │ │ ├── x2UpV3umnzT.js │ │ │ ├── x4eLrd85LUN.js │ │ │ ├── x6-eCrmd1V9.js │ │ │ ├── xBmgk_xc-wG.js │ │ │ ├── xJS31ptCQbq.js │ │ │ ├── xMrUJfyTCUg.js │ │ │ ├── xRT6_TBJBkw.js │ │ │ ├── xZNnvjL182T.js │ │ │ ├── x_EKm-Adi7Q.js │ │ │ ├── xdlg631Qxdp.js │ │ │ ├── xkpiQ5LiVoI.js │ │ │ ├── xo_xIOh_juS.js │ │ │ ├── xsyj3Z3mAiS.js │ │ │ ├── y-05tHqVj8P.js │ │ │ ├── y5R7cnYctJv.js │ │ │ ├── yKclkKsDE2H.js │ │ │ ├── yRA0kDZHvwL.js │ │ │ ├── y_L9TziFm87.js │ │ │ ├── ydXXbqxw_8l.js │ │ │ ├── ynWyXLLi-Ij.js │ │ │ ├── zC72O8ihM25.js │ │ │ ├── zXID_s3O-Wa.js │ │ │ ├── zlhcYuPRsUE.js │ │ │ ├── zm0DxINWRmX.js │ │ │ ├── zuCQsug4SlJ.js │ │ │ └── zxjnIvNA5Hu.js │ ├── frameworks │ │ ├── angular.1.6.5.min.js │ │ ├── backbone.1.3.3.min.js │ │ ├── bootstrap.4.1.0.min.js │ │ ├── chart.2.7.2.min.js │ │ ├── ember.2.18.2.min.js │ │ ├── foundation.6.4.3.min.js │ │ ├── jquery.3.3.1.min.js │ │ ├── moment.2.22.1.min.js │ │ ├── polymer.0.5.6.min.js │ │ ├── react-dom.production.16.3.2.min.js │ │ ├── react.production.16.3.2.min.js │ │ ├── riot.3.9.3.min.js │ │ └── vue.2.5.16.min.js │ ├── json │ │ ├── crash-stats.mozilla.com.json │ │ ├── debian.json │ │ └── generated.json │ ├── misc │ │ ├── lone-surrogate.js │ │ └── test.a.b.c.d.js │ ├── scope │ │ ├── argument_and_var.js │ │ ├── catch_collision.js │ │ ├── catch_collision_2.js │ │ ├── catch_implicit.js │ │ ├── eval_fake.js │ │ ├── eval_fake_2.js │ │ ├── eval_fake_in_function.js │ │ ├── eval_in_function.js │ │ ├── eval_simple.js │ │ ├── function_declaration.js │ │ ├── function_expression.js │ │ ├── getter_setter_scope.js │ │ ├── let_in_fun.js │ │ ├── object_literal.js │ │ ├── simple_function_declaration.js │ │ ├── toplevel_var.js │ │ ├── var_in_fun.js │ │ └── var_in_fun_plus_arg.js │ └── spidermonkey │ │ └── ecma_2 │ │ ├── Exceptions │ │ ├── boolean-001.js │ │ ├── boolean-002.js │ │ ├── browser.js │ │ ├── date-002.js │ │ ├── date-003.js │ │ ├── date-004.js │ │ ├── exception-001.js │ │ ├── exception-002.js │ │ ├── exception-003.js │ │ ├── exception-004.js │ │ ├── exception-005.js │ │ ├── exception-006.js │ │ ├── exception-007.js │ │ ├── exception-008.js │ │ ├── exception-009.js │ │ ├── exception-010-n.js │ │ ├── exception-011-n.js │ │ ├── expression-001.js │ │ ├── expression-002.js │ │ ├── expression-003.js │ │ ├── expression-004.js │ │ ├── expression-005.js │ │ ├── expression-006.js │ │ ├── expression-007.js │ │ ├── expression-008.js │ │ ├── expression-009.js │ │ ├── expression-010.js │ │ ├── expression-011.js │ │ ├── expression-012.js │ │ ├── expression-013.js │ │ ├── expression-014.js │ │ ├── expression-015.js │ │ ├── expression-016.js │ │ ├── expression-017.js │ │ ├── expression-019.js │ │ ├── function-001.js │ │ ├── global-001.js │ │ ├── global-002.js │ │ ├── lexical-001.js │ │ ├── lexical-002.js │ │ ├── lexical-003.js │ │ ├── lexical-004.js │ │ ├── lexical-005.js │ │ ├── lexical-006.js │ │ ├── lexical-007.js │ │ ├── lexical-008.js │ │ ├── lexical-009.js │ │ ├── lexical-011.js │ │ ├── lexical-012.js │ │ ├── lexical-013.js │ │ ├── lexical-014.js │ │ ├── lexical-015.js │ │ ├── lexical-016.js │ │ ├── lexical-017.js │ │ ├── lexical-018.js │ │ ├── lexical-019.js │ │ ├── lexical-020.js │ │ ├── lexical-021.js │ │ ├── lexical-023.js │ │ ├── lexical-024.js │ │ ├── lexical-025.js │ │ ├── lexical-026.js │ │ ├── lexical-027.js │ │ ├── lexical-028.js │ │ ├── lexical-029.js │ │ ├── lexical-030.js │ │ ├── lexical-031.js │ │ ├── lexical-032.js │ │ ├── lexical-033.js │ │ ├── lexical-034.js │ │ ├── lexical-035.js │ │ ├── lexical-036.js │ │ ├── lexical-037.js │ │ ├── lexical-038.js │ │ ├── lexical-039.js │ │ ├── lexical-040.js │ │ ├── lexical-041.js │ │ ├── lexical-042.js │ │ ├── lexical-047.js │ │ ├── lexical-048.js │ │ ├── lexical-049.js │ │ ├── lexical-050.js │ │ ├── lexical-051.js │ │ ├── lexical-052.js │ │ ├── lexical-053.js │ │ ├── lexical-054.js │ │ ├── number-001.js │ │ ├── number-002.js │ │ ├── number-003.js │ │ ├── shell.js │ │ ├── statement-001.js │ │ ├── statement-002.js │ │ ├── statement-003.js │ │ ├── statement-004.js │ │ ├── statement-005.js │ │ ├── statement-006.js │ │ ├── statement-007.js │ │ ├── statement-008.js │ │ ├── statement-009.js │ │ ├── string-001.js │ │ └── string-002.js │ │ ├── Expressions │ │ ├── StrictEquality-001.js │ │ ├── browser.js │ │ └── shell.js │ │ ├── FunctionObjects │ │ ├── apply-001-n.js │ │ ├── browser.js │ │ ├── call-1.js │ │ └── shell.js │ │ ├── LexicalConventions │ │ ├── browser.js │ │ ├── keywords-001.js │ │ ├── regexp-literals-001.js │ │ ├── regexp-literals-002.js │ │ └── shell.js │ │ ├── README │ │ ├── RegExp │ │ ├── browser.js │ │ ├── constructor-001.js │ │ ├── exec-002.js │ │ ├── hex-001.js │ │ ├── multiline-001.js │ │ ├── octal-001.js │ │ ├── octal-002.js │ │ ├── octal-003.js │ │ ├── properties-001.js │ │ ├── properties-002.js │ │ ├── regexp-enumerate-001.js │ │ ├── regress-001.js │ │ ├── shell.js │ │ └── unicode-001.js │ │ ├── Statements │ │ ├── browser.js │ │ ├── dowhile-001.js │ │ ├── dowhile-002.js │ │ ├── dowhile-003.js │ │ ├── dowhile-004.js │ │ ├── dowhile-005.js │ │ ├── dowhile-006.js │ │ ├── dowhile-007.js │ │ ├── forin-001.js │ │ ├── forin-002.js │ │ ├── if-001.js │ │ ├── label-001.js │ │ ├── label-002.js │ │ ├── label-003.js │ │ ├── shell.js │ │ ├── switch-001.js │ │ ├── switch-002.js │ │ ├── switch-003.js │ │ ├── switch-004.js │ │ ├── try-001.js │ │ ├── try-003.js │ │ ├── try-004.js │ │ ├── try-005.js │ │ ├── try-006.js │ │ ├── try-007.js │ │ ├── try-008.js │ │ ├── try-009.js │ │ ├── try-010.js │ │ ├── try-012.js │ │ ├── while-001.js │ │ ├── while-002.js │ │ ├── while-003.js │ │ └── while-004.js │ │ ├── String │ │ ├── browser.js │ │ ├── match-001.js │ │ ├── match-002.js │ │ ├── match-003.js │ │ ├── match-004.js │ │ ├── shell.js │ │ ├── split-001.js │ │ ├── split-002.js │ │ └── split-003.js │ │ ├── browser.js │ │ ├── extensions │ │ ├── browser.js │ │ ├── constructor-001.js │ │ ├── function-001.js │ │ ├── instanceof-001.js │ │ ├── instanceof-002.js │ │ ├── instanceof-003-n.js │ │ ├── instanceof-004-n.js │ │ ├── instanceof-005-n.js │ │ ├── instanceof-006.js │ │ └── shell.js │ │ ├── instanceof │ │ ├── browser.js │ │ ├── instanceof-001.js │ │ ├── instanceof-002.js │ │ ├── instanceof-003.js │ │ ├── regress-7635.js │ │ └── shell.js │ │ ├── shell.js │ │ └── template.js ├── test_dictionary_builder.rs ├── test_external_roundtrip.rs ├── test_paths.rs └── test_roundtrip.rs └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | **/*.rs.bk 3 | Cargo.lock 4 | node_modules/ 5 | *~ 6 | **/.DS_Store 7 | .vscode/ 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/.gitmodules -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - language: rust 4 | cache: 5 | - npm 6 | - cargo 7 | before_script: 8 | - rustup component add rustfmt 9 | script: 10 | - cargo fmt --all -- --check 11 | - cargo build --verbose 12 | - cargo test --all -- --nocapture 13 | rust: 14 | - stable 15 | node_js: 16 | - node 17 | deploy: 18 | # Generate documentation 19 | - provider: script 20 | skip_cleanup: true 21 | script: 22 | - rustup install nightly && cargo +nightly doc --features "unstable" 23 | on: 24 | branch: master 25 | # Deploy documentation 26 | - provider: pages 27 | skip_cleanup: true 28 | github_token: $GITHUB_TOKEN # Belongs to binast-bot. Set in the Travis settings page of the repo. 29 | keep_history: false 30 | local_dir: target/doc 31 | on: 32 | branch: master 33 | 34 | - language: python 35 | dist: xenial 36 | python: 37 | - "3.7" 38 | script: cd ./fbssdc && ./test.py && ./test.sh 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 The binjs-ref developers 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | 27 | === 28 | 29 | This license does not cover some third-party test suites. 30 | -------------------------------------------------------------------------------- /benches/bench.rs: -------------------------------------------------------------------------------- 1 | //! Encode a BinJS, then decode it, ensure that we obtain the same AST. 2 | 3 | #[macro_use] 4 | extern crate bencher; 5 | extern crate binjs; 6 | 7 | #[macro_use] 8 | extern crate lazy_static; 9 | 10 | use binjs::source::*; 11 | 12 | const PATHS: &[&str] = &["tests/data/frameworks/angular.1.6.5.min.js"]; 13 | 14 | fn launch_shift() -> Shift { 15 | Shift::try_new().expect("Could not launch Shift") 16 | } 17 | 18 | lazy_static! { 19 | static ref SHIFT: Shift = launch_shift(); 20 | } 21 | 22 | fn bench_parsing_one_parser_per_run(bencher: &mut bencher::Bencher) { 23 | bench_parsing_aux(None, bencher); 24 | } 25 | 26 | fn bench_parsing_reuse_parser(bencher: &mut bencher::Bencher) { 27 | bench_parsing_aux(Some(&SHIFT), bencher); 28 | } 29 | 30 | fn bench_parsing_aux(parser: Option<&Shift>, bencher: &mut bencher::Bencher) { 31 | bencher.iter(move || { 32 | for &path in PATHS { 33 | let shift; 34 | 35 | bencher::black_box( 36 | match parser { 37 | Some(parser) => parser, 38 | None => { 39 | shift = launch_shift(); 40 | &shift 41 | } 42 | } 43 | .parse_file(path) 44 | .expect("Could not parse source"), 45 | ); 46 | } 47 | }); 48 | } 49 | 50 | benchmark_group!( 51 | bench, 52 | bench_parsing_one_parser_per_run, 53 | bench_parsing_reuse_parser 54 | ); 55 | benchmark_main!(bench); 56 | -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | extern crate which; 2 | 3 | use std::process::Command; 4 | use which::which; 5 | 6 | const PATH_PACKAGES: &'static str = "package.json"; 7 | 8 | fn main() { 9 | // Install Node packages if necessary. 10 | println!("cargo:rerun-if-changed={}", PATH_PACKAGES); 11 | 12 | let tool = which("yarn") 13 | .or_else(|_| which("npm")) 14 | .expect("Could not find neither `yarn` nor `npm`"); 15 | 16 | let status = Command::new(tool).arg("install").status().unwrap(); 17 | 18 | assert!(status.success()); 19 | } 20 | -------------------------------------------------------------------------------- /crates/binjs_es6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "binjs_es6" 3 | version = "0.2.1" 4 | authors = ["David Teller "] 5 | build = "build.rs" 6 | 7 | [dependencies] 8 | assert_matches = "^1.0" 9 | binjs_io = { path = "../binjs_io/", version = "*" } 10 | binjs_shared = { path = "../binjs_shared/", version = "*" } 11 | clap = "^2" 12 | itertools = "^0.8" 13 | serde = { version = "^1.0", features = ["derive"] } 14 | log = "^0.4" 15 | 16 | [build-dependencies] 17 | binjs_generate_library = { path = "../binjs_generate_library/", version = "*" } 18 | binjs_meta = { path = "../binjs_meta/", version = "*" } 19 | -------------------------------------------------------------------------------- /crates/binjs_es6/src/ast.rs: -------------------------------------------------------------------------------- 1 | include!(concat!(env!("OUT_DIR"), "/ast.rs")); 2 | -------------------------------------------------------------------------------- /crates/binjs_generate_library/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "binjs_generate_library" 3 | version = "0.2.0" 4 | authors = ["David Teller "] 5 | 6 | [dependencies] 7 | binjs_meta = { path = "../binjs_meta/", version = "*" } 8 | itertools = "^0.8" 9 | 10 | [dev-dependencies] 11 | env_logger = "0.7.1" 12 | log = "^0.4" 13 | clap = "^2.0" 14 | yaml-rust = "^0.4" 15 | -------------------------------------------------------------------------------- /crates/binjs_generate_library/README.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | This crate defines a library to generate Rust AST & parsing code from a Spec. -------------------------------------------------------------------------------- /crates/binjs_generic/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "binjs_generic" 3 | version = "0.1.2" 4 | authors = ["David Teller "] 5 | build = "build.rs" 6 | 7 | [features] 8 | # An implementation of compression that divides data across several streams 9 | # in an attempt to make it easier to compress. 10 | # 11 | # Experimental, probably deprecated. 12 | multistream = [] 13 | 14 | [dependencies] 15 | binjs_meta = { path = "../binjs_meta", version = "*" } 16 | serde_json = { version = "^1.0.38", features = ["unbounded_depth"] } 17 | rand = "0.7.3" 18 | 19 | [build-dependencies] 20 | binjs_generate_library = { path = "../binjs_generate_library", version = "*" } 21 | binjs_meta = { path = "../binjs_meta", version = "*" } 22 | -------------------------------------------------------------------------------- /crates/binjs_generic/src/es6.rs: -------------------------------------------------------------------------------- 1 | include!(concat!(env!("OUT_DIR"), "/es6.rs")); 2 | -------------------------------------------------------------------------------- /crates/binjs_generic/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! A crate containing tools to manipulate ASTs in generic (i.e. JSON) 2 | //! format. 3 | 4 | extern crate binjs_meta; 5 | 6 | extern crate rand; 7 | extern crate serde_json; 8 | 9 | /// Generic instance of `Spec` representing the es6 AST. 10 | pub mod es6; 11 | 12 | /// Generating random ASTs (for fuzzing purposes). 13 | pub mod pick; 14 | 15 | /// Walkers, comparisons. 16 | pub mod util; 17 | -------------------------------------------------------------------------------- /crates/binjs_generic/src/util.rs: -------------------------------------------------------------------------------- 1 | /// Return a random item from a slice. 2 | pub fn pick<'a, T: rand::Rng, U>(rng: &mut T, slice: &'a [U]) -> &'a U { 3 | let index = rng.gen_range(0, slice.len()); 4 | &slice[index] 5 | } 6 | -------------------------------------------------------------------------------- /crates/binjs_io/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "binjs_io" 3 | version = "0.2.0" 4 | authors = ["David Teller "] 5 | 6 | [dependencies] 7 | bincode = "^1.0" 8 | binjs_meta = { path = "../binjs_meta", version = "*" } 9 | binjs_shared = { path = "../binjs_shared", version = "*" } 10 | brotli = "^3.0" 11 | clap = "^2.32" 12 | derive_more = "0.99.3" 13 | flate2 = "^1.0" 14 | itertools = "^0.8" 15 | serde_json = { version = "^1.0.38", features = ["unbounded_depth"] } 16 | lzw = "^0.10" 17 | log = "^0.4" 18 | rand = "0.7.3" 19 | range-encoding = "^0.2" 20 | serde = { version = "^1.0", features = ["derive", "rc"] } 21 | smallvec = "1.2.0" 22 | vec_map = "^0.8" 23 | xml-rs = "^0.8" 24 | 25 | [dev-dependencies] 26 | env_logger = "0.7.1" 27 | tempdir = "^0.3" 28 | 29 | [features] 30 | default = [] 31 | 32 | # If specified, activate features that require Nightly only compiler features. 33 | # 34 | # At the time of this writing, this affects only documentation generation. 35 | unstable = [] 36 | -------------------------------------------------------------------------------- /crates/binjs_io/src/bytes/bool.rs: -------------------------------------------------------------------------------- 1 | pub fn bytes_of_bool(data: Option) -> [u8; 1] { 2 | match data { 3 | None => [2], 4 | Some(true) => [1], 5 | Some(false) => [0], 6 | } 7 | } 8 | 9 | pub fn bool_of_bytes(buf: &[u8; 1]) -> Result, ()> { 10 | match buf[0] { 11 | 0 => Ok(Some(false)), 12 | 1 => Ok(Some(true)), 13 | 2 => Ok(None), 14 | _ => Err(()), 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/binjs_io/src/bytes/lengthwriter.rs: -------------------------------------------------------------------------------- 1 | pub use io::statistics::Bytes; 2 | 3 | use std::io::{Error, Write}; 4 | 5 | /// An implementation of `Write` that discards its data but remembers 6 | /// how many bytes were written. 7 | #[derive(Default)] 8 | pub struct LengthWriter { 9 | bytes_written: usize, 10 | } 11 | impl LengthWriter { 12 | /// Create an empty LengthWriter. 13 | pub fn new() -> Self { 14 | LengthWriter { bytes_written: 0 } 15 | } 16 | 17 | /// Return the number of bytes written since creation. 18 | pub fn len(&self) -> Bytes { 19 | self.bytes_written.into() 20 | } 21 | } 22 | 23 | impl Write for LengthWriter { 24 | /// Do nothing. 25 | fn flush(&mut self) -> Result<(), Error> { 26 | Ok(()) 27 | } 28 | 29 | /// Pretend to successfully write bytes, only record the number 30 | /// of bytes meant to be written. 31 | fn write(&mut self, buf: &[u8]) -> Result { 32 | self.bytes_written += buf.len(); 33 | Ok(buf.len()) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /crates/binjs_io/src/bytes/mod.rs: -------------------------------------------------------------------------------- 1 | //! Tools for manipulating byte-level data. 2 | 3 | /// Encoding/decoding booleans. 4 | pub mod bool; 5 | 6 | /// Compressing/decompressing from/to common formats. 7 | pub mod compress; 8 | 9 | /// Decoders for streams of floats, etc. 10 | pub mod decoders; 11 | 12 | /// Encoding/decoding floating-point numbers. 13 | pub mod float; 14 | 15 | /// Determining the length of a stream without actually writing/storing data. 16 | pub mod lengthwriter; 17 | 18 | /// Serializing/deserializing traits. 19 | pub mod serialize; 20 | 21 | /// String utilities. 22 | pub mod strings; 23 | 24 | /// Encoding/decoding variable-length numbers. 25 | pub mod varnum; 26 | -------------------------------------------------------------------------------- /crates/binjs_io/src/bytes/serialize.rs: -------------------------------------------------------------------------------- 1 | use std::io::{Error, Read, Seek, Write}; 2 | 3 | pub trait Serializer 4 | where 5 | T: Sized, 6 | { 7 | fn write(&mut self, data: &T, &mut W) -> Result<(), Error>; 8 | } 9 | 10 | /// A value that may be deserialized from bytes, optionally decompressed. 11 | pub trait Deserializer 12 | where 13 | Self::Target: Sized, 14 | { 15 | type Target; 16 | fn read(&self, &mut R) -> Result; 17 | } 18 | -------------------------------------------------------------------------------- /crates/binjs_io/src/bytes/strings.rs: -------------------------------------------------------------------------------- 1 | use std::io::Cursor; 2 | 3 | /// Utility: An extension of `Read` that reads `bytes` bytes and attempts 4 | /// to convert them into a string. 5 | pub trait ReadStr { 6 | fn read_string(&mut self, bytes: usize) -> Result; 7 | } 8 | impl ReadStr for Cursor> { 9 | fn read_string(&mut self, bytes: usize) -> Result { 10 | use std::io::*; 11 | let mut buf = Vec::with_capacity(bytes); 12 | unsafe { 13 | buf.set_len(bytes); 14 | } 15 | self.read_exact(&mut buf)?; 16 | let result = String::from_utf8(buf) 17 | .map_err(|_| Error::new(ErrorKind::InvalidData, "Invalid UTF-8 data"))?; 18 | Ok(result) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /crates/binjs_io/src/context/format.rs: -------------------------------------------------------------------------------- 1 | // Fake module. This is only a placeholder for documentation. 2 | 3 | // As of this writing, doc inclusion only works on Nightly compiler. 4 | #![cfg_attr(feature = "unstable", doc(include = "../../../../spec/context.md"))] 5 | 6 | #![cfg_attr(not(feature = "unstable"), doc = "To generate the format spec documentation, please use `cargo doc --features unstable`. This requires Rust Nightly.")] 7 | -------------------------------------------------------------------------------- /crates/binjs_io/src/context/mod.rs: -------------------------------------------------------------------------------- 1 | //! Encoding/decoding based on Huffman tables. 2 | #![allow(dead_code)] // Silence dead code warnings until they make sense. 3 | 4 | /// Format documentation. 5 | pub mod format; 6 | mod huffman; 7 | mod strings; 8 | mod varnum; 9 | 10 | /// A four-char name embedded in the binary. 11 | /// 12 | /// This may typically the name of a section or that of a compression format. 13 | pub type Name = [u8; 4]; 14 | -------------------------------------------------------------------------------- /crates/binjs_io/src/entropy/format.rs: -------------------------------------------------------------------------------- 1 | // Fake module. This is only a placeholder for documentation. 2 | 3 | // As of this writing, doc inclusion only works on Nightly compiler. 4 | #![cfg_attr(feature = "unstable", doc(include = "../../../../spec/entropy.md"))] 5 | 6 | #![cfg_attr(not(feature = "unstable"), doc = "To generate the format spec documentation, please use `cargo doc --features unstable`. This requires Rust Nightly.")] 7 | -------------------------------------------------------------------------------- /crates/binjs_io/src/entropy/probabilities.rs: -------------------------------------------------------------------------------- 1 | use std::cell::RefCell; 2 | use std::rc::Rc; 3 | 4 | /// A newtype for `usize` used to count the number of some item in a given file. 5 | #[derive(Default, Serialize, Deserialize, From, Into, AddAssign, Clone, Copy, Constructor)] 6 | pub struct SymbolIndex(usize); 7 | 8 | /// Representation of a symbol in a Cumulative Distribution Frequency (CDF). 9 | /// 10 | /// Note: We most likely don't want this struct to implement Serde's Deserialize/Serialize, 11 | /// as this would lead to endless replication of `distribution`. 12 | #[derive(Clone)] 13 | pub struct SymbolInfo { 14 | /// The index of the symbol in the Cumulative Distribution Frequency (CDF). 15 | pub index: SymbolIndex, 16 | 17 | /// The Cumulative Distribution Frequency (CDF), shared between a number of symbols. 18 | pub distribution: Rc>, 19 | } 20 | 21 | /// A structure that may be converted into a probability distribution 22 | /// or a set of probability distributions. 23 | pub trait InstancesToProbabilities { 24 | type AsProbabilities; 25 | fn instances_to_probabilities(&self, description: &str) -> Self::AsProbabilities; 26 | } 27 | 28 | /// A structure that may be converted into statistical information. 29 | pub trait IntoStatistics { 30 | type AsStatistics; 31 | fn into_statistics(self, description: &str) -> Self::AsStatistics; 32 | } 33 | -------------------------------------------------------------------------------- /crates/binjs_io/src/entropy/util.rs: -------------------------------------------------------------------------------- 1 | //! Miscellaneous utilities used for entropy (de)coding. 2 | 3 | use std::io::Read; 4 | 5 | /// Utility: an extension of `Read` with a method `expect` that may be 6 | /// used to ensure the presence of a sequence of bytes. 7 | pub trait Expect { 8 | /// Fail if the following bytes are not identical to `bytes`. 9 | /// 10 | /// State of the stream is not specified in case of failure. In 11 | /// case of success, exactly `bytes` are consumed. 12 | fn expect(&mut self, bytes: &[u8]) -> Result<(), std::io::Error>; 13 | } 14 | 15 | impl Expect for T 16 | where 17 | T: Read, 18 | { 19 | fn expect(&mut self, bytes: &[u8]) -> Result<(), std::io::Error> { 20 | let mut buf = [b'?']; 21 | for b in bytes { 22 | self.read_exact(&mut buf)?; 23 | if b != &buf[0] { 24 | return Err(std::io::Error::new( 25 | std::io::ErrorKind::InvalidData, 26 | "Not the expected bytes", 27 | )); 28 | } 29 | } 30 | Ok(()) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /crates/binjs_meta/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "binjs_meta" 3 | version = "0.5.3" 4 | authors = ["David Teller "] 5 | description = "Part of binjs-ref. Tools for manipulating grammars. You probably do not want to use this crate directly unless you're writing an encoder, decoder or parser generator for binjs." 6 | homepage = "https://binast.github.io/ecmascript-binary-ast/" 7 | repository = "https://github.com/binast/binjs-ref" 8 | readme = "README.md" 9 | keywords = ["javascript", "js", "binjs", "ast"] 10 | categories = ["compression", "parsing", "web-programming"] 11 | license = "MIT" 12 | 13 | [badges] 14 | travis-ci = { repository = "https://github.com/binast/binjs-ref", branch = "master" } 15 | 16 | [dependencies] 17 | Inflector = { version = "^0.11.4", default-features=false } 18 | itertools = "^0.8" 19 | log = "^0.4" 20 | weedle = "0.11" 21 | 22 | [dev-dependencies] 23 | clap = "^2.0" 24 | env_logger = "^0.6" 25 | yaml-rust = "^0.4" 26 | -------------------------------------------------------------------------------- /crates/binjs_meta/README.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | This crate contains the tools used to manipulate the abstract syntax of JavaScript, 4 | i.e. generate parsers, encoders, etc from a specification of ASTs of the language. 5 | 6 | Actual tools to manipulate ASTs for a specific version of JavaScript are 7 | in dependent crates. 8 | -------------------------------------------------------------------------------- /crates/binjs_meta/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate offers tools designed to aid with the implementation 2 | //! of the JavaScript syntax and BinAST encoders/decoders/manipulators. 3 | 4 | extern crate inflector; 5 | extern crate itertools; 6 | 7 | #[macro_use] 8 | extern crate log; 9 | extern crate weedle; 10 | 11 | /// Generic tools for generating implementations of the Syntax. 12 | pub mod export; 13 | 14 | /// Import a specification of the Syntax. 15 | pub mod import; 16 | 17 | /// Manipulating the specifications of the language. 18 | pub mod spec; 19 | 20 | /// Misc. utilities. 21 | pub mod util; 22 | -------------------------------------------------------------------------------- /crates/binjs_shared/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "binjs_shared" 3 | version = "0.1.1" 4 | authors = ["David Teller "] 5 | 6 | [dependencies] 7 | downcast-rs = "^1.0" 8 | itertools = "^0.8" 9 | serde_json = { version = "^1.0.38", features = ["unbounded_depth"] } 10 | log = "^0.4" 11 | serde = { version = "^1.0", features = ["derive"] } 12 | -------------------------------------------------------------------------------- /fbssdc/.gitignore: -------------------------------------------------------------------------------- 1 | *.py~ 2 | __pycache__ 3 | *.pyc 4 | *~ 5 | \#* 6 | .\#* 7 | node_modules 8 | notebooks/.ipynb_checkpoints 9 | -------------------------------------------------------------------------------- /fbssdc/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 1.0 (April 16, 2019) 2 | 3 | First release. 4 | -------------------------------------------------------------------------------- /fbssdc/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | Facebook has adopted a Code of Conduct that we expect project 4 | participants to adhere to. Please read the [full 5 | text](https://code.fb.com/codeofconduct/) so that you can understand 6 | what actions will and will not be tolerated. -------------------------------------------------------------------------------- /fbssdc/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Facebook, Inc. and its affiliates. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /fbssdc/test-data/test.dict: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/fbssdc/test-data/test.dict -------------------------------------------------------------------------------- /fbssdc/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright (c) Facebook, Inc. and its affiliates. 4 | # 5 | # This source code is licensed under the MIT license found in the 6 | # LICENSE file in the root directory of this source tree. 7 | 8 | import doctest 9 | 10 | import ast 11 | import bits 12 | import encode 13 | import format 14 | import idl 15 | import lazy 16 | import model 17 | import opt 18 | import strings 19 | import tycheck 20 | 21 | if __name__ == '__main__': 22 | for mod in [bits, strings, idl, ast, tycheck, opt, lazy, model, encode, format]: 23 | doctest.testmod(mod) 24 | -------------------------------------------------------------------------------- /fbssdc/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 4 | 5 | set -e 6 | 7 | # Integration test for round-tripping a file. 8 | 9 | prog_dir=$(dirname $(realpath $0)) 10 | 11 | tmp_dir=$(mktemp -d) 12 | pushd $tmp_dir > /dev/null 13 | $prog_dir/bpy.py make-dict $prog_dir/test-data/y5R7cnYctJv.js.dump my.dict 14 | $prog_dir/bpy.py optimize-ast $prog_dir/test-data/three.min.js.dump three.dump 15 | $prog_dir/bpy.py encode-ast my.dict three.dump three.bin 16 | $prog_dir/bpy.py decode-ast my.dict three.bin three.out 17 | if [[ $(diff three.dump three.out) ]]; then 18 | echo 'test fails, decoded files differ' 19 | exit 1 20 | else 21 | echo 'test passed' 22 | fi 23 | popd > /dev/null 24 | rm -rf $tmp_dir 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "binjs-ref", 3 | "version": "1.0.0", 4 | "description": "Binary AST JS", 5 | "directories": { 6 | "doc": "docs", 7 | "example": "examples", 8 | "test": "tests" 9 | }, 10 | "dependencies": { 11 | "get-stdin": "^6.0.0", 12 | "mktemp": "^0.4.0", 13 | "shift-codegen": "^5.0.5", 14 | "shift-parser": "^5.2.3", 15 | "split": "^1.0.1" 16 | }, 17 | "devDependencies": {}, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/binast/binjs-ref.git" 21 | }, 22 | "keywords": [], 23 | "author": "", 24 | "license": "ISC", 25 | "bugs": { 26 | "url": "https://github.com/binast/binjs-ref/issues" 27 | }, 28 | "homepage": "https://github.com/binast/binjs-ref#readme" 29 | } 30 | -------------------------------------------------------------------------------- /size_benchmarks/README.md: -------------------------------------------------------------------------------- 1 | This directory contains the reference JS corpuses against which we optimize the BinAST encoder. 2 | 3 | Each subdirectory contains a different corpus. Use the sizes.py script in this directory to measure compression quality. The script depends on the brotli commandline encoder, so e.g. ```brew install brotli``` and make sure it's in the PATH 4 | 5 | Example of measuring compression ratios on a single JS input file: 6 | 7 | ``` 8 | ./sizes.py gendict -d /tmp/fb_bench_concat/ ./fb_bench_files/concat.js 9 | ./sizes.py measure -d /tmp/fb_bench_concat/ ./fb_bench_files/concat.js 10 | ``` 11 | 12 | Example of measuring dictionary aging: 13 | 14 | ``` 15 | ./sizes.py gendict -d /tmp/ef20190102 -- ./earlyflush/ef-2019-01-02/*.js 16 | ./sizes.py aging -d /tmp/ef20190102 './earlyflush/ef-2019-01-02/*.js' './earlyflush/ef-2019-01-03/*.js' './earlyflush/ef-2019-01-04/*.js' './earlyflush/ef-2019-01-10/*.js' './earlyflush/ef-2019-01-16/*.js' './earlyflush/ef-2019-02-01/*.js' 17 | ``` 18 | -------------------------------------------------------------------------------- /size_benchmarks/earlyflush/ef-2019-01-16/cjiweuf5ixkcogk8.pkg.js: -------------------------------------------------------------------------------- 1 | __d("BrowseTopFiltersNone",["cx","CSS"],(function(a,b,c,d,e,f,g){a={init:function(){b("CSS").removeClass(document.body,"-cx-PRIVATE-fbBrowseLayout__haslongtopfilters")}};e.exports=a}),null); 2 | __d("UFIShareNowMenuBootloader.react",["BootloadedComponent.react","JSResource","React","UFIShareLink.react"],(function(a,b,c,d,e,f){"use strict";__p&&__p();var g,h="ufi_share_link_placeholder",i="ufi_share_link_loaded";c=babelHelpers.inherits(a,b("React").Component);g=c&&c.prototype;function a(){var a,b;for(var c=arguments.length,d=new Array(c),e=0;e,\n\ 21 | David Teller, ", 22 | ) 23 | .about("Dump a JavaScript BinJS file structure to stdout.") 24 | .args(&[Arg::with_name("INPUT") 25 | .required(true) 26 | .help("Input file to use. Must be a BinJS source file.")]) 27 | .get_matches(); 28 | 29 | let source_path = matches.value_of("INPUT").expect("Expected input file"); 30 | 31 | println!("Reading."); 32 | let file = File::open(source_path).expect("Could not open source"); 33 | let stream = BufReader::new(file); 34 | 35 | println!("Attempting to decode as multipart."); 36 | if let Ok(mut reader) = binjs::io::multipart::TreeTokenReader::new(stream) { 37 | reader.enable_file_structure_print(); 38 | let mut deserializer = binjs::specialized::es6::io::Deserializer::new(reader); 39 | let _tree: binjs::specialized::es6::ast::Script = deserializer 40 | .deserialize(&mut binjs::specialized::es6::ast::IOPath::new()) 41 | .expect("Could not decode"); 42 | } else { 43 | println!("not supported format."); 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /src/source/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 4, 3 | "singleQuote": true 4 | } 5 | -------------------------------------------------------------------------------- /src/source/codegen.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This CLI "daemon" expects Shift AST objects (in JSON format) on the stdin 3 | * and will return a generated JS (as JSON strings) on stdout. 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const codegen = require('shift-codegen').default; 9 | const startJSONStream = require('./start-json-stream'); 10 | 11 | startJSONStream({ 12 | // `fromJSON` is a `JSON.parse` reviver callback that converts BinaryAST 13 | // JSON to Shift AST compatible objects on the fly. 14 | fromJSON: require('./to-shift'), 15 | 16 | // Mirrors the Rust side of generic value transformations. 17 | // 18 | // This one takes an AST from the Rust side as an input and applies 19 | // a codegen as a transform, returning generated JavaScript back. 20 | transform: ast => codegen(ast) 21 | }); 22 | -------------------------------------------------------------------------------- /src/source/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source-level operations. 2 | //! 3 | //! Reading a JavaScript text source file into an AST. 4 | 5 | mod parser; 6 | pub use self::parser::SourceParser; 7 | 8 | /// Parsing JavaScript using the Shift source parser (in Node). 9 | pub mod shift; 10 | pub use self::shift::Shift; 11 | -------------------------------------------------------------------------------- /src/source/parse_file.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This CLI "daemon" expects file paths to JavaScript files as JSON strings 3 | * on the stdin and will parse them and produce BinaryAST objects as JSON 4 | * on stdout. 5 | */ 6 | 7 | 'use strict'; 8 | 9 | const { readFileSync } = require('fs'); 10 | const { parseScript } = require('shift-parser'); 11 | const startJSONStream = require('./start-json-stream'); 12 | 13 | startJSONStream({ 14 | // Mirrors the Rust side of generic value transformations. 15 | // 16 | // This one takes a file path from the Rust side as an input, reads its 17 | // contents and parses into a Shift AST. 18 | transform: filename => { 19 | let code = readFileSync(filename, 'utf-8'); 20 | return parseScript(code, { earlyErrors: false }); 21 | }, 22 | 23 | // `toJSON` is a `JSON.stringify` replacer callback that converts Shift AST 24 | // to a BinaryAST JSON format on the fly. 25 | toJSON: require('./from-shift') 26 | }); 27 | -------------------------------------------------------------------------------- /src/source/parse_str.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This CLI "daemon" expects JSON strings containing JavaScript code on the 3 | * stdin and will parse them and produce BinaryAST objects as JSON on stdout. 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const { parseScript } = require('shift-parser'); 9 | const startJSONStream = require('./start-json-stream'); 10 | 11 | startJSONStream({ 12 | // Mirrors the Rust side of generic value transformations. 13 | // 14 | // This one takes a JavaScript source code from the Rust side as an input 15 | // and parses it into a Shift AST. 16 | transform: code => parseScript(code, { earlyErrors: false }), 17 | 18 | // `toJSON` is a `JSON.stringify` replacer callback that converts Shift AST 19 | // to a BinaryAST JSON format on the fly. 20 | toJSON: require('./from-shift') 21 | }); 22 | -------------------------------------------------------------------------------- /src/source/parser.rs: -------------------------------------------------------------------------------- 1 | use std::fmt::Debug; 2 | use std::path::Path; 3 | 4 | /// A source that can parse files to ASTs. 5 | pub trait SourceParser { 6 | type Error: Debug; 7 | 8 | /// Parse a string. 9 | fn parse_str(&self, source: &str) -> Result; 10 | 11 | /// Parse a file. 12 | fn parse_file>(&self, path: P) -> Result; 13 | } 14 | -------------------------------------------------------------------------------- /tests/data/facebook/single/09PWOD-iG7U.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["f3+ah"]); } 2 | 3 | __d('getVideoContextMenuOptionItem',['React','ReactXUIMenu'],(function a(b,c,d,e,f,g){var h=c('ReactXUIMenu').Item;function i(k,l,m){k.setOption(l,m,!k.getOption(l,m));}function j(k,l,m,n,o,p){var q=function t(){i(k,l,m);p();},r=k.getOption(l,m)?n:o,s=c('React').createElement(h,{onclick:q},r);return s;}f.exports=j;}),null); 4 | __d('VideoComponentOptionMenuItems',['getVideoContextMenuOptionItem'],(function a(b,c,d,e,f,g){function h(i,j){'use strict';this.$VideoComponentOptionMenuItems1=i;this.$VideoComponentOptionMenuItems2=j;this.$VideoComponentOptionMenuItems3={};}h.prototype.$VideoComponentOptionMenuItems4=function(i,j){'use strict';return i+'::'+j;};h.prototype.removeMenuItem=function(i,j){'use strict';var k=this.$VideoComponentOptionMenuItems4(i,j);delete this.$VideoComponentOptionMenuItems3[k];};h.prototype.addComponentOptionMenuItem=function(i,j,k,l){'use strict';var m=this.$VideoComponentOptionMenuItems4(i,j),n=this.$VideoComponentOptionMenuItems3[m];if(n)return;if(!this.$VideoComponentOptionMenuItems1.hasOption(i,j))return;this.$VideoComponentOptionMenuItems3[m]=c('getVideoContextMenuOptionItem').bind(null,this.$VideoComponentOptionMenuItems1,i,j,k,l,this.$VideoComponentOptionMenuItems2);};h.prototype.getComponentOptionMenuItem=function(i,j){'use strict';var k=this.$VideoComponentOptionMenuItems4(i,j),l=this.$VideoComponentOptionMenuItems3[k];if(l)return l();return undefined;};f.exports=h;}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/1Q7Vw4LF2Yr.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["mGIgA"]); } 2 | 3 | __d("PageFields",[],(function a(b,c,d,e,f,g){f.exports={NOT_APPLICABLE:"\u003C\u003Cnot-applicable>>"};}),null); 4 | __d('EmbeddedVideoWatchAndScrollControl.react',['ix','cx','fbt','AbstractButton.react','Image.react','React','ReactDOM','VideoWebDriverIDs','fbglyph','shallowCompare'],(function a(b,c,d,e,f,g,h,i,j){'use strict';var k,l,m=c('React').PropTypes;k=babelHelpers.inherits(n,c('React').Component);l=k&&k.prototype;n.prototype.shouldComponentUpdate=function(o,p){return c('shallowCompare')(this,o,p);};n.prototype.onMouseOut=function(o){c('ReactDOM').findDOMNode(this.refs.button).blur();};n.prototype.onButtonClick=function(){this.props.onEnterWatchAndScroll&&this.props.onEnterWatchAndScroll();};n.prototype.render=function(){var o=this.props.isSlidingWNSEligible?h("134816"):h("115593"),p=c('React').createElement(c('Image.react'),{className:"_5i0o",src:o});return (c('React').createElement(c('AbstractButton.react'),{className:"_3u33",'data-testid':c('VideoWebDriverIDs').WNS_CONTROL,disabled:this.props.disabled,image:p,label:j._("Enter Watch And Scroll"),labelIsHidden:true,onClick:this.onButtonClick.bind(this),onMouseOut:this.onMouseOut.bind(this),ref:'button',tabIndex:this.props.tabIndex,type:'button'}));};function n(){k.apply(this,arguments);}n.propTypes={onEnterWatchAndScroll:m.func,tabIndex:m.string};f.exports=n;}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/1WkLWwGfQa2.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["zK8AE"]); } 2 | 3 | __d('CommercialBreakHostStoryComponentType',[],(function a(b,c,d,e,f,g){var h={POP_OVER_MENU:'POP_OVER_MENU',HOST_STORY_HEADER:'HOST_STORY_HEADER'};f.exports=h;}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/1kL74PTQCjO.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["7OzSu"]); } 2 | 3 | __d('SignalsTrackingUtil',['immutable','SignalsStatusEnum'],(function a(b,c,d,e,f,g){'use strict';var h=c('immutable').List,i={getSourceByID:function j(k,l){return l.find(function(m){return m.id===k;});},getUnSelectedDataSource:function j(k,l){return (l.filterNot(function(m){return k.includes(m.id)||m.autoTracked;}));},sortSignalsList:function j(k){return k.sort(function(l,m){if(l.status===m.status)return l.name===m.name?0:l.name=15000)r();}function q(t,u){var v=c('ge')(t),w;if(v&&c('isNode')(v)){if(v.childNodes.length===0)w=t+' is empty';if(u&&u.checkVisible&&v.style.display=='none'||v.style.visibility=='hidden')w=t+' is not visible';}else if(u&&u.required)w=t+' is not in DOM';if(w){var x={error:w,extra:{element:t,events:k[t]||k}};c('ErrorSignal').logJSError('empty-dom',x);}}function r(){for(var t in h)q(t,h[t]);for(var u in i)if(c('PageletSet').hasPagelet(u))q(u,{required:true});}n();var s={runInspections:p,inspectDOM:r,inspectElement:q};f.exports=s;}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/Dl0PcFY34M0.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["iT21u"]); } 2 | 3 | __d('LogoutMenu',['csx','DOMQuery','emptyFunction','Event','requireWeak'],(function a(b,c,d,e,f,g,h){var i;c('requireWeak')('MenuItem',function(k){i=k;});function j(k,l){var m;if(l)l.subscribe('confirm',function(){c('Event').fire(m,'submit');m.submit();});k.subscribe('itemclick',function(n,o){switch(o.item.getValue()){case 'logout':m=c('DOMQuery').find(k.getRoot(),"._w0d");break;case 'createnewaccount':m=c('DOMQuery').find(k.getRoot(),"._3eei");break;case 'switchaccount':m=c('DOMQuery').find(k.getRoot(),"._3eeq");break;case 'help':if(i)i.prototype.hasAction=c('emptyFunction').thatReturnsFalse;break;default:break;}if(m)if(l){l.show();}else{c('Event').fire(m,'submit');m.submit();}});}f.exports.init=j;}),null); 4 | __d('ServiceWorkerLoginAndLogoutListener',['Event','ServiceWorkerLoginAndLogout'],(function a(b,c,d,e,f,g){var h={listen:function i(j,k){var l=function m(){if(k==='login'){c('ServiceWorkerLoginAndLogout').login();}else if(k==='logout'){c('ServiceWorkerLoginAndLogout').logout();}else throw new Error('bad login type given');};c('Event').listen(j,{click:l,submit:l});}};f.exports=h;}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/EenddqKIgxS.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["uCyqQ"]); } 2 | 3 | __d('SUIBorderUtils',['CornerEnum','Locale','React','Set','SideEnum'],(function a(b,c,d,e,f,g){'use strict';var h=c('React').PropTypes,i=c('CornerEnum').values,j=c('SideEnum').values,k={ALL_CORNERS:i,ALL_SIDES:j,BorderedSidesPropType:h.arrayOf(h.oneOf(j)),RoundedCornersPropType:h.arrayOf(h.oneOf(i)),getBorderRadiusStyles:function l(m){var n=new (c('Set'))(m);if(n.size===i.length)return null;var o={borderTopLeftRadius:n.has('topLeft')?'2px':'0',borderTopRightRadius:n.has('topRight')?'2px':'0',borderBottomRightRadius:n.has('bottomRight')?'2px':'0',borderBottomLeftRadius:n.has('bottomLeft')?'2px':'0'};if(c('Locale').isRTL())return {borderTopLeftRadius:o.borderTopRightRadius,borderTopRightRadius:o.borderTopLeftRadius,borderBottomRightRadius:o.borderBottomLeftRadius,borderBottomLeftRadius:o.borderBottomRightRadius};return o;},getBorderWidthStyles:function l(m){var n=new (c('Set'))(m);if(n.size===j.length)return null;var o={borderTopWidth:n.has('top')?'1px':'0',borderRightWidth:n.has('right')?'1px':'0',borderBottomWidth:n.has('bottom')?'1px':'0',borderLeftWidth:n.has('left')?'1px':'0'};if(c('Locale').isRTL())return babelHelpers['extends']({},o,{borderRightWidth:o.borderLeftWidth,borderLeftWidth:o.borderRightWidth});return o;}};f.exports=k;}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/Fd1U8zdftY3.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["eUvlN"]); } 2 | 3 | __d('AdsDispatcherDebugger',['AdsFluxStoreInspectorHelper','URI'],(function a(b,c,d,e,f,g){'use strict';var h={shouldLog:!!new (c('URI'))(window.location.href).getQueryData().dispatcherevents,toggleLogging:function i(){h.shouldLog=!h.shouldLog;},isLogging:function i(){return h.shouldLog;},attach:function i(j){j.register(function(k){var l=k.action,m=k.payloadsource;if(l){if(console.timeStamp)console.timeStamp(l.type);if(m)c('AdsFluxStoreInspectorHelper').newAction(l,m);if(h.shouldLog){var n=l.type,o=l.actionType,p=babelHelpers.objectWithoutProperties(l,['type','actionType']);console.groupCollapsed(n||o,p);console.trace();console.groupEnd();}}});}};f.exports=h;}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/Ktjd_zCDiuX.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["umUWd"]); } 2 | 3 | __d('AYMTHomepagePanelLogger',['BanzaiLogger','Event','tidyEvent'],(function a(b,c,d,e,f,g){var h=null,i={init:function j(k,l){c('tidyEvent')(c('Event').listen(k,'click',function(event){c('BanzaiLogger').log('AYMTHomepagePanelLoggerConfig',l);}));}};f.exports=i;}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/MwM-eWv6gvY.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["zLB07"]); } 2 | 3 | __d('ErrorLogging',['ErrorSignal','ErrorUtils','JSErrorExtra','JSErrorPlatformColumns'],(function a(b,c,d,e,f,g){function h(k){var l=k.extra||{},m={};Object.keys(c('JSErrorExtra')).forEach(function(n){if(c('JSErrorExtra')[n])m[n]=true;});Object.keys(l).forEach(function(n){if(l[n]){m[n]=true;}else if(m[n])delete m[n];});k.extra=Object.keys(m);}function i(k){if(c('JSErrorPlatformColumns').app_id!==undefined)k.app_id=c('JSErrorPlatformColumns').app_id;if(c('JSErrorPlatformColumns').access_token!==undefined)k.access_token=c('JSErrorPlatformColumns').access_token;}function j(k){h(k);i(k);var l=k.category||'onerror';c('ErrorSignal').logJSError(l,{error:k.name||k.message,extra:k});}c('ErrorUtils').addListener(j);f.exports={defaultJSErrorHandler:j};}),null); 4 | __d("XPresenceReconnectAsyncController",["XController"],(function a(b,c,d,e,f,g){f.exports=c("XController").create("\/ajax\/presence\/reconnect.php",{reason:{type:"Int"}});}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/N8rUHyk5FDI.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["c362m"]); } 2 | 3 | __d('extractCEA608',['JSResource'],(function a(b,c,d,e,f,g){var h=null;function i(j,k){if(!h)h=c('JSResource')('CEA608Extractor').__setRef('extractCEA608').load().then(function(l){return new l(k);});return h.then(function(l){return l.extract(j);});}f.exports=i;}),null); -------------------------------------------------------------------------------- /tests/data/facebook/single/NhNKyiBLxFg.js: -------------------------------------------------------------------------------- 1 | if (self.CavalryLogger) { CavalryLogger.start_js(["cT\/Rn"]); } 2 | 3 | __d('TraceBench',['TraceBenchUtils'],(function a(b,c,d,e,f,g){var h={};function i(u,v){console.timeStamp&&console.timeStamp(u+' '+JSON.stringify(v));}function j(u,v,w,x){u=u.replace(/\s/g,'_');v=v&&v.replace(/\s/g,'_');i('perf_trace',c('TraceBenchUtils').clean({name:u,stack:c('TraceBenchUtils').getStack(),action:w,parent:v,id:x}));}function k(u,v){var w=c('TraceBenchUtils').nextUID();h[w]={name:u,parent:v,excuted:false};j(u,v,'start',w);return w;}function l(u){var v=h[u];if(!(v.excuted)){var w=v.name;v.excuted=true;j(w,v.parent,'end',u);}}function m(u,v,w){return function(){var x=this,y=k(v||u.name,w);for(var z=arguments.length,aa=Array(z),ba=0;ba version(100) 19 | * 120 20 | * js> eval("function f(){}function g(){}") 21 | * js> version(120); 22 | * 100 23 | * js> eval("function f(){}function g(){}") 24 | * js> 25 | * Author: christine@netscape.com 26 | * Date: 11 August 1998 27 | */ 28 | var SECTION = "function-001.js"; 29 | var VERSION = "JS_12"; 30 | var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; 31 | var BUGNUMBER="10278"; 32 | 33 | startTest(); 34 | writeHeaderToLog( SECTION + " "+ TITLE); 35 | 36 | var result = "pass"; 37 | var exception = "no exception thrown"; 38 | 39 | try { 40 | eval("function f(){}function g(){}"); 41 | } catch ( e ) { 42 | result = "fail"; 43 | exception = e.toString(); 44 | } 45 | 46 | new TestCase( 47 | SECTION, 48 | "eval(\"function f(){}function g(){}\") (threw "+exception, 49 | "pass", 50 | result ); 51 | 52 | test(); 53 | 54 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/global-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: global-001 9 | Corresponds To: ecma/GlobalObject/15.1-1-n.js 10 | ECMA Section: The global object 11 | Description: 12 | 13 | The global object does not have a [[Construct]] property; it is not 14 | possible to use the global object as a constructor with the new operator. 15 | 16 | 17 | Author: christine@netscape.com 18 | Date: 12 november 1997 19 | */ 20 | var SECTION = "global-001"; 21 | var VERSION = "ECMA_1"; 22 | var TITLE = "The Global Object"; 23 | 24 | startTest(); 25 | writeHeaderToLog( SECTION + " "+ TITLE); 26 | 27 | var result = "Failed"; 28 | var exception = "No exception thrown"; 29 | var expect = "Passed"; 30 | 31 | try { 32 | result = new this(); 33 | } catch ( e ) { 34 | result = expect; 35 | exception = e.toString(); 36 | } 37 | 38 | new TestCase( 39 | SECTION, 40 | "result = new this()" + 41 | " (threw " + exception +")", 42 | expect, 43 | result ); 44 | 45 | test(); 46 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/global-002.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: global-002 9 | Corresponds To: ecma/GlobalObject/15.1-2-n.js 10 | ECMA Section: The global object 11 | Description: 12 | 13 | The global object does not have a [[Construct]] property; it is not 14 | possible to use the global object as a constructor with the new operator. 15 | 16 | 17 | Author: christine@netscape.com 18 | Date: 12 november 1997 19 | */ 20 | var SECTION = "global-002"; 21 | var VERSION = "JS1_4"; 22 | var TITLE = "The Global Object"; 23 | 24 | startTest(); 25 | writeHeaderToLog( SECTION + " "+ TITLE); 26 | 27 | var result = "Failed"; 28 | var exception = "No exception thrown"; 29 | var expect = "Passed"; 30 | 31 | try { 32 | result = this(); 33 | } catch ( e ) { 34 | result = expect; 35 | exception = e.toString(); 36 | } 37 | 38 | new TestCase( 39 | SECTION, 40 | "result = this()" + 41 | " (threw " + exception +")", 42 | expect, 43 | result ); 44 | 45 | test(); 46 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-003.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-003.js 9 | Corresponds To: 7.3-13-n.js 10 | ECMA Section: 7.3 Comments 11 | Description: 12 | 13 | Author: christine@netscape.com 14 | Date: 12 november 1997 15 | 16 | */ 17 | var SECTION = "lexical-003.js"; 18 | var VERSION = "JS1_4"; 19 | var TITLE = "Comments"; 20 | 21 | startTest(); 22 | writeHeaderToLog( SECTION + " "+ TITLE); 23 | 24 | var result = "Failed"; 25 | var exception = "No exception thrown"; 26 | var expect = "Passed"; 27 | 28 | try { 29 | eval("/*\n/* nested comment */\n*/\n"); 30 | } catch ( e ) { 31 | result = expect; 32 | exception = e.toString(); 33 | } 34 | 35 | new TestCase( 36 | SECTION, 37 | "/*/*nested comment*/ */" + 38 | " (threw " + exception +")", 39 | expect, 40 | result ); 41 | 42 | test(); 43 | 44 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-004.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-004.js 9 | Corresponds To: ecma/LexicalExpressions/7.4.1-1-n.js 10 | ECMA Section: 7.4.1 11 | 12 | Description: 13 | 14 | Reserved words cannot be used as identifiers. 15 | 16 | ReservedWord :: 17 | Keyword 18 | FutureReservedWord 19 | NullLiteral 20 | BooleanLiteral 21 | 22 | Author: christine@netscape.com 23 | Date: 12 november 1997 24 | 25 | */ 26 | var SECTION = "lexical-004"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Keywords"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("var null = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "var null = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-005.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-005.js 9 | Corresponds To: 7.4.1-2.js 10 | ECMA Section: 7.4.1 11 | 12 | Description: 13 | 14 | Reserved words cannot be used as identifiers. 15 | 16 | ReservedWord :: 17 | Keyword 18 | FutureReservedWord 19 | NullLiteral 20 | BooleanLiteral 21 | 22 | Author: christine@netscape.com 23 | Date: 12 november 1997 24 | 25 | */ 26 | var SECTION = "lexical-005"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Keywords"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("true = false;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "true = false" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-007.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-005.js 9 | Corresponds To: 7.4.1-3-n.js 10 | ECMA Section: 7.4.1 11 | 12 | Description: 13 | 14 | Reserved words cannot be used as identifiers. 15 | 16 | ReservedWord :: 17 | Keyword 18 | FutureReservedWord 19 | NullLiteral 20 | BooleanLiteral 21 | 22 | Author: christine@netscape.com 23 | Date: 12 november 1997 24 | */ 25 | var SECTION = "lexical-005"; 26 | var VERSION = "JS1_4"; 27 | var TITLE = "Keywords"; 28 | 29 | startTest(); 30 | writeHeaderToLog( SECTION + " "+ TITLE); 31 | 32 | var result = "Failed"; 33 | var exception = "No exception thrown"; 34 | var expect = "Passed"; 35 | 36 | try { 37 | eval("false = true;"); 38 | } catch ( e ) { 39 | result = expect; 40 | exception = e.toString(); 41 | } 42 | 43 | new TestCase( 44 | SECTION, 45 | "false = true" + 46 | " (threw " + exception +")", 47 | expect, 48 | result ); 49 | 50 | test(); 51 | 52 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-008.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-008.js 9 | Corresponds To: 7.4.3-1-n.js 10 | ECMA Section: 7.4.3 11 | 12 | Description: 13 | The following words are used as keywords in proposed extensions and are 14 | therefore reserved to allow for the possibility of future adoption of 15 | those extensions. 16 | 17 | FutureReservedWord :: one of 18 | case debugger export super 19 | catch default extends switch 20 | class do finally throw 21 | const enum import try 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | */ 26 | var SECTION = "lexical-008.js"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Future Reserved Words"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("case = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "case = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-009.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-009 9 | Corresponds To: 7.4.3-2-n.js 10 | ECMA Section: 7.4.3 11 | 12 | Description: 13 | The following words are used as keywords in proposed extensions and are 14 | therefore reserved to allow for the possibility of future adoption of 15 | those extensions. 16 | 17 | FutureReservedWord :: one of 18 | case debugger export super 19 | catch default extends switch 20 | class do finally throw 21 | const enum import try 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | */ 26 | var SECTION = "lexical-009"; 27 | var VERSION = "ECMA_1"; 28 | var TITLE = "Future Reserved Words"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("debugger = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "debugger = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-012.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-012.js 9 | Corresponds To: 7.4.3-5-n.js 10 | ECMA Section: 7.4.3 11 | 12 | Description: 13 | The following words are used as keywords in proposed extensions and are 14 | therefore reserved to allow for the possibility of future adoption of 15 | those extensions. 16 | 17 | FutureReservedWord :: one of 18 | case debugger export super 19 | catch default extends switch 20 | class do finally throw 21 | const enum import try 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | */ 26 | var SECTION = "lexical-012"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Future Reserved Words"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("catch = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "catch = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-013.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-013.js 9 | Corresponds To: 7.4.3-6-n.js 10 | ECMA Section: 7.4.3 11 | 12 | Description: 13 | The following words are used as keywords in proposed extensions and are 14 | therefore reserved to allow for the possibility of future adoption of 15 | those extensions. 16 | 17 | FutureReservedWord :: one of 18 | case debugger export super 19 | catch default extends switch 20 | class do finally throw 21 | const enum import try 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | */ 26 | var SECTION = "lexical-013"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Future Reserved Words"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("default = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "default = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-015.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-015.js 9 | Corresponds To: 7.4.3-8-n.js 10 | ECMA Section: 7.4.3 11 | 12 | Description: 13 | The following words are used as keywords in proposed extensions and are 14 | therefore reserved to allow for the possibility of future adoption of 15 | those extensions. 16 | 17 | FutureReservedWord :: one of 18 | case debugger export super 19 | catch default extends switch 20 | class do finally throw 21 | const enum import try 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | */ 26 | var SECTION = "lexical-015"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Future Reserved Words"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("switch = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "switch = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-017.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-017.js 9 | Corresponds To: 7.4.3-10-n.js 10 | ECMA Section: 7.4.3 11 | 12 | Description: 13 | The following words are used as keywords in proposed extensions and are 14 | therefore reserved to allow for the possibility of future adoption of 15 | those extensions. 16 | 17 | FutureReservedWord :: one of 18 | case debugger export super 19 | catch default extends switch 20 | class do finally throw 21 | const enum import try 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | */ 26 | var SECTION = "lexical-017"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Future Reserved Words"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("do = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "do = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-018.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-018 9 | Corresponds To: 7.4.3-11-n.js 10 | ECMA Section: 7.4.3 11 | 12 | Description: 13 | The following words are used as keywords in proposed extensions and are 14 | therefore reserved to allow for the possibility of future adoption of 15 | those extensions. 16 | 17 | FutureReservedWord :: one of 18 | case debugger export super 19 | catch default extends switch 20 | class do finally throw 21 | const enum import try 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | */ 26 | var SECTION = "lexical-018"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Future Reserved Words"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("finally = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "finally = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-019.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-019.js 9 | Corresponds To: 7.4.3-12-n.js 10 | ECMA Section: 7.4.3 11 | 12 | Description: 13 | The following words are used as keywords in proposed extensions and are 14 | therefore reserved to allow for the possibility of future adoption of 15 | those extensions. 16 | 17 | FutureReservedWord :: one of 18 | case debugger export super 19 | catch default extends switch 20 | class do finally throw 21 | const enum import try 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | */ 26 | var SECTION = "lexical-019"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Future Reserved Words"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("throw = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "throw = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-020.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-020.js 9 | Corresponds To 7.4.3-13-n.js 10 | ECMA Section: 7.4.3 11 | 12 | Description: 13 | The following words are used as keywords in proposed extensions and are 14 | therefore reserved to allow for the possibility of future adoption of 15 | those extensions. 16 | 17 | FutureReservedWord :: one of 18 | case debugger export super 19 | catch default extends switch 20 | class do finally throw 21 | const enum import try 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | */ 26 | var SECTION = "lexical-020"; 27 | var VERSION = "JS1_4"; 28 | var TITLE = "Future Reserved Words"; 29 | 30 | startTest(); 31 | writeHeaderToLog( SECTION + " "+ TITLE); 32 | 33 | var result = "Failed"; 34 | var exception = "No exception thrown"; 35 | var expect = "Passed"; 36 | 37 | try { 38 | eval("const = true;"); 39 | } catch ( e ) { 40 | result = expect; 41 | exception = e.toString(); 42 | } 43 | 44 | new TestCase( 45 | SECTION, 46 | "const = true" + 47 | " (threw " + exception +")", 48 | expect, 49 | result ); 50 | 51 | test(); 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-023.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-023.js 9 | Corresponds To: 7.4.3-16-n.js 10 | ECMA Section: 7.4.3 11 | Description: 12 | The following words are used as keywords in proposed extensions and are 13 | therefore reserved to allow for the possibility of future adoption of 14 | those extensions. 15 | 16 | FutureReservedWord :: one of 17 | case debugger export super 18 | catch default extends switch 19 | class do finally throw 20 | const enum import try 21 | 22 | Author: christine@netscape.com 23 | Date: 12 november 1997 24 | */ 25 | var SECTION = "lexical-023.js"; 26 | var VERSION = "ECMA_1"; 27 | var TITLE = "Future Reserved Words"; 28 | 29 | startTest(); 30 | writeHeaderToLog( SECTION + " "+ TITLE); 31 | 32 | var result = "Failed"; 33 | var exception = "No exception thrown"; 34 | var expect = "Passed"; 35 | 36 | try { 37 | eval("try = true;"); 38 | } catch ( e ) { 39 | result = expect; 40 | exception = e.toString(); 41 | } 42 | 43 | new TestCase( 44 | SECTION, 45 | "try = true" + 46 | " (threw " + exception +")", 47 | expect, 48 | result ); 49 | 50 | test(); 51 | 52 | 53 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-024.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-024 9 | Corresponds To: 7.4.2-1-n.js 10 | ECMA Section: 7.4.2 11 | 12 | Description: 13 | The following tokens are ECMAScript keywords and may not be used as 14 | identifiers in ECMAScript programs. 15 | 16 | Syntax 17 | 18 | Keyword :: one of 19 | break for new var 20 | continue function return void 21 | delete if this while 22 | else in typeof with 23 | 24 | This test verifies that the keyword cannot be used as an identifier. 25 | Functioinal tests of the keyword may be found in the section corresponding 26 | to the function of the keyword. 27 | 28 | Author: christine@netscape.com 29 | Date: 12 november 1997 30 | 31 | */ 32 | var SECTION = "lexical-024"; 33 | var VERSION = "JS1_4"; 34 | var TITLE = "Keywords"; 35 | 36 | startTest(); 37 | writeHeaderToLog( SECTION + " "+ TITLE); 38 | 39 | var result = "Failed"; 40 | var exception = "No exception thrown"; 41 | var expect = "Passed"; 42 | 43 | try { 44 | eval("var break;"); 45 | } catch ( e ) { 46 | result = expect; 47 | exception = e.toString(); 48 | } 49 | 50 | new TestCase( 51 | SECTION, 52 | "var break" + 53 | " (threw " + exception +")", 54 | expect, 55 | result ); 56 | 57 | test(); 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-025.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-025.js 9 | Corresponds To 7.4.2-2-n.js 10 | ECMA Section: 7.4.2 11 | 12 | Description: 13 | The following tokens are ECMAScript keywords and may not be used as 14 | identifiers in ECMAScript programs. 15 | 16 | Syntax 17 | 18 | Keyword :: one of 19 | break for new var 20 | continue function return void 21 | delete if this while 22 | else in typeof with 23 | 24 | This test verifies that the keyword cannot be used as an identifier. 25 | Functioinal tests of the keyword may be found in the section corresponding 26 | to the function of the keyword. 27 | 28 | Author: christine@netscape.com 29 | Date: 12 november 1997 30 | 31 | */ 32 | var SECTION = "lexical-025"; 33 | var VERSION = "JS1_4"; 34 | var TITLE = "Keywords"; 35 | 36 | startTest(); 37 | writeHeaderToLog( SECTION + " "+ TITLE); 38 | 39 | var result = "Failed"; 40 | var exception = "No exception thrown"; 41 | var expect = "Passed"; 42 | 43 | try { 44 | eval("var for;"); 45 | } catch ( e ) { 46 | result = expect; 47 | exception = e.toString(); 48 | } 49 | 50 | new TestCase( 51 | SECTION, 52 | "var for" + 53 | " (threw " + exception +")", 54 | expect, 55 | result ); 56 | 57 | test(); 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-026.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-026.js 9 | Corresponds To: 7.4.2-3-n.js 10 | ECMA Section: 7.4.2 11 | 12 | Description: 13 | The following tokens are ECMAScript keywords and may not be used as 14 | identifiers in ECMAScript programs. 15 | 16 | Syntax 17 | 18 | Keyword :: one of 19 | break for new var 20 | continue function return void 21 | delete if this while 22 | else in typeof with 23 | 24 | This test verifies that the keyword cannot be used as an identifier. 25 | Functioinal tests of the keyword may be found in the section corresponding 26 | to the function of the keyword. 27 | 28 | Author: christine@netscape.com 29 | Date: 12 november 1997 30 | 31 | */ 32 | var SECTION = "lexical-026"; 33 | var VERSION = "JS1_4"; 34 | var TITLE = "Keywords"; 35 | 36 | startTest(); 37 | writeHeaderToLog( SECTION + " "+ TITLE); 38 | 39 | var result = "Failed"; 40 | var exception = "No exception thrown"; 41 | var expect = "Passed"; 42 | 43 | try { 44 | eval("var new;"); 45 | } catch ( e ) { 46 | result = expect; 47 | exception = e.toString(); 48 | } 49 | 50 | new TestCase( 51 | SECTION, 52 | "var new" + 53 | " (threw " + exception +")", 54 | expect, 55 | result ); 56 | 57 | test(); 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-034.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: 7.4.2-11-n.js 9 | ECMA Section: 7.4.2 10 | 11 | Description: 12 | The following tokens are ECMAScript keywords and may not be used as 13 | identifiers in ECMAScript programs. 14 | 15 | Syntax 16 | 17 | Keyword :: one of 18 | break for new var 19 | continue function return void 20 | delete if this while 21 | else in typeof with 22 | 23 | This test verifies that the keyword cannot be used as an identifier. 24 | Functioinal tests of the keyword may be found in the section corresponding 25 | to the function of the keyword. 26 | 27 | Author: christine@netscape.com 28 | Date: 12 november 1997 29 | 30 | */ 31 | var SECTION = "lexical-034"; 32 | var VERSION = "JS1_4"; 33 | var TITLE = "Keywords"; 34 | 35 | startTest(); 36 | writeHeaderToLog( SECTION + " "+ TITLE); 37 | 38 | var result = "Failed"; 39 | var exception = "No exception thrown"; 40 | var expect = "Passed"; 41 | 42 | try { 43 | eval("this = true"); 44 | } catch ( e ) { 45 | result = expect; 46 | exception = e.toString(); 47 | } 48 | 49 | new TestCase( 50 | SECTION, 51 | "this = true" + 52 | " (threw " + exception +")", 53 | expect, 54 | result ); 55 | 56 | test(); 57 | 58 | 59 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-039.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-039 9 | Corresponds To: 7.5-2-n.js 10 | ECMA Section: 7.5 Identifiers 11 | Description: Identifiers are of unlimited length 12 | - can contain letters, a decimal digit, _, or $ 13 | - the first character cannot be a decimal digit 14 | - identifiers are case sensitive 15 | 16 | Author: christine@netscape.com 17 | Date: 11 september 1997 18 | */ 19 | var SECTION = "lexical-039"; 20 | var VERSION = "JS1_4"; 21 | var TITLE = "Identifiers"; 22 | 23 | startTest(); 24 | writeHeaderToLog( SECTION + " "+ TITLE); 25 | 26 | var result = "Failed"; 27 | var exception = "No exception thrown"; 28 | var expect = "Passed"; 29 | 30 | try { 31 | eval("var 0abc;"); 32 | } catch ( e ) { 33 | result = expect; 34 | exception = e.toString(); 35 | } 36 | 37 | new TestCase( 38 | SECTION, 39 | "var 0abc" + 40 | " (threw " + exception +")", 41 | expect, 42 | result ); 43 | 44 | test(); 45 | 46 | 47 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-040.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-040.js 9 | Corresponds To: 7.5-2.js 10 | ECMA Section: 7.5 Identifiers 11 | Description: Identifiers are of unlimited length 12 | - can contain letters, a decimal digit, _, or $ 13 | - the first character cannot be a decimal digit 14 | - identifiers are case sensitive 15 | 16 | Author: christine@netscape.com 17 | Date: 11 september 1997 18 | */ 19 | var SECTION = "lexical-040"; 20 | var VERSION = "JS1_4"; 21 | var TITLE = "Identifiers"; 22 | 23 | startTest(); 24 | writeHeaderToLog( SECTION + " "+ TITLE); 25 | 26 | var result = "Failed"; 27 | var exception = "No exception thrown"; 28 | var expect = "Passed"; 29 | 30 | try { 31 | eval("var 1abc;"); 32 | } catch ( e ) { 33 | result = expect; 34 | exception = e.toString(); 35 | } 36 | 37 | new TestCase( 38 | SECTION, 39 | "var 1abc" + 40 | " (threw " + exception +")", 41 | expect, 42 | result ); 43 | 44 | test(); 45 | 46 | 47 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-041.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-041.js 9 | Corresponds To: 7.5-8-n.js 10 | ECMA Section: 7.5 Identifiers 11 | Description: Identifiers are of unlimited length 12 | - can contain letters, a decimal digit, _, or $ 13 | - the first character cannot be a decimal digit 14 | - identifiers are case sensitive 15 | 16 | Author: christine@netscape.com 17 | Date: 11 september 1997 18 | */ 19 | var SECTION = "lexical-041"; 20 | var VERSION = "ECMA_1"; 21 | var TITLE = "Identifiers"; 22 | 23 | startTest(); 24 | writeHeaderToLog( SECTION + " "+ TITLE); 25 | startTest(); 26 | writeHeaderToLog( SECTION + " "+ TITLE); 27 | 28 | var result = "Failed"; 29 | var exception = "No exception thrown"; 30 | var expect = "Passed"; 31 | 32 | try { 33 | eval("var @abc;"); 34 | } catch ( e ) { 35 | result = expect; 36 | exception = e.toString(); 37 | } 38 | 39 | new TestCase( 40 | SECTION, 41 | "var @abc" + 42 | " (threw " + exception +")", 43 | expect, 44 | result ); 45 | 46 | test(); 47 | 48 | 49 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-042.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-042.js 9 | Corresponds To: 7.5-9-n.js 10 | ECMA Section: 7.5 Identifiers 11 | Description: Identifiers are of unlimited length 12 | - can contain letters, a decimal digit, _, or $ 13 | - the first character cannot be a decimal digit 14 | - identifiers are case sensitive 15 | 16 | Author: christine@netscape.com 17 | Date: 11 september 1997 18 | */ 19 | var SECTION = "lexical-042"; 20 | var VERSION = "JS1_4"; 21 | var TITLE = "Identifiers"; 22 | 23 | startTest(); 24 | writeHeaderToLog( SECTION + " "+ TITLE); 25 | 26 | startTest(); 27 | writeHeaderToLog( SECTION + " "+ TITLE); 28 | 29 | var result = "Failed"; 30 | var exception = "No exception thrown"; 31 | var expect = "Passed"; 32 | 33 | try { 34 | eval("var 123;"); 35 | } catch ( e ) { 36 | result = expect; 37 | exception = e.toString(); 38 | } 39 | 40 | new TestCase( 41 | SECTION, 42 | "var 123" + 43 | " (threw " + exception +")", 44 | expect, 45 | result ); 46 | 47 | test(); 48 | 49 | 50 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-047.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-047.js 9 | Corresponds To: 7.8.1-7-n.js 10 | ECMA Section: 7.8.1 11 | Description: 12 | Author: christine@netscape.com 13 | Date: 15 september 1997 14 | */ 15 | 16 | var SECTION = "lexical-047"; 17 | var VERSION = "JS1_4"; 18 | var TITLE = "for loops"; 19 | 20 | startTest(); 21 | writeHeaderToLog( SECTION + " "+ TITLE); 22 | 23 | var result = "Failed"; 24 | var exception = "No exception thrown"; 25 | var expect = "Passed"; 26 | 27 | try { 28 | var counter = 0; 29 | eval("for ( counter = 0\n" 30 | + "counter <= 1\n" 31 | + "counter++ )\n" 32 | + "{\n" 33 | + "result += \": got to inner loop\";\n" 34 | + "}\n"); 35 | 36 | } catch ( e ) { 37 | result = expect; 38 | exception = e.toString(); 39 | } 40 | 41 | new TestCase( 42 | SECTION, 43 | "line breaks within a for expression" + 44 | " (threw " + exception +")", 45 | expect, 46 | result ); 47 | 48 | test(); 49 | 50 | 51 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-048.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-048.js 9 | Corresponds To: 7.8.1-1.js 10 | ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertion 11 | Description: 12 | Author: christine@netscape.com 13 | Date: 15 september 1997 14 | */ 15 | 16 | var SECTION = "lexical-048"; 17 | var VERSION = "JS1_4"; 18 | var TITLE = "The Rules of Automatic Semicolon Insertion"; 19 | 20 | startTest(); 21 | writeHeaderToLog( SECTION + " "+ TITLE); 22 | 23 | var result = "Failed"; 24 | var exception = "No exception thrown"; 25 | var expect = "Passed"; 26 | 27 | try { 28 | var counter = 0; 29 | eval( "for ( counter = 0;\ncounter <= 1\ncounter++ ) {\nresult += \": got inside for loop\")"); 30 | } catch ( e ) { 31 | result = expect; 32 | exception = e.toString(); 33 | } 34 | 35 | new TestCase( 36 | SECTION, 37 | "line breaks within a for expression" + 38 | " (threw " + exception +")", 39 | expect, 40 | result ); 41 | 42 | test(); 43 | 44 | 45 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-049.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-049 9 | Corresponds To: 7.8.1-1.js 10 | ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertioin 11 | Description: 12 | Author: christine@netscape.com 13 | Date: 15 september 1997 14 | */ 15 | var SECTION = "lexical-049"; 16 | var VERSION = "JS1_4"; 17 | var TITLE = "The Rules of Automatic Semicolon Insertion"; 18 | 19 | startTest(); 20 | writeHeaderToLog( SECTION + " "+ TITLE); 21 | 22 | var result = "Failed"; 23 | var exception = "No exception thrown"; 24 | var expect = "Passed"; 25 | 26 | try { 27 | var counter = 0; 28 | eval("for ( counter = 0\n" 29 | + "counter <= 1;\n" 30 | + "counter++ )\n" 31 | + "{\n" 32 | + "result += \": got inside for loop\";\n" 33 | + "}\n"); 34 | 35 | } catch ( e ) { 36 | result = expect; 37 | exception = e.toString(); 38 | } 39 | 40 | new TestCase( 41 | SECTION, 42 | "line breaks within a for expression" + 43 | " (threw " + exception +")", 44 | expect, 45 | result ); 46 | 47 | test(); 48 | 49 | 50 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-050.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-050.js 9 | Corresponds to: 7.8.2-1-n.js 10 | ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion 11 | Description: compare some specific examples of the automatic 12 | insertion rules in the EMCA specification. 13 | Author: christine@netscape.com 14 | Date: 15 september 1997 15 | */ 16 | 17 | var SECTION = "lexical-050"; 18 | var VERSION = "JS1_4"; 19 | var TITLE = "Examples of Automatic Semicolon Insertion"; 20 | 21 | startTest(); 22 | writeHeaderToLog( SECTION + " "+ TITLE); 23 | 24 | var result = "Failed"; 25 | var exception = "No exception thrown"; 26 | var expect = "Passed"; 27 | 28 | try { 29 | eval("{ 1 2 } 3"); 30 | } catch ( e ) { 31 | result = expect; 32 | exception = e.toString(); 33 | } 34 | 35 | new TestCase( 36 | SECTION, 37 | "{ 1 2 } 3" + 38 | " (threw " + exception +")", 39 | expect, 40 | result ); 41 | 42 | test(); 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-051.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-051.js 9 | Corresponds to: 7.8.2-3-n.js 10 | ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion 11 | Description: compare some specific examples of the automatic 12 | insertion rules in the EMCA specification. 13 | Author: christine@netscape.com 14 | Date: 15 september 1997 15 | */ 16 | 17 | var SECTION = "lexical-051"; 18 | var VERSION = "JS1_4"; 19 | var TITLE = "Examples of Automatic Semicolon Insertion"; 20 | 21 | startTest(); 22 | writeHeaderToLog( SECTION + " "+ TITLE); 23 | 24 | var result = "Failed"; 25 | var exception = "No exception thrown"; 26 | var expect = "Passed"; 27 | 28 | try { 29 | eval("for (a; b\n) result += \": got to inner loop\";") 30 | } catch ( e ) { 31 | result = expect; 32 | exception = e.toString(); 33 | } 34 | 35 | new TestCase( 36 | SECTION, 37 | "for (a; b\n)" + 38 | " (threw " + exception +")", 39 | expect, 40 | result ); 41 | 42 | test(); 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-052.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-052.js 9 | Corresponds to: 7.8.2-4-n.js 10 | ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion 11 | Description: compare some specific examples of the automatic 12 | insertion rules in the EMCA specification. 13 | Author: christine@netscape.com 14 | Date: 15 september 1997 15 | */ 16 | 17 | var SECTION = "lexical-052"; 18 | var VERSION = "JS1_4"; 19 | var TITLE = "Examples of Automatic Semicolon Insertion"; 20 | 21 | startTest(); 22 | writeHeaderToLog( SECTION + " "+ TITLE); 23 | 24 | var result = "Failed"; 25 | var exception = "No exception thrown"; 26 | var expect = "Passed"; 27 | 28 | try { 29 | MyFunction(); 30 | } catch ( e ) { 31 | result = expect; 32 | exception = e.toString(); 33 | } 34 | 35 | new TestCase( 36 | SECTION, 37 | "calling return indirectly" + 38 | " (threw " + exception +")", 39 | expect, 40 | result ); 41 | 42 | test(); 43 | 44 | function MyFunction() { 45 | var s = "return"; 46 | eval(s); 47 | } 48 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-053.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-053.js 9 | Corresponds to: 7.8.2-7-n.js 10 | ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion 11 | Description: compare some specific examples of the automatic 12 | insertion rules in the EMCA specification. 13 | Author: christine@netscape.com 14 | Date: 15 september 1997 15 | */ 16 | 17 | var SECTION = "lexical-053"; 18 | var VERSION = "JS1_4"; 19 | var TITLE = "Examples of Automatic Semicolon Insertion"; 20 | 21 | startTest(); 22 | writeHeaderToLog( SECTION + " "+ TITLE); 23 | 24 | var result = "Failed"; 25 | var exception = "No exception thrown"; 26 | var expect = "Passed"; 27 | 28 | try { 29 | a = true 30 | b = false 31 | 32 | eval('if (a > b)\nelse result += ": got to else statement"'); 33 | } catch ( e ) { 34 | result = expect; 35 | exception = e.toString(); 36 | } 37 | 38 | new TestCase( 39 | SECTION, 40 | "calling return indirectly" + 41 | " (threw " + exception +")", 42 | expect, 43 | result ); 44 | 45 | test(); 46 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/lexical-054.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: lexical-054.js 9 | Corresponds to: 7.8.2-7-n.js 10 | ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion 11 | Description: compare some specific examples of the automatic 12 | insertion rules in the EMCA specification. 13 | Author: christine@netscape.com 14 | Date: 15 september 1997 15 | */ 16 | 17 | var SECTION = "lexical-054"; 18 | var VERSION = "JS1_4"; 19 | var TITLE = "Examples of Automatic Semicolon Insertion"; 20 | 21 | startTest(); 22 | writeHeaderToLog( SECTION + " "+ TITLE); 23 | 24 | var result = "Failed"; 25 | var exception = "No exception thrown"; 26 | var expect = "Passed"; 27 | 28 | try { 29 | a=0; 30 | b=1; 31 | c=2; 32 | d=3; 33 | eval("if (a > b)\nelse c = d"); 34 | } catch ( e ) { 35 | result = expect; 36 | exception = e.toString(); 37 | } 38 | 39 | new TestCase( 40 | SECTION, 41 | "if (a > b)\nelse c = d" + 42 | " (threw " + exception +")", 43 | expect, 44 | result ); 45 | 46 | test(); 47 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/number-002.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: number-002.js 9 | Corresponds To: ecma/Number/15.7.4.3-2-n.js 10 | ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() 11 | Description: 12 | Returns this number value. 13 | 14 | The valueOf function is not generic; it generates a runtime error if its 15 | this value is not a Number object. Therefore it cannot be transferred to 16 | other kinds of objects for use as a method. 17 | 18 | Author: christine@netscape.com 19 | Date: 16 september 1997 20 | */ 21 | var SECTION = "number-002"; 22 | var VERSION = "JS1_4"; 23 | var TITLE = "Exceptions for Number.valueOf()"; 24 | 25 | startTest(); 26 | writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); 27 | 28 | var result = "Failed"; 29 | var exception = "No exception thrown"; 30 | var expect = "Passed"; 31 | 32 | try { 33 | object= new Object(); 34 | object.toString = Number.prototype.valueOf; 35 | result = object.toString(); 36 | } catch ( e ) { 37 | result = expect; 38 | exception = e.toString(); 39 | } 40 | 41 | new TestCase( 42 | SECTION, 43 | "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" + 44 | " (threw " + exception +")", 45 | expect, 46 | result ); 47 | 48 | test(); 49 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/number-003.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: number-003.js 9 | Corresponds To: 15.7.4.3-3.js 10 | ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() 11 | Description: 12 | Returns this number value. 13 | 14 | The valueOf function is not generic; it generates a runtime error if its 15 | this value is not a Number object. Therefore it cannot be transferred to 16 | other kinds of objects for use as a method. 17 | 18 | Author: christine@netscape.com 19 | Date: 16 september 1997 20 | */ 21 | var SECTION = "number-003"; 22 | var VERSION = "JS1_4"; 23 | var TITLE = "Exceptions for Number.valueOf()"; 24 | 25 | startTest(); 26 | writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); 27 | 28 | var result = "Failed"; 29 | var exception = "No exception thrown"; 30 | var expect = "Passed"; 31 | 32 | try { 33 | VALUE_OF = Number.prototype.valueOf; 34 | OBJECT = new String("Infinity"); 35 | OBJECT.valueOf = VALUE_OF; 36 | result = OBJECT.valueOf(); 37 | } catch ( e ) { 38 | result = expect; 39 | exception = e.toString(); 40 | } 41 | 42 | new TestCase( 43 | SECTION, 44 | "Assigning Number.prototype.valueOf as the valueOf of a String object " + 45 | " (threw " + exception +")", 46 | expect, 47 | result ); 48 | 49 | test(); 50 | 51 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/Exceptions/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/statement-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: statement-001.js 9 | Corresponds To: 12.6.2-9-n.js 10 | ECMA Section: 12.6.2 The for Statement 11 | 12 | 1. first expression is not present. 13 | 2. second expression is not present 14 | 3. third expression is not present 15 | 16 | 17 | Author: christine@netscape.com 18 | Date: 15 september 1997 19 | */ 20 | 21 | var SECTION = "statement-001.js"; 22 | // var SECTION = "12.6.2-9-n"; 23 | var VERSION = "ECMA_1"; 24 | var TITLE = "The for statement"; 25 | 26 | startTest(); 27 | writeHeaderToLog( SECTION + " "+ TITLE); 28 | 29 | var result = "Failed"; 30 | var exception = "No exception thrown"; 31 | var expect = "Passed"; 32 | 33 | try { 34 | eval("for (i) {\n}"); 35 | } catch ( e ) { 36 | result = expect; 37 | exception = e.toString(); 38 | } 39 | 40 | new TestCase( 41 | SECTION, 42 | "for(i) {}" + 43 | " (threw " + exception +")", 44 | expect, 45 | result ); 46 | 47 | test(); 48 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/statement-004.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: statement-004.js 9 | Corresponds To: 12.6.3-1.js 10 | ECMA Section: 12.6.3 The for...in Statement 11 | Description: 12 | Author: christine@netscape.com 13 | Date: 11 september 1997 14 | */ 15 | var SECTION = "statement-004"; 16 | var VERSION = "JS1_4"; 17 | var TITLE = "The for..in statement"; 18 | 19 | startTest(); 20 | writeHeaderToLog( SECTION + " "+ TITLE); 21 | 22 | var result = "Failed"; 23 | var exception = "No exception thrown"; 24 | var expect = "Passed"; 25 | 26 | try { 27 | var o = new MyObject(); 28 | 29 | eval("for ( \"a\" in o) {\n" 30 | + "result += this[p];\n" 31 | + "}"); 32 | 33 | } catch ( e ) { 34 | result = expect; 35 | exception = e.toString(); 36 | } 37 | 38 | new TestCase( 39 | SECTION, 40 | "bad left-hand side expression" + 41 | " (threw " + exception +")", 42 | expect, 43 | result ); 44 | 45 | test(); 46 | 47 | 48 | function MyObject() { 49 | this.value = 2; 50 | this[0] = 4; 51 | return this; 52 | } 53 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/statement-005.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: statement-005.js 9 | Corresponds To: 12.6.3-8-n.js 10 | ECMA Section: 12.6.3 The for...in Statement 11 | Description: 12 | Author: christine@netscape.com 13 | Date: 11 september 1997 14 | */ 15 | var SECTION = "statement-005"; 16 | var VERSION = "JS1_4"; 17 | var TITLE = "The for..in statement"; 18 | 19 | startTest(); 20 | writeHeaderToLog( SECTION + " "+ TITLE); 21 | 22 | var result = "Failed"; 23 | var exception = "No exception thrown"; 24 | var expect = "Passed"; 25 | 26 | try { 27 | var o = new MyObject(); 28 | result = 0; 29 | 30 | eval("for (1 in o) {\n" 31 | + "result += this[p];" 32 | + "}\n"); 33 | } catch ( e ) { 34 | result = expect; 35 | exception = e.toString(); 36 | } 37 | 38 | new TestCase( 39 | SECTION, 40 | "bad left-hand side expression" + 41 | " (threw " + exception +")", 42 | expect, 43 | result ); 44 | 45 | test(); 46 | 47 | function MyObject() { 48 | this.value = 2; 49 | this[0] = 4; 50 | return this; 51 | } 52 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/statement-006.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: statement-006.js 9 | Corresponds To: 12.6.3-9-n.js 10 | ECMA Section: 12.6.3 The for...in Statement 11 | Description: 12 | 13 | Author: christine@netscape.com 14 | Date: 11 september 1997 15 | */ 16 | var SECTION = "statement-006"; 17 | var VERSION = "JS1_4"; 18 | var TITLE = "The for..in statement"; 19 | 20 | startTest(); 21 | writeHeaderToLog( SECTION + " "+ TITLE); 22 | 23 | var result = "Failed"; 24 | var exception = "No exception thrown"; 25 | var expect = "Passed"; 26 | 27 | try { 28 | var o = new MyObject(); 29 | var result = 0; 30 | for ( var o in foo) { 31 | result += this[o]; 32 | } 33 | } catch ( e ) { 34 | result = expect; 35 | exception = e.toString(); 36 | } 37 | 38 | new TestCase( 39 | SECTION, 40 | "object is not defined" + 41 | " (threw " + exception +")", 42 | expect, 43 | result ); 44 | 45 | test(); 46 | 47 | function MyObject() { 48 | this.value = 2; 49 | this[0] = 4; 50 | return this; 51 | } 52 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/statement-007.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: statement-007.js 9 | Corresponds To: 12.7-1-n.js 10 | ECMA Section: 12.7 The continue statement 11 | Description: 12 | 13 | Author: christine@netscape.com 14 | Date: 12 november 1997 15 | */ 16 | var SECTION = "statement-007"; 17 | var VERSION = "JS1_4"; 18 | var TITLE = "The continue statement"; 19 | 20 | startTest(); 21 | writeHeaderToLog( SECTION + " "+ TITLE); 22 | 23 | var result = "Failed"; 24 | var exception = "No exception thrown"; 25 | var expect = "Passed"; 26 | 27 | try { 28 | eval("continue;"); 29 | } catch ( e ) { 30 | result = expect; 31 | exception = e.toString(); 32 | } 33 | 34 | new TestCase( 35 | SECTION, 36 | "continue outside of an iteration statement" + 37 | " (threw " + exception +")", 38 | expect, 39 | result ); 40 | 41 | test(); 42 | 43 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/statement-008.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: statement-008.js 9 | Corresponds To: 12.8-1-n.js 10 | ECMA Section: 12.8 The break statement 11 | Description: 12 | 13 | Author: christine@netscape.com 14 | Date: 12 november 1997 15 | */ 16 | var SECTION = "statement-008"; 17 | var VERSION = "JS1_4"; 18 | var TITLE = "The break in statement"; 19 | 20 | startTest(); 21 | writeHeaderToLog( SECTION + " "+ TITLE); 22 | 23 | var result = "Failed"; 24 | var exception = "No exception thrown"; 25 | var expect = "Passed"; 26 | 27 | try { 28 | eval("break;"); 29 | } catch ( e ) { 30 | result = expect; 31 | exception = e.toString(); 32 | } 33 | 34 | new TestCase( 35 | SECTION, 36 | "break outside of an iteration statement" + 37 | " (threw " + exception +")", 38 | expect, 39 | result ); 40 | 41 | test(); 42 | 43 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/statement-009.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: 12.9-1-n.js 9 | ECMA Section: 12.9 The return statement 10 | Description: 11 | 12 | Author: christine@netscape.com 13 | Date: 12 november 1997 14 | */ 15 | var SECTION = "12.9-1-n"; 16 | var VERSION = "ECMA_1"; 17 | var TITLE = "The return statement"; 18 | 19 | startTest(); 20 | writeHeaderToLog( SECTION + " The return statement"); 21 | 22 | var result = "Failed"; 23 | var exception = "No exception thrown"; 24 | var expect = "Passed"; 25 | 26 | try { 27 | eval("return;"); 28 | } catch ( e ) { 29 | result = expect; 30 | exception = e.toString(); 31 | } 32 | 33 | new TestCase( 34 | SECTION, 35 | "return outside of a function" + 36 | " (threw " + exception +")", 37 | expect, 38 | result ); 39 | 40 | test(); 41 | 42 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Exceptions/string-002.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: string-002.js 9 | Corresponds To: 15.5.4.3-3-n.js 10 | ECMA Section: 15.5.4.3 String.prototype.valueOf() 11 | 12 | Description: Returns this string value. 13 | 14 | The valueOf function is not generic; it generates a 15 | runtime error if its this value is not a String object. 16 | Therefore it connot be transferred to the other kinds of 17 | objects for use as a method. 18 | 19 | Author: christine@netscape.com 20 | Date: 1 october 1997 21 | */ 22 | var SECTION = "string-002"; 23 | var VERSION = "JS1_4"; 24 | var TITLE = "String.prototype.valueOf"; 25 | 26 | startTest(); 27 | writeHeaderToLog( SECTION + " "+ TITLE); 28 | 29 | var result = "Failed"; 30 | var exception = "No exception thrown"; 31 | var expect = "Passed"; 32 | 33 | try { 34 | var OBJECT =new Object(); 35 | OBJECT.valueOf = String.prototype.valueOf; 36 | result = OBJECT.valueOf(); 37 | } catch ( e ) { 38 | result = expect; 39 | exception = e.toString(); 40 | } 41 | 42 | new TestCase( 43 | SECTION, 44 | "OBJECT = new Object; OBJECT.valueOf = String.prototype.valueOf;"+ 45 | "result = OBJECT.valueOf();" + 46 | " (threw " + exception +")", 47 | expect, 48 | result ); 49 | 50 | test(); 51 | 52 | 53 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Expressions/browser.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/Expressions/browser.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Expressions/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/Expressions/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/FunctionObjects/apply-001-n.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- 2 | * This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | print("STATUS: f.apply crash test."); 8 | 9 | print("BUGNUMBER: 21836"); 10 | 11 | function f () 12 | { 13 | } 14 | 15 | var SECTION = "apply-001-n"; 16 | var VERSION = "ECMA_1"; 17 | startTest(); 18 | var TITLE = "f.apply(2,2) doesn't crash"; 19 | 20 | writeHeaderToLog( SECTION + " "+ TITLE); 21 | 22 | DESCRIPTION = "f.apply(2,2) doesn't crash"; 23 | EXPECTED = "error"; 24 | 25 | new TestCase( SECTION, "f.apply(2,2) doesn't crash", "error", eval("f.apply(2,2)") ); 26 | 27 | test(); 28 | 29 | 30 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/FunctionObjects/browser.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/FunctionObjects/browser.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/FunctionObjects/call-1.js: -------------------------------------------------------------------------------- 1 | /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: call-1.js 9 | Section: Function.prototype.call 10 | Description: 11 | 12 | 13 | Author: christine@netscape.com 14 | Date: 12 november 1997 15 | */ 16 | var SECTION = "call-1"; 17 | var VERSION = "ECMA_2"; 18 | var TITLE = "Function.prototype.call"; 19 | 20 | startTest(); 21 | writeHeaderToLog( SECTION + " "+ TITLE); 22 | 23 | new TestCase( SECTION, 24 | "ConvertToString.call(this, this)", 25 | GLOBAL, 26 | ConvertToString.call(this, this)); 27 | 28 | new TestCase( SECTION, 29 | "ConvertToString.call(Boolean, Boolean.prototype)", 30 | "false", 31 | ConvertToString.call(Boolean, Boolean.prototype)); 32 | 33 | new TestCase( SECTION, 34 | "ConvertToString.call(Boolean, Boolean.prototype.valueOf())", 35 | "false", 36 | ConvertToString.call(Boolean, Boolean.prototype.valueOf())); 37 | 38 | test(); 39 | 40 | function ConvertToString(obj) { 41 | return obj +""; 42 | } 43 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/FunctionObjects/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/FunctionObjects/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/LexicalConventions/browser.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/LexicalConventions/browser.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/LexicalConventions/keywords-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: 9 | * ECMA Section: 10 | * Description: 11 | * 12 | * 13 | * Author: christine@netscape.com 14 | * Date: 11 August 1998 15 | */ 16 | var SECTION = ""; 17 | var VERSION = "ECMA_2"; 18 | var TITLE = "Keywords"; 19 | 20 | startTest(); 21 | 22 | print("This test requires option javascript.options.strict enabled"); 23 | 24 | if (!options().match(/strict/)) 25 | { 26 | options('strict'); 27 | } 28 | if (!options().match(/werror/)) 29 | { 30 | options('werror'); 31 | } 32 | 33 | var result = "failed"; 34 | 35 | try { 36 | eval("super;"); 37 | } 38 | catch (x) { 39 | if (x instanceof SyntaxError) 40 | result = x.name; 41 | } 42 | 43 | AddTestCase( 44 | "using the expression \"super\" shouldn't cause js to crash", 45 | "SyntaxError", 46 | result ); 47 | 48 | test(); 49 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/LexicalConventions/regexp-literals-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: LexicalConventions/regexp-literals-001.js 9 | * ECMA Section: 7.8.5 10 | * Description: 11 | * 12 | * 13 | * Author: christine@netscape.com 14 | * Date: 11 August 1998 15 | */ 16 | var SECTION = "LexicalConventions/regexp-literals-001.js"; 17 | var VERSION = "ECMA_2"; 18 | var TITLE = "Regular Expression Literals"; 19 | 20 | startTest(); 21 | 22 | // Regular Expression Literals may not be empty; // should be regarded 23 | // as a comment, not a RegExp literal. 24 | 25 | s = //; 26 | 27 | "passed"; 28 | 29 | AddTestCase( 30 | "// should be a comment, not a regular expression literal", 31 | "passed", 32 | String(s)); 33 | 34 | AddTestCase( 35 | "// typeof object should be type of object declared on following line", 36 | "passed", 37 | (typeof s) == "string" ? "passed" : "failed" ); 38 | 39 | AddTestCase( 40 | "// should not return an object of the type RegExp", 41 | "passed", 42 | (typeof s == "object") ? "failed" : "passed" ); 43 | 44 | test(); 45 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/LexicalConventions/regexp-literals-002.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: LexicalConventions/regexp-literals-002.js 9 | * ECMA Section: 7.8.5 10 | * Description: Based on ECMA 2 Draft 8 October 1999 11 | * 12 | * Author: christine@netscape.com 13 | * Date: 19 February 1999 14 | */ 15 | var SECTION = "LexicalConventions/regexp-literals-002.js"; 16 | var VERSION = "ECMA_2"; 17 | var TITLE = "Regular Expression Literals"; 18 | 19 | startTest(); 20 | 21 | // A regular expression literal represents an object of type RegExp. 22 | 23 | AddTestCase( 24 | "// A regular expression literal represents an object of type RegExp.", 25 | "true", 26 | (/x*/ instanceof RegExp).toString() ); 27 | 28 | test(); 29 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/LexicalConventions/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/LexicalConventions/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/README: -------------------------------------------------------------------------------- 1 | ECMA 262 Edition 2 2 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/RegExp/browser.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/RegExp/browser.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/RegExp/regress-001.js: -------------------------------------------------------------------------------- 1 | /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: RegExp/regress-001.js 9 | * ECMA Section: N/A 10 | * Description: Regression test case: 11 | * JS regexp anchoring on empty match bug 12 | * http://bugzilla.mozilla.org/show_bug.cgi?id=2157 13 | * 14 | * Author: christine@netscape.com 15 | * Date: 19 February 1999 16 | */ 17 | var SECTION = "RegExp/hex-001.js"; 18 | var VERSION = "ECMA_2"; 19 | var TITLE = "JS regexp anchoring on empty match bug"; 20 | var BUGNUMBER = "2157"; 21 | 22 | startTest(); 23 | 24 | AddRegExpCases( /a||b/.exec(''), 25 | "/a||b/.exec('')", 26 | 1, 27 | [''] ); 28 | 29 | test(); 30 | 31 | function AddRegExpCases( regexp, str_regexp, length, matches_array ) { 32 | 33 | AddTestCase( 34 | "( " + str_regexp + " ).length", 35 | regexp.length, 36 | regexp.length ); 37 | 38 | 39 | for ( var matches = 0; matches < matches_array.length; matches++ ) { 40 | AddTestCase( 41 | "( " + str_regexp + " )[" + matches +"]", 42 | matches_array[matches], 43 | regexp[matches] ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/RegExp/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/RegExp/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/browser.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/Statements/browser.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/dowhile-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: dowhile-001 9 | * ECMA Section: 10 | * Description: do...while statements 11 | * 12 | * 13 | * 14 | * Author: christine@netscape.com 15 | * Date: 11 August 1998 16 | */ 17 | var SECTION = "dowhile-002"; 18 | var VERSION = "ECMA_2"; 19 | var TITLE = "do...while with a labeled continue statement"; 20 | 21 | startTest(); 22 | writeHeaderToLog( SECTION + " "+ TITLE); 23 | 24 | LabeledContinue( 0, 1 ); 25 | LabeledContinue( 1, 1 ); 26 | LabeledContinue( -1, 1 ); 27 | LabeledContinue( 5, 5 ); 28 | 29 | test(); 30 | 31 | function LabeledContinue( limit, expect ) { 32 | i = 0; 33 | woohoo: 34 | do { 35 | i++; 36 | continue woohoo; 37 | } while ( i < limit ); 38 | 39 | new TestCase( 40 | SECTION, 41 | "do while ( " + i +" < " + limit +" )", 42 | expect, 43 | i ); 44 | } 45 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/if-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: if-001.js 9 | * ECMA Section: 10 | * Description: The if statement 11 | * 12 | * Verify that assignment in the if expression is evaluated correctly. 13 | * Verifies the fix for bug http://scopus/bugsplat/show_bug.cgi?id=148822. 14 | * 15 | * Author: christine@netscape.com 16 | * Date: 28 August 1998 17 | */ 18 | var SECTION = "for-001"; 19 | var VERSION = "ECMA_2"; 20 | var TITLE = "The if statement"; 21 | var BUGNUMBER="148822"; 22 | 23 | startTest(); 24 | writeHeaderToLog( SECTION + " "+ TITLE); 25 | 26 | var a = 0; 27 | var b = 0; 28 | var result = "passed"; 29 | 30 | if ( a = b ) { 31 | result = "failed: a = b should return 0"; 32 | } 33 | 34 | new TestCase( 35 | SECTION, 36 | "if ( a = b ), where a and b are both equal to 0", 37 | "passed", 38 | result ); 39 | 40 | 41 | test(); 42 | 43 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/label-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: label-001.js 9 | * ECMA Section: 10 | * Description: Labeled statements 11 | * 12 | * Labeled break and continue within a for loop. 13 | * 14 | * 15 | * Author: christine@netscape.com 16 | * Date: 11 August 1998 17 | */ 18 | var SECTION = "label-003"; 19 | var VERSION = "ECMA_2"; 20 | var TITLE = "Labeled statements"; 21 | 22 | startTest(); 23 | writeHeaderToLog( SECTION + " "+ TITLE); 24 | 25 | LabelTest(0, 0); 26 | LabelTest(1, 1) 27 | LabelTest(-1, 1000); 28 | LabelTest(false, 0); 29 | LabelTest(true, 1); 30 | 31 | test(); 32 | 33 | function LabelTest( limit, expect) { 34 | woo: for ( var result = 0; result < 1000; result++ ) { if (result == limit) { break woo; } else { continue woo; } }; 35 | 36 | new TestCase( 37 | SECTION, 38 | "break out of a labeled for loop: "+ limit, 39 | expect, 40 | result ); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/label-003.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | // The colon for a labeled statement may be on a separate line. 7 | var x; 8 | label 9 | : { 10 | x = 1; 11 | break label; 12 | x = 2; 13 | } 14 | assertEq(x, 1); 15 | reportCompare(0, 0, 'ok'); 16 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/Statements/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/switch-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: switch-001.js 9 | * ECMA Section: 10 | * Description: The switch Statement 11 | * 12 | * A simple switch test with no abrupt completions. 13 | * 14 | * Author: christine@netscape.com 15 | * Date: 11 August 1998 16 | * 17 | */ 18 | var SECTION = "switch-001"; 19 | var VERSION = "ECMA_2"; 20 | var TITLE = "The switch statement"; 21 | 22 | var BUGNUMBER="315767"; 23 | 24 | startTest(); 25 | writeHeaderToLog( SECTION + " "+ TITLE); 26 | 27 | SwitchTest( 0, 126 ); 28 | SwitchTest( 1, 124 ); 29 | SwitchTest( 2, 120 ); 30 | SwitchTest( 3, 112 ); 31 | SwitchTest( 4, 64 ); 32 | SwitchTest( 5, 96 ); 33 | SwitchTest( true, 96 ); 34 | SwitchTest( false, 96 ); 35 | SwitchTest( null, 96 ); 36 | SwitchTest( void 0, 96 ); 37 | SwitchTest( "0", 96 ); 38 | 39 | test(); 40 | 41 | function SwitchTest( input, expect ) { 42 | var result = 0; 43 | 44 | switch ( input ) { 45 | case 0: 46 | result += 2; 47 | case 1: 48 | result += 4; 49 | case 2: 50 | result += 8; 51 | case 3: 52 | result += 16; 53 | default: 54 | result += 32; 55 | case 4: 56 | result +=64; 57 | } 58 | 59 | new TestCase( 60 | SECTION, 61 | "switch with no breaks, case expressions are numbers. input is "+ 62 | input, 63 | expect, 64 | result ); 65 | } 66 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/switch-002.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: switch-002.js 9 | * ECMA Section: 10 | * Description: The switch Statement 11 | * 12 | * A simple switch test with no abrupt completions. 13 | * 14 | * Author: christine@netscape.com 15 | * Date: 11 August 1998 16 | * 17 | */ 18 | var SECTION = "switch-002"; 19 | var VERSION = "ECMA_2"; 20 | var TITLE = "The switch statement"; 21 | 22 | startTest(); 23 | writeHeaderToLog( SECTION + " "+ TITLE); 24 | 25 | SwitchTest( 0, 6 ); 26 | SwitchTest( 1, 4 ); 27 | SwitchTest( 2, 56 ); 28 | SwitchTest( 3, 48 ); 29 | SwitchTest( 4, 64 ); 30 | SwitchTest( true, 32 ); 31 | SwitchTest( false, 32 ); 32 | SwitchTest( null, 32 ); 33 | SwitchTest( void 0, 32 ); 34 | SwitchTest( "0", 32 ); 35 | 36 | test(); 37 | 38 | function SwitchTest( input, expect ) { 39 | var result = 0; 40 | 41 | switch ( input ) { 42 | case 0: 43 | result += 2; 44 | case 1: 45 | result += 4; 46 | break; 47 | case 2: 48 | result += 8; 49 | case 3: 50 | result += 16; 51 | default: 52 | result += 32; 53 | break; 54 | case 4: 55 | result += 64; 56 | } 57 | 58 | new TestCase( 59 | SECTION, 60 | "switch with no breaks: input is " + input, 61 | expect, 62 | result ); 63 | } 64 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/switch-003.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: switch-003.js 9 | * ECMA Section: 10 | * Description: The switch Statement 11 | * 12 | * Attempt to verify that case statements are evaluated in source order 13 | * 14 | * Author: christine@netscape.com 15 | * Date: 11 August 1998 16 | * 17 | */ 18 | var SECTION = "switch-003"; 19 | var VERSION = "ECMA_2"; 20 | var TITLE = "The switch statement"; 21 | 22 | startTest(); 23 | writeHeaderToLog( SECTION + " "+ TITLE); 24 | 25 | SwitchTest( "a", "abc" ); 26 | SwitchTest( "b", "bc" ); 27 | SwitchTest( "c", "c" ); 28 | SwitchTest( "d", "*abc" ); 29 | SwitchTest( "v", "*abc" ); 30 | SwitchTest( "w", "w*abc" ); 31 | SwitchTest( "x", "xw*abc" ); 32 | SwitchTest( "y", "yxw*abc" ); 33 | SwitchTest( "z", "zyxw*abc" ); 34 | // SwitchTest( new java.lang.String("z"), "*abc" ); 35 | 36 | test(); 37 | 38 | function SwitchTest( input, expect ) { 39 | var result = ""; 40 | 41 | switch ( input ) { 42 | case "z": result += "z"; 43 | case "y": result += "y"; 44 | case "x": result += "x"; 45 | case "w": result += "w"; 46 | default: result += "*"; 47 | case "a": result += "a"; 48 | case "b": result += "b"; 49 | case "c": result += "c"; 50 | } 51 | 52 | new TestCase( 53 | SECTION, 54 | "switch with no breaks: input is " + input, 55 | expect, 56 | result ); 57 | } 58 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/try-004.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: try-004.js 9 | * ECMA Section: 10 | * Description: The try statement 11 | * 12 | * This test has a try with one catch block but no finally. 13 | * 14 | * Author: christine@netscape.com 15 | * Date: 11 August 1998 16 | */ 17 | var SECTION = "try-004"; 18 | var VERSION = "ECMA_2"; 19 | var TITLE = "The try statement"; 20 | 21 | startTest(); 22 | writeHeaderToLog( SECTION + " "+ TITLE); 23 | 24 | TryToCatch( "Math.PI", Math.PI ); 25 | TryToCatch( "Thrower(5)", "Caught 5" ); 26 | TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); 27 | 28 | test(); 29 | 30 | function Thrower( v ) { 31 | throw "Caught " + v; 32 | } 33 | 34 | /** 35 | * Evaluate a string. Catch any exceptions thrown. If no exception is 36 | * expected, verify the result of the evaluation. If an exception is 37 | * expected, verify that we got the right exception. 38 | */ 39 | 40 | function TryToCatch( value, expect ) { 41 | try { 42 | result = eval( value ); 43 | } catch ( e ) { 44 | result = e; 45 | } 46 | 47 | new TestCase( 48 | SECTION, 49 | "eval( " + value +" )", 50 | expect, 51 | result ); 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/try-008.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: try-008.js 9 | * ECMA Section: 10 | * Description: The try statement 11 | * 12 | * This test has a try block in a constructor. 13 | * 14 | * 15 | * Author: christine@netscape.com 16 | * Date: 11 August 1998 17 | */ 18 | var SECTION = "try-008"; 19 | var VERSION = "ECMA_2"; 20 | var TITLE = "The try statement: try in a constructor"; 21 | 22 | startTest(); 23 | writeHeaderToLog( SECTION + " "+ TITLE); 24 | 25 | function Integer( value, exception ) { 26 | try { 27 | this.value = checkValue( value ); 28 | } catch ( e ) { 29 | this.value = e.toString(); 30 | } 31 | 32 | new TestCase( 33 | SECTION, 34 | "Integer( " + value +" )", 35 | (exception ? INVALID_INTEGER_VALUE +": " + value : this.value), 36 | this.value ); 37 | } 38 | 39 | var INVALID_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; 40 | 41 | function checkValue( value ) { 42 | if ( Math.floor(value) != value || isNaN(value) ) { 43 | throw ( INVALID_INTEGER_VALUE +": " + value ); 44 | } else { 45 | return value; 46 | } 47 | } 48 | 49 | // add test cases 50 | 51 | new Integer( 3, false ); 52 | new Integer( NaN, true ); 53 | new Integer( 0, false ); 54 | new Integer( Infinity, false ); 55 | new Integer( -2.12, true ); 56 | new Integer( Math.LN2, true ); 57 | 58 | 59 | test(); 60 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/Statements/while-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: while-001 9 | * ECMA Section: 10 | * Description: while statement 11 | * 12 | * Verify that the while statement is not executed if the while expression is 13 | * false 14 | * 15 | * Author: christine@netscape.com 16 | * Date: 11 August 1998 17 | */ 18 | var SECTION = "while-001"; 19 | var VERSION = "ECMA_2"; 20 | var TITLE = "while statement"; 21 | 22 | startTest(); 23 | writeHeaderToLog( SECTION + " "+ TITLE); 24 | 25 | DoWhile(); 26 | test(); 27 | 28 | function DoWhile() { 29 | result = "pass"; 30 | 31 | while (false) { 32 | result = "fail"; 33 | break; 34 | } 35 | 36 | new TestCase( 37 | SECTION, 38 | "while statement: don't evaluate statement is expression is false", 39 | "pass", 40 | result ); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/String/browser.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/String/browser.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/String/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/String/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/browser.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/browser.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/extensions/browser.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/extensions/browser.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/extensions/constructor-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: RegExp/constructor-001.js 9 | * ECMA Section: 15.7.3.3 10 | * Description: Based on ECMA 2 Draft 7 February 1999 11 | * 12 | * Author: christine@netscape.com 13 | * Date: 19 February 1999 14 | */ 15 | var SECTION = "RegExp/constructor-001"; 16 | var VERSION = "ECMA_2"; 17 | var TITLE = "new RegExp()"; 18 | 19 | startTest(); 20 | 21 | /* 22 | * for each test case, verify: 23 | * - verify that [[Class]] property is RegExp 24 | * - prototype property should be set to RegExp.prototype 25 | * - source is set to the empty string 26 | * - global property is set to false 27 | * - ignoreCase property is set to false 28 | * - multiline property is set to false 29 | * - lastIndex property is set to 0 30 | */ 31 | 32 | RegExp.prototype.getClassProperty = Object.prototype.toString; 33 | var re = new RegExp(); 34 | 35 | AddTestCase( 36 | "new RegExp().__proto__", 37 | RegExp.prototype, 38 | re.__proto__ 39 | ); 40 | 41 | test() 42 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/extensions/function-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | * File Name: RegExp/function-001.js 9 | * ECMA Section: 15.7.2.1 10 | * Description: Based on ECMA 2 Draft 7 February 1999 11 | * 12 | * Author: christine@netscape.com 13 | * Date: 19 February 1999 14 | */ 15 | var SECTION = "RegExp/function-001"; 16 | var VERSION = "ECMA_2"; 17 | var TITLE = "RegExp( pattern, flags )"; 18 | 19 | startTest(); 20 | 21 | /* 22 | * for each test case, verify: 23 | * - verify that [[Class]] property is RegExp 24 | * - prototype property should be set to RegExp.prototype 25 | * - source is set to the empty string 26 | * - global property is set to false 27 | * - ignoreCase property is set to false 28 | * - multiline property is set to false 29 | * - lastIndex property is set to 0 30 | */ 31 | 32 | RegExp.prototype.getClassProperty = Object.prototype.toString; 33 | var re = new RegExp(); 34 | 35 | AddTestCase( 36 | "new RegExp().__proto__", 37 | RegExp.prototype, 38 | re.__proto__ 39 | ); 40 | 41 | test() 42 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/extensions/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/extensions/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/instanceof/browser.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/instanceof/browser.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/instanceof/instanceof-001.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: instanceof-1.js 9 | ECMA Section: 10 | Description: instanceof operator 11 | 12 | Author: christine@netscape.com 13 | Date: 12 november 1997 14 | */ 15 | var SECTION = ""; 16 | var VERSION = "ECMA_2"; 17 | var TITLE = "instanceof operator"; 18 | 19 | startTest(); 20 | writeHeaderToLog( SECTION + " "+ TITLE); 21 | 22 | var b = new Boolean(); 23 | 24 | new TestCase( SECTION, 25 | "var b = new Boolean(); b instanceof Boolean", 26 | true, 27 | b instanceof Boolean ); 28 | 29 | new TestCase( SECTION, 30 | "b instanceof Object", 31 | true, 32 | b instanceof Object ); 33 | 34 | test(); 35 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/instanceof/instanceof-002.js: -------------------------------------------------------------------------------- 1 | /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: 9 | ECMA Section: 10 | Description: Call Objects 11 | 12 | 13 | 14 | Author: christine@netscape.com 15 | Date: 12 november 1997 16 | */ 17 | var SECTION = ""; 18 | var VERSION = "ECMA_2"; 19 | var TITLE = "The Call Constructor"; 20 | 21 | startTest(); 22 | writeHeaderToLog( SECTION + " "+ TITLE); 23 | 24 | var b = new Boolean(); 25 | 26 | new TestCase( SECTION, 27 | "var b = new Boolean(); b instanceof Boolean", 28 | true, 29 | b instanceof Boolean ); 30 | 31 | new TestCase( SECTION, 32 | "b instanceof Object", 33 | true, 34 | b instanceof Object ); 35 | 36 | new TestCase( SECTION, 37 | "b instanceof Array", 38 | false, 39 | b instanceof Array ); 40 | 41 | new TestCase( SECTION, 42 | "true instanceof Boolean", 43 | false, 44 | true instanceof Boolean ); 45 | 46 | new TestCase( SECTION, 47 | "Boolean instanceof Object", 48 | true, 49 | Boolean instanceof Object ); 50 | test(); 51 | 52 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/instanceof/instanceof-003.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | 7 | /** 8 | File Name: instanceof-003.js 9 | ECMA Section: 10 | Description: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 11 | 12 | js> function Foo() {} 13 | js> theproto = {}; 14 | [object Object] 15 | js> Foo.prototype = theproto 16 | [object Object] 17 | js> theproto instanceof Foo 18 | true 19 | 20 | I think this should be 'false' 21 | 22 | 23 | Author: christine@netscape.com 24 | Date: 12 november 1997 25 | 26 | Modified to conform to ECMA3 27 | https://bugzilla.mozilla.org/show_bug.cgi?id=281606 28 | */ 29 | var SECTION = "instanceof-003"; 30 | var VERSION = "ECMA_2"; 31 | var TITLE = "instanceof operator"; 32 | var BUGNUMBER ="7635"; 33 | 34 | startTest(); 35 | 36 | function Foo() {}; 37 | theproto = {}; 38 | Foo.prototype = theproto; 39 | 40 | AddTestCase( 41 | "function Foo() = {}; theproto = {}; Foo.prototype = theproto; " + 42 | "theproto instanceof Foo", 43 | false, 44 | theproto instanceof Foo ); 45 | 46 | 47 | var o = {}; 48 | 49 | // https://bugzilla.mozilla.org/show_bug.cgi?id=281606 50 | try 51 | { 52 | AddTestCase( 53 | "o = {}; o instanceof o", 54 | "error", 55 | o instanceof o ); 56 | } 57 | catch(e) 58 | { 59 | AddTestCase( 60 | "o = {}; o instanceof o", 61 | "error", 62 | "error" ); 63 | } 64 | 65 | test(); 66 | -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/instanceof/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/instanceof/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/shell.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binast/binjs-ref/4261ca204354423faa1c5e4236dff5e93b20a09d/tests/data/spidermonkey/ecma_2/shell.js -------------------------------------------------------------------------------- /tests/data/spidermonkey/ecma_2/template.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 | /* 3 | * Any copyright is dedicated to the Public Domain. 4 | * http://creativecommons.org/licenses/publicdomain/ 5 | * Contributor: 6 | */ 7 | 8 | 9 | /** 10 | * File Name: template.js 11 | * Reference: ** replace with bugzilla URL or document reference ** 12 | * Description: ** replace with description of test ** 13 | * Author: ** replace with your e-mail address ** 14 | */ 15 | 16 | var SECTION = ""; // if ECMA test, provide section number 17 | var VERSION = "ECMA_2"; // Version of JavaScript or ECMA 18 | var TITLE = ""; // Provide ECMA section title or description 19 | var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report 20 | 21 | startTest(); // leave this alone 22 | 23 | 24 | /* Calls to AddTestCase here */ 25 | 26 | test(); // leave this alone 27 | --------------------------------------------------------------------------------