yield-with-escape-in-object-destr-script.js (3006B)
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: yi\u0065ld} = {a: "yield-with-name"}; 8 assertEq(yield, "yield-with-name"); 9 10 var {yi\u0065ld} = {yield: "yield-with-shorthand"}; 11 assertEq(yield, "yield-with-shorthand"); 12 13 var {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}; 14 assertEq(yield, "yield-with-coverinitname"); 15 16 assertThrowsInstanceOf(() => eval(String.raw` 17 "use strict"; 18 var {a: yi\u0065ld} = {}; 19 `), SyntaxError); 20 21 assertThrowsInstanceOf(() => eval(String.raw` 22 "use strict"; 23 var {yi\u0065ld} = {}; 24 `), SyntaxError); 25 26 assertThrowsInstanceOf(() => eval(String.raw` 27 "use strict"; 28 var {yi\u0065ld = 0} = {}; 29 `), SyntaxError); 30 31 32 // Destructuring binding patterns with let. 33 { 34 let {a: yi\u0065ld} = {a: "yield-with-name"}; 35 assertEq(yield, "yield-with-name"); 36 } 37 38 { 39 let {yi\u0065ld} = {yield: "yield-with-shorthand"}; 40 assertEq(yield, "yield-with-shorthand"); 41 } 42 43 { 44 let {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}; 45 assertEq(yield, "yield-with-coverinitname"); 46 } 47 48 assertThrowsInstanceOf(() => eval(String.raw` 49 "use strict"; 50 let {a: yi\u0065ld} = {}; 51 `), SyntaxError); 52 53 assertThrowsInstanceOf(() => eval(String.raw` 54 "use strict"; 55 let {yi\u0065ld} = {}; 56 `), SyntaxError); 57 58 assertThrowsInstanceOf(() => eval(String.raw` 59 "use strict"; 60 let {yi\u0065ld = 0} = {}; 61 `), SyntaxError); 62 63 64 // Destructuring binding patterns with const. 65 { 66 const {a: yi\u0065ld} = {a: "yield-with-name"}; 67 assertEq(yield, "yield-with-name"); 68 } 69 70 { 71 const {yi\u0065ld} = {yield: "yield-with-shorthand"}; 72 assertEq(yield, "yield-with-shorthand"); 73 } 74 75 { 76 const {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}; 77 assertEq(yield, "yield-with-coverinitname"); 78 } 79 80 assertThrowsInstanceOf(() => eval(String.raw` 81 "use strict"; 82 const {a: yi\u0065ld} = {}; 83 `), SyntaxError); 84 85 assertThrowsInstanceOf(() => eval(String.raw` 86 "use strict"; 87 const {yi\u0065ld} = {}; 88 `), SyntaxError); 89 90 assertThrowsInstanceOf(() => eval(String.raw` 91 "use strict"; 92 const {yi\u0065ld = 0} = {}; 93 `), SyntaxError); 94 95 96 // Destructuring assignment pattern. 97 ({a: yi\u0065ld} = {a: "yield-with-name"}); 98 assertEq(yield, "yield-with-name"); 99 100 ({yi\u0065ld} = {yield: "yield-with-shorthand"}); 101 assertEq(yield, "yield-with-shorthand"); 102 103 ({yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}); 104 assertEq(yield, "yield-with-coverinitname"); 105 106 assertThrowsInstanceOf(() => eval(String.raw` 107 "use strict"; 108 ({a: yi\u0065ld} = {}); 109 `), SyntaxError); 110 111 assertThrowsInstanceOf(() => eval(String.raw` 112 "use strict"; 113 ({yi\u0065ld} = {}); 114 `), SyntaxError); 115 116 assertThrowsInstanceOf(() => eval(String.raw` 117 "use strict"; 118 ({yi\u0065ld = 0} = {}); 119 `), SyntaxError); 120 121 122 if (typeof reportCompare === "function") 123 reportCompare(0, 0, "ok");