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

Unified Diff: tests/corelib/for_in_test.dart

Issue 2989643002: Migrate test block 8 to Dart 2.0. (Closed)
Patch Set: Merge Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/corelib/expression_test.dart ('k') | tests/corelib/from_environment_const_type_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/for_in_test.dart
diff --git a/tests/corelib/for_in_test.dart b/tests/corelib/for_in_test.dart
deleted file mode 100644
index 35d1a86439caf2cf607a7419e6821414e6866568..0000000000000000000000000000000000000000
--- a/tests/corelib/for_in_test.dart
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import "package:expect/expect.dart";
-
-class ForInTest {
- static testMain() {
- testSimple();
- testBreak();
- testContinue();
- testClosure();
- }
-
- static Set<int> getSmallSet() {
- Set<int> set = new Set<int>();
- set.add(1);
- set.add(2);
- set.add(4);
- return set;
- }
-
- static void testSimple() {
- Set<int> set = getSmallSet();
- int count = 0;
- for (final i in set) {
- count += i;
- }
- Expect.equals(7, count);
-
- count = 0;
- for (var i in set) {
- count += i;
- }
- Expect.equals(7, count);
-
- count = 0;
- for (int i in set) {
- count += i;
- }
- Expect.equals(7, count);
-
- count = 0;
- for (final int i in set) {
- count += i;
- }
- Expect.equals(7, count);
-
- count = 0;
- int i = 0;
- Expect.equals(false, set.contains(i)); // Used to test [i] after loop.
- for (i in set) {
- count += i;
- }
- Expect.equals(7, count);
- Expect.equals(true, set.contains(i));
- // The default implementation of [Set] preserves order.
- Expect.equals(4, i);
- }
-
- static void testBreak() {
- Set<int> set = getSmallSet();
- int count = 0;
- for (final i in set) {
- if (i == 4) break;
- count += i;
- }
- Expect.equals(true, count < 4);
- }
-
- static void testContinue() {
- Set<int> set = getSmallSet();
- int count = 0;
- for (final i in set) {
- if (i < 4) continue;
- count += i;
- }
- Expect.equals(4, count);
- }
-
- static void testClosure() {
- Set<int> set = getSmallSet();
- List<Function> closures = new List(set.length);
- int index = 0;
- for (var i in set) {
- closures[index++] = () => i;
- }
-
- Expect.equals(index, set.length);
- Expect.equals(7, closures[0]() + closures[1]() + closures[2]());
- }
-}
-
-main() {
- ForInTest.testMain();
-}
« no previous file with comments | « tests/corelib/expression_test.dart ('k') | tests/corelib/from_environment_const_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698