diff options
author | Ali Ijaz Sheikh <ofrobots@google.com> | 2015-08-23 06:09:40 -0700 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2015-09-06 21:38:01 +1000 |
commit | 9fddd83cf9adf505bce2e2373881df0c4d41b261 (patch) | |
tree | 4272ce14c10fea496af2e78fc6debb187d613451 /deps/v8/test/mjsunit/harmony/arrow-functions-this.js | |
parent | 46b7d151674d138e7ea4342d5f3ada1208b87ff2 (diff) | |
download | node-new-9fddd83cf9adf505bce2e2373881df0c4d41b261.tar.gz |
deps: upgrade V8 to 4.5.103.24
Upgrade to the latest branch-head for V8 4.5. For the full commit log see
https://github.com/v8/v8-git-mirror/commits/4.5.103.24
PR-URL: https://github.com/nodejs/node/pull/2509
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/test/mjsunit/harmony/arrow-functions-this.js')
-rw-r--r-- | deps/v8/test/mjsunit/harmony/arrow-functions-this.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/harmony/arrow-functions-this.js b/deps/v8/test/mjsunit/harmony/arrow-functions-this.js new file mode 100644 index 0000000000..2c2ad075d2 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/arrow-functions-this.js @@ -0,0 +1,81 @@ +// 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 + +var object = {}; +var global = this; +var call = Function.call.bind(Function.call); + +var globalSloppyArrow = () => this; +var globalStrictArrow = () => { "use strict"; return this; }; +var globalSloppyArrowEval = (s) => eval(s); +var globalStrictArrowEval = (s) => { "use strict"; return eval(s); }; + +var sloppyFunctionArrow = function() { + return (() => this)(); +}; +var strictFunctionArrow = function() { + "use strict"; + return (() => this)(); +}; +var sloppyFunctionEvalArrow = function() { + return eval("(() => this)()"); +}; +var strictFunctionEvalArrow = function() { + "use strict"; + return eval("(() => this)()"); +}; +var sloppyFunctionArrowEval = function(s) { + return (() => eval(s))(); +}; +var strictFunctionArrowEval = function(s) { + "use strict"; + return (() => eval(s))(); +}; + +var withObject = { 'this': object } +var arrowInsideWith, arrowInsideWithEval; +with (withObject) { + arrowInsideWith = () => this; + arrowInsideWithEval = (s) => eval(s); +} + +assertEquals(global, call(globalSloppyArrow, object)); +assertEquals(global, call(globalStrictArrow, object)); +assertEquals(global, call(globalSloppyArrowEval, object, "this")); +assertEquals(global, call(globalStrictArrowEval, object, "this")); +assertEquals(global, call(globalSloppyArrowEval, object, "(() => this)()")); +assertEquals(global, call(globalStrictArrowEval, object, "(() => this)()")); + +assertEquals(object, call(sloppyFunctionArrow, object)); +assertEquals(global, call(sloppyFunctionArrow, undefined)); +assertEquals(object, call(strictFunctionArrow, object)); +assertEquals(undefined, call(strictFunctionArrow, undefined)); + +assertEquals(object, call(sloppyFunctionEvalArrow, object)); +assertEquals(global, call(sloppyFunctionEvalArrow, undefined)); +assertEquals(object, call(strictFunctionEvalArrow, object)); +assertEquals(undefined, call(strictFunctionEvalArrow, undefined)); + +assertEquals(object, call(sloppyFunctionArrowEval, object, "this")); +assertEquals(global, call(sloppyFunctionArrowEval, undefined, "this")); +assertEquals(object, call(strictFunctionArrowEval, object, "this")); +assertEquals(undefined, call(strictFunctionArrowEval, undefined, "this")); + +assertEquals(object, + call(sloppyFunctionArrowEval, object, "(() => this)()")); +assertEquals(global, + call(sloppyFunctionArrowEval, undefined, "(() => this)()")); +assertEquals(object, + call(strictFunctionArrowEval, object, "(() => this)()")); +assertEquals(undefined, + call(strictFunctionArrowEval, undefined, "(() => this)()")); + +assertEquals(global, call(arrowInsideWith, undefined)); +assertEquals(global, call(arrowInsideWith, object)); +assertEquals(global, call(arrowInsideWithEval, undefined, "this")); +assertEquals(global, call(arrowInsideWithEval, object, "this")); +assertEquals(global, call(arrowInsideWithEval, undefined, "(() => this)()")); +assertEquals(global, call(arrowInsideWithEval, object, "(() => this)()")); |