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 import "dart:convert"; | 5 import "dart:convert"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 | 7 |
8 import "package:path/path.dart"; | 8 import "package:path/path.dart"; |
9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
10 | 10 |
11 void testReadByte() { | 11 void testReadByte() { |
12 void test(String line, List<String> expected) { | 12 void test(String line, List<String> expected) { |
13 var script = Platform.script.resolve("stdin_sync_script.dart").toFilePath(); | 13 var script = Platform.script.resolve("stdin_sync_script.dart").toFilePath(); |
14 Process.start(Platform.executable, | 14 Process.start(Platform.executable, |
15 ["--checked", script]..addAll( | 15 [script]..addAll( |
16 expected.map(JSON.encode))).then((process) { | 16 expected.map(JSON.encode))).then((process) { |
17 process.stdin.write(line); | 17 process.stdin.write(line); |
18 process.stdin.close(); | 18 process.stdin.close(); |
19 process.stderr | 19 process.stderr |
20 .transform(UTF8.decoder) | 20 .transform(UTF8.decoder) |
21 .transform(new LineSplitter()) | 21 .transform(new LineSplitter()) |
22 .fold(new StringBuffer(), (b, d) => b..write(d)) | 22 .fold(new StringBuffer(), (b, d) => b..write(d)) |
23 .then((data) { | 23 .then((data) { |
24 if (data.toString() != '') throw "Bad output: '$data'"; | 24 if (data.toString() != '') throw "Bad output: '$data'"; |
25 }); | 25 }); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 | 71 |
72 void main() { | 72 void main() { |
73 testReadByte(); | 73 testReadByte(); |
74 | 74 |
75 // testEchoMode and testLineMode is developer-interactive tests, thus not | 75 // testEchoMode and testLineMode is developer-interactive tests, thus not |
76 // enabled. | 76 // enabled. |
77 //testEchoMode(); | 77 //testEchoMode(); |
78 //testLineMode(); | 78 //testLineMode(); |
79 } | 79 } |
OLD | NEW |