tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

yield-in-object-destr-script.js (2766B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 
      6 // Destructuring binding patterns with var.
      7 var {a: yield} = {a: "yield-with-name"};
      8 assertEq(yield, "yield-with-name");
      9 
     10 var {yield} = {yield: "yield-with-shorthand"};
     11 assertEq(yield, "yield-with-shorthand");
     12 
     13 var {yield = 0} = {yield: "yield-with-coverinitname"};
     14 assertEq(yield, "yield-with-coverinitname");
     15 
     16 assertThrowsInstanceOf(() => eval(`
     17    "use strict";
     18    var {a: yield} = {};
     19 `), SyntaxError);
     20 
     21 assertThrowsInstanceOf(() => eval(`
     22    "use strict";
     23    var {yield} = {};
     24 `), SyntaxError);
     25 
     26 assertThrowsInstanceOf(() => eval(`
     27    "use strict";
     28    var {yield = 0} = {};
     29 `), SyntaxError);
     30 
     31 
     32 // Destructuring binding patterns with let.
     33 {
     34    let {a: yield} = {a: "yield-with-name"};
     35    assertEq(yield, "yield-with-name");
     36 }
     37 
     38 {
     39    let {yield} = {yield: "yield-with-shorthand"};
     40    assertEq(yield, "yield-with-shorthand");
     41 }
     42 
     43 {
     44    let {yield = 0} = {yield: "yield-with-coverinitname"};
     45    assertEq(yield, "yield-with-coverinitname");
     46 }
     47 
     48 assertThrowsInstanceOf(() => eval(`
     49    "use strict";
     50    let {a: yield} = {};
     51 `), SyntaxError);
     52 
     53 assertThrowsInstanceOf(() => eval(`
     54    "use strict";
     55    let {yield} = {};
     56 `), SyntaxError);
     57 
     58 assertThrowsInstanceOf(() => eval(`
     59    "use strict";
     60    let {yield = 0} = {};
     61 `), SyntaxError);
     62 
     63 
     64 // Destructuring binding patterns with const.
     65 {
     66    const {a: yield} = {a: "yield-with-name"};
     67    assertEq(yield, "yield-with-name");
     68 }
     69 
     70 {
     71    const {yield} = {yield: "yield-with-shorthand"};
     72    assertEq(yield, "yield-with-shorthand");
     73 }
     74 
     75 {
     76    const {yield = 0} = {yield: "yield-with-coverinitname"};
     77    assertEq(yield, "yield-with-coverinitname");
     78 }
     79 
     80 assertThrowsInstanceOf(() => eval(`
     81    "use strict";
     82    const {a: yield} = {};
     83 `), SyntaxError);
     84 
     85 assertThrowsInstanceOf(() => eval(`
     86    "use strict";
     87    const {yield} = {};
     88 `), SyntaxError);
     89 
     90 assertThrowsInstanceOf(() => eval(`
     91    "use strict";
     92    const {yield = 0} = {};
     93 `), SyntaxError);
     94 
     95 
     96 // Destructuring assignment pattern.
     97 ({a: yield} = {a: "yield-with-name"});
     98 assertEq(yield, "yield-with-name");
     99 
    100 ({yield} = {yield: "yield-with-shorthand"});
    101 assertEq(yield, "yield-with-shorthand");
    102 
    103 ({yield = 0} = {yield: "yield-with-coverinitname"});
    104 assertEq(yield, "yield-with-coverinitname");
    105 
    106 assertThrowsInstanceOf(() => eval(`
    107    "use strict";
    108    ({a: yield} = {});
    109 `), SyntaxError);
    110 
    111 assertThrowsInstanceOf(() => eval(`
    112    "use strict";
    113    ({yield} = {});
    114 `), SyntaxError);
    115 
    116 assertThrowsInstanceOf(() => eval(`
    117    "use strict";
    118    ({yield = 0} = {});
    119 `), SyntaxError);
    120 
    121 
    122 if (typeof reportCompare === "function")
    123    reportCompare(0, 0, "ok");