| OLD | NEW |
| 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 library descriptor_test; | 5 library descriptor_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 | 702 |
| 703 expectTestsPass("directory().load() loads a deeply-nested file", () { | 703 expectTestsPass("directory().load() loads a deeply-nested file", () { |
| 704 test('test', () { | 704 test('test', () { |
| 705 var dir = d.dir('dir', [ | 705 var dir = d.dir('dir', [ |
| 706 d.dir('subdir', [ | 706 d.dir('subdir', [ |
| 707 d.file('name.txt', 'subcontents') | 707 d.file('name.txt', 'subcontents') |
| 708 ]), | 708 ]), |
| 709 d.file('name.txt', 'contents') | 709 d.file('name.txt', 'contents') |
| 710 ]); | 710 ]); |
| 711 | 711 |
| 712 expect(byteStreamToString(dir.load(path.join('subdir', 'name.txt'))), | 712 expect(byteStreamToString(dir.load('subdir/name.txt')), |
| 713 completion(equals('subcontents'))); | 713 completion(equals('subcontents'))); |
| 714 }); | 714 }); |
| 715 }); | 715 }); |
| 716 | 716 |
| 717 expectTestsPass("directory().read() fails", () { | 717 expectTestsPass("directory().read() fails", () { |
| 718 test('test', () { | 718 test('test', () { |
| 719 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); | 719 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); |
| 720 expect(dir.read().toList(), | 720 expect(dir.read().toList(), |
| 721 throwsA(equals("Can't read the contents of 'dir': is a directory."))); | 721 throwsA(equals("Can't read the contents of 'dir': is a directory."))); |
| 722 }); | 722 }); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 | 882 |
| 883 Future<List<int>> byteStreamToList(Stream<List<int>> stream) { | 883 Future<List<int>> byteStreamToList(Stream<List<int>> stream) { |
| 884 return stream.reduce(<int>[], (buffer, chunk) { | 884 return stream.reduce(<int>[], (buffer, chunk) { |
| 885 buffer.addAll(chunk); | 885 buffer.addAll(chunk); |
| 886 return buffer; | 886 return buffer; |
| 887 }); | 887 }); |
| 888 } | 888 } |
| 889 | 889 |
| 890 Future<String> byteStreamToString(Stream<List<int>> stream) => | 890 Future<String> byteStreamToString(Stream<List<int>> stream) => |
| 891 byteStreamToList(stream).then((bytes) => new String.fromCharCodes(bytes)); | 891 byteStreamToList(stream).then((bytes) => new String.fromCharCodes(bytes)); |
| OLD | NEW |