Chromium Code Reviews| Index: tests/standalone/io/link_test.dart |
| diff --git a/tests/standalone/io/link_test.dart b/tests/standalone/io/link_test.dart |
| index ae303a772ec4b75710c5867f9d18f2fa6d751f64..23f716befad0b2ef60c18e6b238f26e6bd0997d6 100644 |
| --- a/tests/standalone/io/link_test.dart |
| +++ b/tests/standalone/io/link_test.dart |
| @@ -2,6 +2,7 @@ |
| // 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 "dart:async"; |
| import "dart:io"; |
| import "dart:isolate"; |
| @@ -76,7 +77,59 @@ testCreateSync() { |
| Expect.throws(() => FileSystemEntity.identicalSync(createdFile, |
| base.append('link/foo').toNativePath())); |
| - new Directory.fromPath(base).deleteSync(recursive: true); |
| + var baseDir = new Directory.fromPath(base); |
| + |
| + Map makeExpected(bool recursive, bool followLinks) { |
| + Map expected = new Map(); |
| + expected['target'] = 'Directory'; |
| + expected['link'] = followLinks ? 'Directory' : 'Link'; |
| + if (recursive) { |
| + expected['target/createdDirectly'] = 'Directory'; |
| + expected['target/createdThroughLink'] = 'Directory'; |
| + expected['target/createdFile'] = 'File'; |
| + if (followLinks) { |
| + expected['link/createdDirectly'] = 'Directory'; |
| + expected['link/createdThroughLink'] = 'Directory'; |
| + expected['link/createdFile'] = 'File'; |
| + } |
| + } |
| + return expected; |
| + } |
| + |
| + void checkEntity(FileSystemEntity x, Map expected) { |
| + String ending = new Path(x.path).relativeTo(base).toString(); |
| + Expect.isNotNull(expected[ending]); |
| + Expect.isTrue(x.toString().startsWith(expected[ending])); |
| + expected[ending] = 'Found'; |
| + } |
| + |
| + List futures = []; |
| + for (bool recursive in [true, false]) { |
| + for (bool followLinks in [true, false]) { |
| + Map expected = makeExpected(recursive, followLinks); |
| + for (var x in baseDir.listSync(recursive: recursive, |
| + followLinks: followLinks)) { |
|
Bill Hesse
2013/03/21 18:36:44
Indentation.
|
| + checkEntity(x, expected); |
| + } |
| + for (var v in expected.values) { |
| + Expect.equals('Found', v); |
| + } |
| + expected = makeExpected(recursive, followLinks); |
| + futures.add( |
| + baseDir.list(recursive: recursive, followLinks: followLinks).reduce( |
|
Bill Hesse
2013/03/21 18:36:44
Use Stream.reduce to call a function with each eve
Søren Gjesse
2013/03/22 08:07:35
Run the same tests for listSync.
Bill Hesse
2013/03/22 09:58:55
I do! It is just so small you missed it - lines 1
Bill Hesse
2013/03/22 09:58:55
Switched to the more straightforward "create a Com
|
| + null, |
| + (_, x) { |
| + checkEntity(x, expected); |
| + }).then((_) { |
| + for (var v in expected.values) { |
| + Expect.equals('Found', v); |
| + } |
| + })); |
| + } |
| + } |
| + Future.wait(futures).then((_) { |
| + baseDir.deleteSync(recursive: true); |
| + }); |
| } |