Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: test/mjsunit/harmony/block-conflicts-sloppy.js

Issue 1226103002: [es6] Handle conflicts for sloppy let (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: more comments and git rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 "use strict"; 7 // Flags: --no-legacy-const --harmony-sloppy
8 8
9 function CheckException(e) { 9 function CheckException(e) {
10 var string = e.toString(); 10 var string = e.toString();
11 assertTrue(string.indexOf("has already been declared") >= 0 || 11 assertTrue(string.indexOf("has already been declared") >= 0 ||
12 string.indexOf("redeclaration") >= 0); 12 string.indexOf("redeclaration") >= 0);
13 return 'Conflict'; 13 return 'Conflict';
14 } 14 }
15 15
16 16
17 function TestGlobal(s,e) { 17 function TestGlobal(s,e) {
(...skipping 19 matching lines...) Expand all
37 return eval("(function(){ {" + s + "} return " + e + "})")(); 37 return eval("(function(){ {" + s + "} return " + e + "})")();
38 } catch (x) { 38 } catch (x) {
39 return CheckException(x); 39 return CheckException(x);
40 } 40 }
41 } 41 }
42 42
43 function TestAll(expected,s,opt_e) { 43 function TestAll(expected,s,opt_e) {
44 var e = ""; 44 var e = "";
45 var msg = s; 45 var msg = s;
46 if (opt_e) { e = opt_e; msg += opt_e; } 46 if (opt_e) { e = opt_e; msg += opt_e; }
47 assertEquals(expected === 'LocalConflict' ? 'NoConflict' : expected, 47 // TODO(littledan): https://code.google.com/p/v8/issues/detail?id=4288
48 TestGlobal(s,e), "global:'" + msg + "'"); 48 // It is also not clear whether these tests makes sense in sloppy mode.
49 // TODO(littledan): Add tests using Realm.eval to ensure that global eval
50 // works as expected.
51 // assertEquals(expected === 'LocalConflict' ? 'NoConflict' : expected,
52 // TestGlobal(s,e), "global:'" + msg + "'");
49 assertEquals(expected === 'LocalConflict' ? 'NoConflict' : expected, 53 assertEquals(expected === 'LocalConflict' ? 'NoConflict' : expected,
50 TestFunction(s,e), "function:'" + msg + "'"); 54 TestFunction(s,e), "function:'" + msg + "'");
51 assertEquals(expected === 'LocalConflict' ? 'Conflict' : expected, 55 assertEquals(expected === 'LocalConflict' ? 'Conflict' : expected,
52 TestBlock(s,e), "block:'" + msg + "'"); 56 TestBlock(s,e), "block:'" + msg + "'");
53 } 57 }
54 58
55 59
56 function TestConflict(s) { 60 function TestConflict(s) {
57 TestAll('Conflict', s); 61 TestAll('Conflict', s);
58 TestAll('Conflict', 'eval("' + s + '");'); 62 // TODO(littledan): https://code.google.com/p/v8/issues/detail?id=4288
63 // It is also not clear whether these tests makes sense in sloppy mode.
64 // TestAll('Conflict', 'eval("' + s + '");');
59 } 65 }
60 66
61 function TestNoConflict(s) { 67 function TestNoConflict(s) {
62 TestAll('NoConflict', s, "'NoConflict'"); 68 TestAll('NoConflict', s, "'NoConflict'");
63 TestAll('NoConflict', 'eval("' + s + '");', "'NoConflict'"); 69 // TODO(littledan): https://code.google.com/p/v8/issues/detail?id=4288
70 // TestAll('NoConflict', 'eval("' + s + '");', "'NoConflict'");
64 } 71 }
65 72
66 function TestLocalConflict(s) { 73 function TestLocalConflict(s) {
67 TestAll('LocalConflict', s, "'NoConflict'"); 74 TestAll('LocalConflict', s, "'NoConflict'");
68 TestAll('NoConflict', 'eval("' + s + '");', "'NoConflict'"); 75 // TODO(littledan): https://code.google.com/p/v8/issues/detail?id=4288
76 // It is also not clear whether these tests makes sense in sloppy mode.
77 // TestAll('NoConflict', 'eval("' + s + '");', "'NoConflict'");
69 } 78 }
70 79
71 var letbinds = [ "let x;", 80 var letbinds = [ "let x;",
72 "let x = 0;", 81 "let x = 0;",
73 "let x = undefined;", 82 "let x = undefined;",
74 "let x = function() {};", 83 "let x = function() {};",
75 "let x, y;", 84 "let x, y;",
76 "let y, x;", 85 "let y, x;",
77 "const x = 0;", 86 "const x = 0;",
78 "const x = undefined;", 87 "const x = undefined;",
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // Test conflicting parameter/var bindings. 165 // Test conflicting parameter/var bindings.
157 for (var v = 0; v < varbinds.length; ++v) { 166 for (var v = 0; v < varbinds.length; ++v) {
158 TestNoConflict('(function (x) {' + varbinds[v] + '})();'); 167 TestNoConflict('(function (x) {' + varbinds[v] + '})();');
159 } 168 }
160 169
161 // Test conflicting catch/function bindings. 170 // Test conflicting catch/function bindings.
162 TestNoConflict('try {} catch(x) {' + funbind + '}'); 171 TestNoConflict('try {} catch(x) {' + funbind + '}');
163 172
164 // Test conflicting parameter/function bindings. 173 // Test conflicting parameter/function bindings.
165 TestNoConflict('(function (x) {' + funbind + '})();'); 174 TestNoConflict('(function (x) {' + funbind + '})();');
OLDNEW
« no previous file with comments | « test/mjsunit/es6/block-let-semantics.js ('k') | test/mjsunit/harmony/block-let-semantics-sloppy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698