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

Side by Side Diff: tests/compiler/dart2js/value_range_test.dart

Issue 23872005: Fix http://code.google.com/p/dart/issues/detail?id=13007 by introducing a new Marker value in the S… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'compiler_helper.dart'; 6 import 'compiler_helper.dart';
7 7
8 const int REMOVED = 0; 8 const int REMOVED = 0;
9 const int ABOVE_ZERO = 1; 9 const int ABOVE_ZERO = 1;
10 const int BELOW_LENGTH = 2; 10 const int BELOW_LENGTH = 2;
11 const int KEPT = 3; 11 const int KEPT = 3;
12 const int ONE_CHECK = 4; 12 const int ONE_CHECK = 4;
13 const int ONE_ZERO_CHECK = 5; 13 const int ONE_ZERO_CHECK = 5;
14 const int BELOW_ZERO_CHECK = 6;
14 15
15 final List TESTS = [ 16 final List TESTS = [
16 """ 17 """
17 main() { 18 main() {
18 var a = new List(); 19 var a = new List();
19 var sum = 0; 20 var sum = 0;
20 for (int i = 0; i < a.length; i++) { 21 for (int i = 0; i < a.length; i++) {
21 sum += a[i]; 22 sum += a[i];
22 } 23 }
23 return sum; 24 return sum;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // want an int. 191 // want an int.
191 int sum = ~value; 192 int sum = ~value;
192 for (int i = 0; i < 42; i++) sum += (value & 4); 193 for (int i = 0; i < 42; i++) sum += (value & 4);
193 var a = new List(); 194 var a = new List();
194 if (value >= a.length) return; 195 if (value >= a.length) return;
195 if (value <= -1) return; 196 if (value <= -1) return;
196 return a[value]; 197 return a[value];
197 } 198 }
198 """, 199 """,
199 REMOVED, 200 REMOVED,
201 """
202 main(value) {
203 var a = new List(4);
204 var sum = 0;
205 for (int i = 0; i < a.length; i++) {
206 sum += a[i];
207 if (sum == 0) i++;
208 }
209 return sum;
210 }
211 """,
212 REMOVED,
213 """
214 main(value) {
215 var a = new List(5);
216 var sum = 0;
217 for (int i = a.length - 1; i >= 0; i--) {
218 sum += a[i];
219 if (sum == 0) i--;
220 }
221 return sum;
222 }
223 """,
224 REMOVED,
225 """
226 main(value) {
227 var a = new List(6);
228 var sum = 0;
229 for (int i = 0; i < a.length; i++) {
230 sum += a[i];
231 if (sum == 0) i--;
232 }
233 return sum;
234 }
235 """,
236 BELOW_ZERO_CHECK,
237 """
238 main(value) {
239 var a = new List(7);
240 var sum = 0;
241 for (int i = 0; i < a.length;) {
242 sum += a[i];
243 sum == 0 ? i-- : i++;
244 }
245 return sum;
246 }
247 """,
248 BELOW_ZERO_CHECK,
200 ]; 249 ];
201 250
202 // TODO(ahe): It would probably be better if this test used the real 251 // TODO(ahe): It would probably be better if this test used the real
203 // core library sources, as its purpose is to detect failure to 252 // core library sources, as its purpose is to detect failure to
204 // optimize fixed-sized arrays. 253 // optimize fixed-sized arrays.
205 const String DEFAULT_CORELIB_WITH_LIST_INTERFACE = r''' 254 const String DEFAULT_CORELIB_WITH_LIST_INTERFACE = r'''
206 print(var obj) {} 255 print(var obj) {}
207 abstract class num {} 256 abstract class num {}
208 abstract class int extends num { } 257 abstract class int extends num { }
209 abstract class double extends num { } 258 abstract class double extends num { }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 coreSource: DEFAULT_CORELIB_WITH_LIST_INTERFACE, 332 coreSource: DEFAULT_CORELIB_WITH_LIST_INTERFACE,
284 interceptorsSource: INTERCEPTORSLIB_WITH_MEMBERS); 333 interceptorsSource: INTERCEPTORSLIB_WITH_MEMBERS);
285 switch (kind) { 334 switch (kind) {
286 case REMOVED: 335 case REMOVED:
287 Expect.isTrue(!generated.contains('ioore')); 336 Expect.isTrue(!generated.contains('ioore'));
288 break; 337 break;
289 338
290 case ABOVE_ZERO: 339 case ABOVE_ZERO:
291 Expect.isTrue(!generated.contains('< 0')); 340 Expect.isTrue(!generated.contains('< 0'));
292 Expect.isTrue(generated.contains('ioore')); 341 Expect.isTrue(generated.contains('ioore'));
342 break;
343
344 case BELOW_ZERO_CHECK:
345 Expect.isTrue(generated.contains('< 0'));
346 Expect.isTrue(!generated.contains('||'));
293 Expect.isTrue(generated.contains('ioore')); 347 Expect.isTrue(generated.contains('ioore'));
294 break; 348 break;
295 349
296 case BELOW_LENGTH: 350 case BELOW_LENGTH:
297 Expect.isTrue(!generated.contains('||')); 351 Expect.isTrue(!generated.contains('||'));
298 Expect.isTrue(generated.contains('ioore')); 352 Expect.isTrue(generated.contains('ioore'));
299 break; 353 break;
300 354
301 case KEPT: 355 case KEPT:
302 Expect.isTrue(generated.contains('ioore')); 356 Expect.isTrue(generated.contains('ioore'));
(...skipping 12 matching lines...) Expand all
315 break; 369 break;
316 } 370 }
317 } 371 }
318 372
319 373
320 main() { 374 main() {
321 for (int i = 0; i < TESTS.length; i += 2) { 375 for (int i = 0; i < TESTS.length; i += 2) {
322 expect(TESTS[i], TESTS[i + 1]); 376 expect(TESTS[i], TESTS[i + 1]);
323 } 377 }
324 } 378 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698