summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/harmony/generators-poisoned-properties.js
blob: 39a583ec976d10e965395433edf9ce85a70fa9a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-generators

function assertIteratorResult(value, done, result) {
  assertEquals({value: value, done: done}, result);
}

function test(f) {
  var cdesc = Object.getOwnPropertyDescriptor(f, "caller");
  var adesc = Object.getOwnPropertyDescriptor(f, "arguments");

  assertFalse(cdesc.enumerable);
  assertFalse(cdesc.configurable);

  assertFalse(adesc.enumerable);
  assertFalse(adesc.configurable);

  assertSame(cdesc.get, cdesc.set);
  assertSame(cdesc.get, adesc.get);
  assertSame(cdesc.get, adesc.set);

  assertTrue(cdesc.get instanceof Function);
  assertEquals(0, cdesc.get.length);
  assertThrows(cdesc.get, TypeError);

  assertThrows(function() { return f.caller; }, TypeError);
  assertThrows(function() { f.caller = 42; }, TypeError);
  assertThrows(function() { return f.arguments; }, TypeError);
  assertThrows(function() { f.arguments = 42; }, TypeError);
}

function *sloppy() { test(sloppy); }
function *strict() { "use strict"; test(strict); }

test(sloppy);
test(strict);

assertIteratorResult(undefined, true, sloppy().next());
assertIteratorResult(undefined, true, strict().next());