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

Unified Diff: frog/tests/leg_only/for_in_test.dart

Issue 10536169: Move frog/tests/{leg,leg_only,frog_native} to tests/compiler/. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 | « frog/tests/leg_only/foo7_test.dart ('k') | frog/tests/leg_only/for_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/tests/leg_only/for_in_test.dart
===================================================================
--- frog/tests/leg_only/for_in_test.dart (revision 8644)
+++ frog/tests/leg_only/for_in_test.dart (working copy)
@@ -1,80 +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.
-
-// Test foreach (aka. for-in) functionality.
-
-testIterator(List expect, Iterable input) {
- int i = 0;
- for (var value in input) {
- Expect.isTrue(i < expect.length);
- Expect.equals(expect[i], value);
- i += 1;
- }
- Expect.equals(expect.length, i);
-
- i = 0;
- var value2;
- for (value2 in input) {
- Expect.isTrue(i < expect.length);
- Expect.equals(expect[i], value2);
- i += 1;
- }
- Expect.equals(expect.length, i);
-}
-
-class MyIterable<T> implements Iterable<T> {
- final List<T> values;
- MyIterable(List<T> values) : this.values = values;
- Iterator iterator() {
- return new MyListIterator(values);
- }
-}
-
-class MyListIterator<T> implements Iterator<T> {
- final List<T> values;
- int index;
- MyListIterator(List<T> values) : this.values = values, index = 0;
- bool hasNext() => index < values.length;
- T next() => values[index++];
-}
-
-void main() {
- testIterator([], []);
- testIterator([], new MyIterable([]));
- testIterator([1], [1]);
- testIterator([1], new MyIterable([1]));
- testIterator([1,2,3], [1,2,3]);
- testIterator([1,2,3], new MyIterable([1,2,3]));
- testIterator(["a","b","c"], ["a","b","c"]);
- testIterator(["a","b","c"], new MyIterable(["a","b","c"]));
-
- // Several nested for-in's.
- for (var x in [[["a"]]]) {
- for (var y in x) {
- for (var z in y) {
- Expect.equals("a", z);
- }
- }
- }
-
- // Simultaneous iteration of the same iterable.
- for (var iterable in [[1,2,3], new MyIterable([1,2,3])]) {
- int result = 0;
- for (var x in iterable) {
- for (var y in iterable) {
- result += x * y;
- }
- }
- Expect.equals(36, result);
- }
-
- // Using the same variable (showing that the expression is evaluated
- // in the outer scope).
- int result = 0;
- var x = [1,2,3];
- for (var x in x) {
- result += x;
- }
- Expect.equals(6, result);
-}
« no previous file with comments | « frog/tests/leg_only/foo7_test.dart ('k') | frog/tests/leg_only/for_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698