OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --harmony-arrow-functions |
| 6 |
| 7 // The following are tests from: |
| 8 // http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax |
| 9 |
| 10 // ''=>'' has only lexical ''this'', no dynamic ''this'' |
| 11 var obj = { |
| 12 method: function () { |
| 13 return () => this; |
| 14 } |
| 15 }; |
| 16 assertSame(obj, obj.method()()); |
| 17 |
| 18 var fake = {steal: obj.method()}; |
| 19 assertSame(obj, fake.steal()); |
| 20 |
| 21 // But ''function'' still has dynamic ''this'' of course |
| 22 var real = {borrow: obj.method}; |
| 23 assertSame(real, real.borrow()()); |
OLD | NEW |