| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --harmony-arrow-functions | |
| 6 | |
| 7 // Arrow functions are like functions, except they throw when using the | 5 // Arrow functions are like functions, except they throw when using the |
| 8 // "new" operator on them. | 6 // "new" operator on them. |
| 9 assertEquals("function", typeof (() => {})); | 7 assertEquals("function", typeof (() => {})); |
| 10 assertEquals(Function.prototype, Object.getPrototypeOf(() => {})); | 8 assertEquals(Function.prototype, Object.getPrototypeOf(() => {})); |
| 11 assertThrows(function() { new (() => {}); }, TypeError); | 9 assertThrows(function() { new (() => {}); }, TypeError); |
| 12 assertFalse("prototype" in (() => {})); | 10 assertFalse("prototype" in (() => {})); |
| 13 | 11 |
| 14 // Check the different syntax variations | 12 // Check the different syntax variations |
| 15 assertEquals(1, (() => 1)()); | 13 assertEquals(1, (() => 1)()); |
| 16 assertEquals(2, (a => a + 1)(1)); | 14 assertEquals(2, (a => a + 1)(1)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 (function testRestrictedFunctionPropertiesSloppy() { | 61 (function testRestrictedFunctionPropertiesSloppy() { |
| 64 var arrowFn = () => {}; | 62 var arrowFn = () => {}; |
| 65 assertFalse(arrowFn.hasOwnProperty("arguments")); | 63 assertFalse(arrowFn.hasOwnProperty("arguments")); |
| 66 assertThrows(function() { return arrowFn.arguments; }, TypeError); | 64 assertThrows(function() { return arrowFn.arguments; }, TypeError); |
| 67 assertThrows(function() { arrowFn.arguments = {}; }, TypeError); | 65 assertThrows(function() { arrowFn.arguments = {}; }, TypeError); |
| 68 | 66 |
| 69 assertFalse(arrowFn.hasOwnProperty("caller")); | 67 assertFalse(arrowFn.hasOwnProperty("caller")); |
| 70 assertThrows(function() { return arrowFn.caller; }, TypeError); | 68 assertThrows(function() { return arrowFn.caller; }, TypeError); |
| 71 assertThrows(function() { arrowFn.caller = {}; }, TypeError); | 69 assertThrows(function() { arrowFn.caller = {}; }, TypeError); |
| 72 })(); | 70 })(); |
| OLD | NEW |