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 3// found in the LICENSE file. 4 5function assertIteratorResult(value, done, result) { 6 assertEquals({value: value, done: done}, result); 7} 8 9function test(f) { 10 var cdesc = Object.getOwnPropertyDescriptor(f, "caller"); 11 var adesc = Object.getOwnPropertyDescriptor(f, "arguments"); 12 13 assertFalse(cdesc.enumerable); 14 assertFalse(cdesc.configurable); 15 16 assertFalse(adesc.enumerable); 17 assertFalse(adesc.configurable); 18 19 assertSame(cdesc.get, cdesc.set); 20 assertSame(cdesc.get, adesc.get); 21 assertSame(cdesc.get, adesc.set); 22 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 33function *sloppy() { test(sloppy); } 34function *strict() { "use strict"; test(strict); } 35 36test(sloppy); 37test(strict); 38 39assertIteratorResult(undefined, true, sloppy().next()); 40assertIteratorResult(undefined, true, strict().next()); 41