1/* Copyright JS Foundation and other contributors, http://js.foundation 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16var y = 0 17var prot = Object.getPrototypeOf(/ /) 18 19prot.setY = function (v) { y = v } 20 21assert(y === 0) 22// Since arrow function is an assignment expression, this affects certain constructs 23var f = x => {} 24/ /.setY(5) 25assert(y === 5) 26 27var s 28// This is not a function call 29assert(eval("s = x => { return 1 }\n(3)") === 3) 30assert(typeof s === "function") 31 32// This is a function call 33assert(eval("s = function () { return 1 }\n(3)") === 1) 34assert(s === 1) 35 36var f = 5 ? x => 1 : x => 2 37assert(f() === 1) 38 39var f = [x => 2][0] 40assert(f() === 2) 41 42var f = 123; f += x => y 43assert(typeof f === "string") 44 45// Comma operator 46assert(eval("x => {}, 5") === 5) 47