Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: test/mjsunit/harmony/arrow-functions.js

Issue 1027283004: [es6] do not add caller/arguments to ES6 function definitions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase + test262 exceptions Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 5 // Flags: --harmony-arrow-functions
6 6
7 // Arrow functions are like functions, except they throw when using the 7 // Arrow functions are like functions, except they throw when using the
8 // "new" operator on them. 8 // "new" operator on them.
9 assertEquals("function", typeof (() => {})); 9 assertEquals("function", typeof (() => {}));
10 assertEquals(Function.prototype, Object.getPrototypeOf(() => {})); 10 assertEquals(Function.prototype, Object.getPrototypeOf(() => {}));
(...skipping 29 matching lines...) Expand all
40 40
41 // Statement body needs braces, must use 'return' explicitly if not void 41 // Statement body needs braces, must use 'return' explicitly if not void
42 var evens = [0, 2, 4, 6, 8]; 42 var evens = [0, 2, 4, 6, 8];
43 assertEquals([1, 3, 5, 7, 9], evens.map(v => v + 1)); 43 assertEquals([1, 3, 5, 7, 9], evens.map(v => v + 1));
44 44
45 var fives = []; 45 var fives = [];
46 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].forEach(v => { 46 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].forEach(v => {
47 if (v % 5 === 0) fives.push(v); 47 if (v % 5 === 0) fives.push(v);
48 }); 48 });
49 assertEquals([5, 10], fives); 49 assertEquals([5, 10], fives);
50
51 (function testRestrictedFunctionPropertiesStrict() {
52 var arrowFn = () => { "use strict"; };
53 assertFalse(arrowFn.hasOwnProperty("arguments"));
54 assertThrows(function() { return arrowFn.arguments; }, TypeError);
55 assertThrows(function() { arrowFn.arguments = {}; }, TypeError);
56
57 assertFalse(arrowFn.hasOwnProperty("caller"));
58 assertThrows(function() { return arrowFn.caller; }, TypeError);
59 assertThrows(function() { arrowFn.caller = {}; }, TypeError);
60 })();
61
62
63 (function testRestrictedFunctionPropertiesSloppy() {
64 var arrowFn = () => {};
65 assertFalse(arrowFn.hasOwnProperty("arguments"));
66 assertThrows(function() { return arrowFn.arguments; }, TypeError);
67 assertThrows(function() { arrowFn.arguments = {}; }, TypeError);
68
69 assertFalse(arrowFn.hasOwnProperty("caller"));
70 assertThrows(function() { return arrowFn.caller; }, TypeError);
71 assertThrows(function() { arrowFn.caller = {}; }, TypeError);
72 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698