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

Side by Side Diff: test/cctest/compiler/test-run-jsbranches.cc

Issue 850803002: First simple implementation of for-of in TurboFan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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
« src/ast-numbering.cc ('K') | « src/compiler/pipeline.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "test/cctest/compiler/function-tester.h" 7 #include "test/cctest/compiler/function-tester.h"
8 8
9 using namespace v8::internal; 9 using namespace v8::internal;
10 using namespace v8::internal::compiler; 10 using namespace v8::internal::compiler;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 "})"; 161 "})";
162 FunctionTester T(src); 162 FunctionTester T(src);
163 163
164 T.CheckCall(T.Val("-A-B-"), T.NewObject("({x:1})"), T.false_value()); 164 T.CheckCall(T.Val("-A-B-"), T.NewObject("({x:1})"), T.false_value());
165 T.CheckCall(T.Val("-A-B-A-B-"), T.NewObject("({x:1,y:2})"), T.false_value()); 165 T.CheckCall(T.Val("-A-B-A-B-"), T.NewObject("({x:1,y:2})"), T.false_value());
166 T.CheckCall(T.Val("-A-"), T.NewObject("({x:1})"), T.true_value()); 166 T.CheckCall(T.Val("-A-"), T.NewObject("({x:1})"), T.true_value());
167 T.CheckCall(T.Val("-A-A-"), T.NewObject("({x:1,y:2})"), T.true_value()); 167 T.CheckCall(T.Val("-A-A-"), T.NewObject("({x:1,y:2})"), T.true_value());
168 } 168 }
169 169
170 170
171 TEST(ForOfContinueStatement) {
172 const char* src =
173 "(function(a,b) {"
174 " var r = '-';"
175 " for (var x of a) {"
176 " r += x + '-';"
177 " if (b) continue;"
178 " r += 'X-';"
179 " }"
180 " return r;"
181 "})";
182 FunctionTester T(src);
183
184 CompileRun(
185 "function wrap(v) {"
186 " var iterable = {};"
187 " function next() { return { done:!v.length, value:v.shift() }; };"
188 " iterable[Symbol.iterator] = function() { return { next:next }; };"
189 " return iterable;"
190 "}");
191
192 T.CheckCall(T.Val("-"), T.NewObject("wrap([])"), T.true_value());
193 T.CheckCall(T.Val("-1-2-"), T.NewObject("wrap([1,2])"), T.true_value());
194 T.CheckCall(T.Val("-1-X-2-X-"), T.NewObject("wrap([1,2])"), T.false_value());
195 }
196
197
171 TEST(SwitchStatement) { 198 TEST(SwitchStatement) {
172 const char* src = 199 const char* src =
173 "(function(a,b) {" 200 "(function(a,b) {"
174 " var r = '-';" 201 " var r = '-';"
175 " switch (a) {" 202 " switch (a) {"
176 " case 'x' : r += 'X-';" 203 " case 'x' : r += 'X-';"
177 " case b + 'b': r += 'B-';" 204 " case b + 'b': r += 'B-';"
178 " default : r += 'D-';" 205 " default : r += 'D-';"
179 " case 'y' : r += 'Y-';" 206 " case 'y' : r += 'Y-';"
180 " }" 207 " }"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 T.CheckCall(T.Val(-8445), T.Val(8661), T.Val(-8445)); 375 T.CheckCall(T.Val(-8445), T.Val(8661), T.Val(-8445));
349 } 376 }
350 377
351 378
352 TEST(EmptyFor) { 379 TEST(EmptyFor) {
353 FunctionTester T("(function(a,b) { if (a) for(;;) ; return b; })"); 380 FunctionTester T("(function(a,b) { if (a) for(;;) ; return b; })");
354 381
355 T.CheckCall(T.Val(8126.1), T.Val(0.0), T.Val(8126.1)); 382 T.CheckCall(T.Val(8126.1), T.Val(0.0), T.Val(8126.1));
356 T.CheckCall(T.Val(1123.1), T.Val(0.0), T.Val(1123.1)); 383 T.CheckCall(T.Val(1123.1), T.Val(0.0), T.Val(1123.1));
357 } 384 }
OLDNEW
« src/ast-numbering.cc ('K') | « src/compiler/pipeline.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698