OLD | NEW |
---|---|
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()); | |
OLD | NEW |