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 | 9 |
10 void testReadByte() { | 10 void testReadByte() { |
11 void test(String line, List<String> expected) { | 11 void test(String line, List<String> expected) { |
12 var script = join(dirname(Platform.script), "stdin_sync_script.dart"); | 12 var script = Platform.script.resolve("stdin_sync_script.dart").toFilePath(); |
13 Process.start(Platform.executable, | 13 Process.start(Platform.executable, |
14 ["--checked", script]..addAll( | 14 ["--checked", script]..addAll( |
15 expected.map(JSON.encode))).then((process) { | 15 expected.map(JSON.encode))).then((process) { |
16 process.stdin.write(line); | 16 process.stdin.write(line); |
17 process.stdin.close(); | 17 process.stdin.close(); |
18 process.stderr | 18 process.stderr |
19 .transform(UTF8.decoder) | 19 .transform(UTF8.decoder) |
20 .transform(new LineSplitter()) | 20 .transform(new LineSplitter()) |
21 .fold(new StringBuffer(), (b, d) => b..write(d)) | 21 .fold(new StringBuffer(), (b, d) => b..write(d)) |
22 .then((data) { | 22 .then((data) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 | 62 |
63 void main() { | 63 void main() { |
64 testReadByte(); | 64 testReadByte(); |
65 | 65 |
66 // testEchoMode and testLineMode is an developer-interactive test, thus not | 66 // testEchoMode and testLineMode is an developer-interactive test, thus not |
67 // enabled. | 67 // enabled. |
68 //testEchoMode(); | 68 //testEchoMode(); |
69 //testLineMode(); | 69 //testLineMode(); |
70 } | 70 } |
OLD | NEW |