Debian Codegraph @

js/src/tests/test262/built-ins/GeneratorFunction/instance-restricted-properties.js

raw
1 // Copyright (C) 2015 Caitlin Potter. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: >
6 Functions created using GeneratorFunction intrinsic function do not have
7 own properties "caller" or "arguments", but inherit them from
8 %FunctionPrototype%.
9 features: [generators]
10 ---*/
11
12 var Generator = Object.getPrototypeOf(function*() {});
13 var GeneratorFunction = Generator.constructor;
14 var generator = new GeneratorFunction();
15
16 assert.sameValue(
17 generator.hasOwnProperty('caller'), false, 'No "caller" own property'
18 );
19 assert.sameValue(
20 generator.hasOwnProperty('arguments'), false, 'No "arguments" own property'
21 );
22
23 assert.throws(TypeError, function() {
24 return generator.caller;
25 });
26
27 assert.throws(TypeError, function() {
28 generator.caller = {};
29 });
30
31 assert.throws(TypeError, function() {
32 return generator.arguments;
33 });
34
35 assert.throws(TypeError, function() {
36 generator.arguments = {};
37 });
38
39 reportCompare(0, 0);