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

Side by Side Diff: tests/corelib/iterable_generate_test.dart

Issue 2598983002: Introduce DartType super hierarchy based on Entity (Closed)
Patch Set: Cleanup. Created 4 years 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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 main() { 8 main() {
9 bool checkedMode = false; 9 bool checkedMode = false;
10 assert((checkedMode = true)); 10 assert((checkedMode = true));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 Expect.equals(2, iter1.elementAt(2)); 52 Expect.equals(2, iter1.elementAt(2));
53 Iterable<num> iter2 = new Iterable<num>.generate(5); 53 Iterable<num> iter2 = new Iterable<num>.generate(5);
54 Expect.equals(2, iter2.elementAt(2)); 54 Expect.equals(2, iter2.elementAt(2));
55 Iterable<Object> iter3 = new Iterable<Object>.generate(5); 55 Iterable<Object> iter3 = new Iterable<Object>.generate(5);
56 Expect.equals(2, iter3.elementAt(2)); 56 Expect.equals(2, iter3.elementAt(2));
57 Iterable<dynamic> iter4 = new Iterable<dynamic>.generate(5); 57 Iterable<dynamic> iter4 = new Iterable<dynamic>.generate(5);
58 Expect.equals(2, iter4.elementAt(2)); 58 Expect.equals(2, iter4.elementAt(2));
59 59
60 // Invalid types: 60 // Invalid types:
61 Expect.throws(() => new Iterable<String>.generate(5)); 61 Expect.throws(() => new Iterable<String>.generate(5));
62 Expect.throws(() => new Iterable<Null>.generate(5)); 62 Expect.throws(() {
63 new Iterable<Null>.generate(5).elementAt(2);
Siggi Cherem (dart-lang) 2016/12/22 15:42:03 not sure I follow: why is this change needed?
Johnni Winther 2016/12/22 15:58:49 From a different CL. Removed.
64 });
63 Expect.throws(() => new Iterable<bool>.generate(5)); 65 Expect.throws(() => new Iterable<bool>.generate(5));
64 66
65 // Regression: https://github.com/dart-lang/sdk/issues/26358 67 // Regression: https://github.com/dart-lang/sdk/issues/26358
66 var count = 0; 68 var count = 0;
67 var iter = new Iterable.generate(5, (v) { count++; return v; }); 69 var iter = new Iterable.generate(5, (v) { count++; return v; });
68 Expect.equals(0, count); 70 Expect.equals(0, count);
69 Expect.equals(2, iter.elementAt(2)); // Doesn't compute the earlier values. 71 Expect.equals(2, iter.elementAt(2)); // Doesn't compute the earlier values.
70 Expect.equals(1, count); 72 Expect.equals(1, count);
71 Expect.equals(2, iter.skip(2).first); // Doesn't compute the skipped values. 73 Expect.equals(2, iter.skip(2).first); // Doesn't compute the skipped values.
72 Expect.equals(2, count); 74 Expect.equals(2, count);
73 } 75 }
OLDNEW
« pkg/compiler/lib/src/elements/types.dart ('K') | « pkg/compiler/lib/src/ssa/nodes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698