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

Side by Side Diff: test/mjsunit/es6/generators-poisoned-properties.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: Remove unneeded bits Created 5 years, 9 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 (function testRestrictedPropertiesStrict() {
6 "use strict";
7 assertEquals(false, (function*() {}).hasOwnProperty("arguments"));
arv (Not doing code reviews) 2015/03/25 13:36:47 assertFalse
8 assertEquals(null, (function*() {}).arguments);
9
10 assertEquals(false, (function*() {}).hasOwnProperty("caller"));
11 assertEquals(null, (function*() {}).caller);
12 })();
13
14
15 (function testRestrictedPropertiesSloppy() {
16 assertEquals(false, (function*() {}).hasOwnProperty("arguments"));
17 assertEquals(null, (function*() {}).arguments);
18
19 assertEquals(false, (function*() {}).hasOwnProperty("caller"));
20 assertEquals(null, (function*() {}).caller);
21 })();
22
5 function assertIteratorResult(value, done, result) { 23 function assertIteratorResult(value, done, result) {
6 assertEquals({value: value, done: done}, result); 24 assertEquals({value: value, done: done}, result);
7 } 25 }
8 26
9 function test(f) {
10 var cdesc = Object.getOwnPropertyDescriptor(f, "caller");
11 var adesc = Object.getOwnPropertyDescriptor(f, "arguments");
12 27
13 assertFalse(cdesc.enumerable); 28 (function testIteratorResultStrict() {
14 assertFalse(cdesc.configurable); 29 function* generator() { "use strict"; }
30 assertIteratorResult(undefined, true, generator().next());
31 })();
15 32
16 assertFalse(adesc.enumerable);
17 assertFalse(adesc.configurable);
18 33
19 assertSame(cdesc.get, cdesc.set); 34 (function testIteratorResultSloppy() {
20 assertSame(cdesc.get, adesc.get); 35 function* generator() {}
21 assertSame(cdesc.get, adesc.set); 36 assertIteratorResult(undefined, true, generator().next());
22 37 })();
23 assertTrue(cdesc.get instanceof Function);
24 assertEquals(0, cdesc.get.length);
25 assertThrows(cdesc.get, TypeError);
26
27 assertThrows(function() { return f.caller; }, TypeError);
28 assertThrows(function() { f.caller = 42; }, TypeError);
29 assertThrows(function() { return f.arguments; }, TypeError);
30 assertThrows(function() { f.arguments = 42; }, TypeError);
31 }
32
33 function *sloppy() { test(sloppy); }
34 function *strict() { "use strict"; test(strict); }
35
36 test(sloppy);
37 test(strict);
38
39 assertIteratorResult(undefined, true, sloppy().next());
40 assertIteratorResult(undefined, true, strict().next());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698