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 "package:path/path.dart"; | 5 import "package:path/path.dart"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 import "dart:json"; | 7 import "dart:json"; |
8 | 8 |
9 void testReadByte() { | 9 void testReadByte() { |
10 void test(String line, List<String> expected) { | 10 void test(String line, List<String> expected) { |
11 var script = join(dirname(Platform.script), "stdin_sync_script.dart"); | 11 var script = join(dirname(Platform.script), "stdin_sync_script.dart"); |
12 Process.start(Platform.executable, | 12 Process.start(Platform.executable, |
13 [script]..addAll( | 13 ["--checked", script]..addAll( |
14 expected.map(stringify))).then((process) { | 14 expected.map(stringify))).then((process) { |
15 process.stdin.write(line); | 15 process.stdin.write(line); |
16 process.stdin.close(); | 16 process.stdin.close(); |
17 process.stderr | 17 process.stderr |
18 .transform(new StringDecoder()) | 18 .transform(new StringDecoder()) |
19 .transform(new LineTransformer()) | 19 .transform(new LineTransformer()) |
20 .fold(new StringBuffer(), (b, d) => b..write(d)) | 20 .fold(new StringBuffer(), (b, d) => b..write(d)) |
21 .then((data) { | 21 .then((data) { |
22 if (data.toString() != '') throw "Bad output: '$data'"; | 22 if (data.toString() != '') throw "Bad output: '$data'"; |
23 }); | 23 }); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 | 61 |
62 void main() { | 62 void main() { |
63 testReadByte(); | 63 testReadByte(); |
64 | 64 |
65 // testEchoMode and testLineMode is an developer-interactive test, thus not | 65 // testEchoMode and testLineMode is an developer-interactive test, thus not |
66 // enabled. | 66 // enabled. |
67 //testEchoMode(); | 67 //testEchoMode(); |
68 //testLineMode(); | 68 //testLineMode(); |
69 } | 69 } |
OLD | NEW |