blob: 887c00099a7b053f4a3968043f72da74ae5e7aee [file] [log] [blame]
Ben Murdochc5610432016-08-08 18:44:38 +01001// Copyright 2016 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
5// Flags: --allow-natives-syntax
6
7// Tests function bindings are correctly handled in ignition.
8(function f() {
9 function assignSloppy() {
10 f = 0;
11 }
12 assertDoesNotThrow(assignSloppy);
13
14 function assignStrict() {
15 'use strict';
16 f = 0;
17 }
18 assertThrows(assignStrict, TypeError);
19
20 function assignStrictLookup() {
21 eval("'use strict'; f = 1;");
22 }
23 assertThrows(assignStrictLookup, TypeError);
24})();
25
26// Tests for compound assignments which are handled differently
27// in crankshaft.
28(function f() {
29 function assignSloppy() {
30 f += "x";
31 }
32 assertDoesNotThrow(assignSloppy);
33 assertDoesNotThrow(assignSloppy);
34 %OptimizeFunctionOnNextCall(assignSloppy);
35 assertDoesNotThrow(assignSloppy);
36
37 function assignStrict() {
38 'use strict';
39 f += "x";
40 }
41 assertThrows(assignStrict, TypeError);
42 assertThrows(assignStrict, TypeError);
43 %OptimizeFunctionOnNextCall(assignStrict);
44 assertThrows(assignStrict, TypeError);
45})();