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

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

Issue 1286923002: Add class to existing lexical scoping tests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test bug Created 5 years, 4 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
« no previous file with comments | « test/mjsunit/es6/block-scoping.js ('k') | test/mjsunit/harmony/block-let-declaration-sloppy.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let 7 // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let
8 8
9 function CheckException(e) { 9 function CheckException(e) {
10 var string = e.toString(); 10 var string = e.toString();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 "let x = 0;", 74 "let x = 0;",
75 "let x = undefined;", 75 "let x = undefined;",
76 "let x = function() {};", 76 "let x = function() {};",
77 "let x, y;", 77 "let x, y;",
78 "let y, x;", 78 "let y, x;",
79 "const x = 0;", 79 "const x = 0;",
80 "const x = undefined;", 80 "const x = undefined;",
81 "const x = function() {};", 81 "const x = function() {};",
82 "const x = 2, y = 3;", 82 "const x = 2, y = 3;",
83 "const y = 4, x = 5;", 83 "const y = 4, x = 5;",
84 "class x { }",
84 ]; 85 ];
86 function forCompatible(bind) {
87 return !bind.startsWith('class');
88 }
85 var varbinds = [ "var x;", 89 var varbinds = [ "var x;",
86 "var x = 0;", 90 "var x = 0;",
87 "var x = undefined;", 91 "var x = undefined;",
88 "var x = function() {};", 92 "var x = function() {};",
89 "var x, y;", 93 "var x, y;",
90 "var y, x;", 94 "var y, x;",
91 ]; 95 ];
92 var funbind = "function x() {}"; 96 var funbind = "function x() {}";
93 97
94 for (var l = 0; l < letbinds.length; ++l) { 98 for (var l = 0; l < letbinds.length; ++l) {
95 // Test conflicting let/var bindings. 99 // Test conflicting let/var bindings.
96 for (var v = 0; v < varbinds.length; ++v) { 100 for (var v = 0; v < varbinds.length; ++v) {
97 // Same level. 101 // Same level.
98 TestConflict(letbinds[l] + varbinds[v]); 102 TestConflict(letbinds[l] + varbinds[v]);
99 TestConflict(varbinds[v] + letbinds[l]); 103 TestConflict(varbinds[v] + letbinds[l]);
100 // Different level. 104 // Different level.
101 TestConflict(letbinds[l] + '{' + varbinds[v] + '}'); 105 TestConflict(letbinds[l] + '{' + varbinds[v] + '}');
102 TestConflict('{' + varbinds[v] +'}' + letbinds[l]); 106 TestConflict('{' + varbinds[v] +'}' + letbinds[l]);
103 TestNoConflict(varbinds[v] + '{' + letbinds[l] + '}'); 107 TestNoConflict(varbinds[v] + '{' + letbinds[l] + '}');
104 TestNoConflict('{' + letbinds[l] + '}' + varbinds[v]); 108 TestNoConflict('{' + letbinds[l] + '}' + varbinds[v]);
105 // For loop. 109 // For loop.
106 TestConflict('for (' + letbinds[l] + '0;) {' + varbinds[v] + '}'); 110 if (forCompatible(letbinds[l])) {
111 TestConflict('for (' + letbinds[l] + '0;) {' + varbinds[v] + '}');
112 }
107 TestNoConflict('for (' + varbinds[v] + '0;) {' + letbinds[l] + '}'); 113 TestNoConflict('for (' + varbinds[v] + '0;) {' + letbinds[l] + '}');
108 } 114 }
109 115
110 // Test conflicting let/let bindings. 116 // Test conflicting let/let bindings.
111 for (var k = 0; k < letbinds.length; ++k) { 117 for (var k = 0; k < letbinds.length; ++k) {
112 // Same level. 118 // Same level.
113 TestConflict(letbinds[l] + letbinds[k]); 119 TestConflict(letbinds[l] + letbinds[k]);
114 TestConflict(letbinds[k] + letbinds[l]); 120 TestConflict(letbinds[k] + letbinds[l]);
115 // Different level. 121 // Different level.
116 TestNoConflict(letbinds[l] + '{ ' + letbinds[k] + '}'); 122 TestNoConflict(letbinds[l] + '{ ' + letbinds[k] + '}');
117 TestNoConflict('{' + letbinds[k] +'} ' + letbinds[l]); 123 TestNoConflict('{' + letbinds[k] +'} ' + letbinds[l]);
118 // For loop. 124 // For loop.
119 TestNoConflict('for (' + letbinds[l] + '0;) {' + letbinds[k] + '}'); 125 if (forCompatible(letbinds[l])) {
120 TestNoConflict('for (' + letbinds[k] + '0;) {' + letbinds[l] + '}'); 126 TestNoConflict('for (' + letbinds[l] + '0;) {' + letbinds[k] + '}');
127 }
128 if (forCompatible(letbinds[k])) {
129 TestNoConflict('for (' + letbinds[k] + '0;) {' + letbinds[l] + '}');
130 }
121 } 131 }
122 132
123 // Test conflicting function/let bindings. 133 // Test conflicting function/let bindings.
124 // Same level. 134 // Same level.
125 TestConflict(letbinds[l] + funbind); 135 TestConflict(letbinds[l] + funbind);
126 TestConflict(funbind + letbinds[l]); 136 TestConflict(funbind + letbinds[l]);
127 // Different level. 137 // Different level.
128 TestNoConflict(letbinds[l] + '{' + funbind + '}'); 138 TestNoConflict(letbinds[l] + '{' + funbind + '}');
129 TestNoConflict('{' + funbind + '}' + letbinds[l]); 139 TestNoConflict('{' + funbind + '}' + letbinds[l]);
130 TestNoConflict(funbind + '{' + letbinds[l] + '}'); 140 TestNoConflict(funbind + '{' + letbinds[l] + '}');
131 TestNoConflict('{' + letbinds[l] + '}' + funbind); 141 TestNoConflict('{' + letbinds[l] + '}' + funbind);
132 // For loop. 142 // For loop.
133 TestNoConflict('for (' + letbinds[l] + '0;) {' + funbind + '}'); 143 if (forCompatible(letbinds[l])) {
144 TestNoConflict('for (' + letbinds[l] + '0;) {' + funbind + '}');
145 }
134 146
135 // Test conflicting parameter/let bindings. 147 // Test conflicting parameter/let bindings.
136 TestConflict('(function(x) {' + letbinds[l] + '})();'); 148 TestConflict('(function(x) {' + letbinds[l] + '})();');
137 } 149 }
138 150
139 // Test conflicting function/var bindings. 151 // Test conflicting function/var bindings.
140 for (var v = 0; v < varbinds.length; ++v) { 152 for (var v = 0; v < varbinds.length; ++v) {
141 // Same level. 153 // Same level.
142 TestLocalConflict(varbinds[v] + funbind); 154 TestLocalConflict(varbinds[v] + funbind);
143 TestLocalConflict(funbind + varbinds[v]); 155 TestLocalConflict(funbind + varbinds[v]);
(...skipping 14 matching lines...) Expand all
158 // Test conflicting parameter/var bindings. 170 // Test conflicting parameter/var bindings.
159 for (var v = 0; v < varbinds.length; ++v) { 171 for (var v = 0; v < varbinds.length; ++v) {
160 TestNoConflict('(function (x) {' + varbinds[v] + '})();'); 172 TestNoConflict('(function (x) {' + varbinds[v] + '})();');
161 } 173 }
162 174
163 // Test conflicting catch/function bindings. 175 // Test conflicting catch/function bindings.
164 TestNoConflict('try {} catch(x) {' + funbind + '}'); 176 TestNoConflict('try {} catch(x) {' + funbind + '}');
165 177
166 // Test conflicting parameter/function bindings. 178 // Test conflicting parameter/function bindings.
167 TestNoConflict('(function (x) {' + funbind + '})();'); 179 TestNoConflict('(function (x) {' + funbind + '})();');
OLDNEW
« no previous file with comments | « test/mjsunit/es6/block-scoping.js ('k') | test/mjsunit/harmony/block-let-declaration-sloppy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698