OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Test for conflicting variable bindings. | 5 // Test for conflicting variable bindings. |
6 | 6 |
7 // Flags: --harmony-sloppy --harmony-sloppy-function | |
8 | |
9 function AssertEqualsStrictAndSloppy(value, code) { | 7 function AssertEqualsStrictAndSloppy(value, code) { |
10 assertEquals(value, eval("(function() {" + code + "})()")); | 8 assertEquals(value, eval("(function() {" + code + "})()")); |
11 assertEquals(value, eval("(function() { 'use strict'; " + code + "})()")); | 9 assertEquals(value, eval("(function() { 'use strict'; " + code + "})()")); |
12 assertEquals(value, eval("(function() { var x = 0; {" + code + "} })()")); | 10 assertEquals(value, eval("(function() { var x = 0; {" + code + "} })()")); |
13 assertEquals(value, eval("(function() { 'use strict'; var x = 0; {" | 11 assertEquals(value, eval("(function() { 'use strict'; var x = 0; {" |
14 + code + "} })()")); | 12 + code + "} })()")); |
15 } | 13 } |
16 | 14 |
17 function AssertThrowsStrictAndSloppy(code, error) { | 15 function AssertThrowsStrictAndSloppy(code, error) { |
18 assertThrows("(function() {" + code + "})()", error); | 16 assertThrows("(function() {" + code + "})()", error); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 AssertThrowsStrictAndSloppy("class x { }; for (var x = 0; false;) { };", | 48 AssertThrowsStrictAndSloppy("class x { }; for (var x = 0; false;) { };", |
51 SyntaxError); | 49 SyntaxError); |
52 AssertThrowsStrictAndSloppy("for (var x = 0; false;) { }; class x { };", | 50 AssertThrowsStrictAndSloppy("for (var x = 0; false;) { }; class x { };", |
53 SyntaxError); | 51 SyntaxError); |
54 })(); | 52 })(); |
55 | 53 |
56 (function TestClassMutableBinding() { | 54 (function TestClassMutableBinding() { |
57 AssertEqualsStrictAndSloppy( | 55 AssertEqualsStrictAndSloppy( |
58 "x3", "class x { }; var y = x.name; x = 3; return y + x;") | 56 "x3", "class x { }; var y = x.name; x = 3; return y + x;") |
59 })(); | 57 })(); |
OLD | NEW |