Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/arrow-function/cannot-override-this-with-thisArg.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 14.2
5 description: >
6 ArrowFunction `this` cannot be overridden by thisArg
7
8 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope)
9
10 ...
11 9. If kind is Arrow, set the [[ThisMode]] internal slot of F to lexical.
12 ...
13
14 9.2.1.2 OrdinaryCallBindThis ( F, calleeContext, thisArgument )
15
16 1. Let thisMode be the value of F’s [[ThisMode]] internal slot.
17 2. If thisMode is lexical, return NormalCompletion(undefined).
18 ...
19
20 ---*/
21
22 var calls = 0;
23 var usurper = {};
24 [1].forEach(value => {
25 calls++;
26 assert.notSameValue(this, usurper);
27 }, usurper);
28
29 assert.sameValue(calls, 1);