Index: test/mjsunit/harmony/arrow-functions-scoping.js |
diff --git a/test/mjsunit/harmony/arrow-functions-scoping.js b/test/mjsunit/harmony/arrow-functions-scoping.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c2433552896d63ec3ca41f3b0313ca6fd5fbf7f7 |
--- /dev/null |
+++ b/test/mjsunit/harmony/arrow-functions-scoping.js |
@@ -0,0 +1,36 @@ |
+// Copyright 2015 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Flags: --harmony-arrow-functions |
+ |
+// The following are tests from: |
+// http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax |
+var obj = { |
+ method: function () { |
+ return () => this; |
+ } |
+}; |
+assertSame(obj, obj.method()()); |
+ |
+var fake = { steal: obj.method() }; |
+assertSame(obj, fake.steal()); |
+ |
+var real = { borrow: obj.method }; |
+assertSame(real, real.borrow()()); |
+ |
+// Same, but using eval() for the arrow function. |
+obj = { |
+ method: function () { |
+ return eval("() => this"); |
+ } |
+}; |
+assertSame(obj, obj.method()()); |
+ |
+// Using eval() to define the whole object. |
+eval('obj = { method: function () { return () => this } }'); |
+assertSame(obj, obj.method()()); |
+ |
+// Nested eval(). |
+eval('obj = { method: function () { return eval("() => this") } }'); |
+assertSame(obj, obj.method()()); |