OLD | NEW |
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 TestForIn( | 141 TestForIn( |
142 "(function(a, b) {" | 142 "(function(a, b) {" |
143 "var obj = {'a' : undefined};" | 143 "var obj = {'a' : undefined};" |
144 "for (obj.a in a) {" | 144 "for (obj.a in a) {" |
145 " if (b) { delete a[b]; b = undefined; }" | 145 " if (b) { delete a[b]; b = undefined; }" |
146 "}" | 146 "}" |
147 "return obj.a;})"); | 147 "return obj.a;})"); |
148 } | 148 } |
149 | 149 |
150 | 150 |
| 151 TEST(ForInContinueStatement) { |
| 152 const char* src = |
| 153 "(function(a,b) {" |
| 154 " var r = '-';" |
| 155 " for (var x in a) {" |
| 156 " r += 'A-';" |
| 157 " if (b) continue;" |
| 158 " r += 'B-';" |
| 159 " }" |
| 160 " return r;" |
| 161 "})"; |
| 162 FunctionTester T(src); |
| 163 |
| 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()); |
| 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()); |
| 168 } |
| 169 |
| 170 |
151 TEST(SwitchStatement) { | 171 TEST(SwitchStatement) { |
152 const char* src = | 172 const char* src = |
153 "(function(a,b) {" | 173 "(function(a,b) {" |
154 " var r = '-';" | 174 " var r = '-';" |
155 " switch (a) {" | 175 " switch (a) {" |
156 " case 'x' : r += 'X-';" | 176 " case 'x' : r += 'X-';" |
157 " case b + 'b': r += 'B-';" | 177 " case b + 'b': r += 'B-';" |
158 " default : r += 'D-';" | 178 " default : r += 'D-';" |
159 " case 'y' : r += 'Y-';" | 179 " case 'y' : r += 'Y-';" |
160 " }" | 180 " }" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 273 } |
254 | 274 |
255 | 275 |
256 TEST(NestedForConditional) { | 276 TEST(NestedForConditional) { |
257 FunctionTester T("(function(a,b) { for (; a > 1; a--) return b ? 1 : 2; })"); | 277 FunctionTester T("(function(a,b) { for (; a > 1; a--) return b ? 1 : 2; })"); |
258 | 278 |
259 T.CheckCall(T.Val(1), T.Val(3), T.true_value()); | 279 T.CheckCall(T.Val(1), T.Val(3), T.true_value()); |
260 T.CheckCall(T.Val(2), T.Val(2), T.false_value()); | 280 T.CheckCall(T.Val(2), T.Val(2), T.false_value()); |
261 T.CheckCall(T.undefined(), T.Val(1), T.null()); | 281 T.CheckCall(T.undefined(), T.Val(1), T.null()); |
262 } | 282 } |
OLD | NEW |