| 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 import "dart:json"; | 7 import "dart:json"; | 
| 8 | 8 | 
| 9 import "package:path/path.dart"; | 9 import "package:path/path.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 = join(dirname(Platform.script), "stdin_sync_script.dart"); | 13     var script = join(dirname(Platform.script), "stdin_sync_script.dart"); | 
| 14     Process.start(Platform.executable, | 14     Process.start(Platform.executable, | 
| 15                   ["--checked", script]..addAll( | 15                   ["--checked", script]..addAll( | 
| 16                       expected.map(stringify))).then((process) { | 16                       expected.map(stringify))).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(new StringDecoder()) | 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           }); | 
| 26       process.stdout | 26       process.stdout | 
| 27           .transform(new StringDecoder()) | 27           .transform(UTF8.decoder) | 
| 28           .transform(new LineSplitter()) | 28           .transform(new LineSplitter()) | 
| 29           .fold(new StringBuffer(), (b, d) => b..write(d)) | 29           .fold(new StringBuffer(), (b, d) => b..write(d)) | 
| 30           .then((data) { | 30           .then((data) { | 
| 31             if (data.toString() != 'true') throw "Bad output: '$data'"; | 31             if (data.toString() != 'true') throw "Bad output: '$data'"; | 
| 32           }); | 32           }); | 
| 33     }); | 33     }); | 
| 34   } | 34   } | 
| 35 | 35 | 
| 36   test("hej\x01\x00\x0d\x0a\x0a4\x0a", ['hej\x01\x00', '', '4']); | 36   test("hej\x01\x00\x0d\x0a\x0a4\x0a", ['hej\x01\x00', '', '4']); | 
| 37 | 37 | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 62 | 62 | 
| 63 | 63 | 
| 64 void main() { | 64 void main() { | 
| 65   testReadByte(); | 65   testReadByte(); | 
| 66 | 66 | 
| 67   // testEchoMode and testLineMode is an developer-interactive test, thus not | 67   // testEchoMode and testLineMode is an developer-interactive test, thus not | 
| 68   // enabled. | 68   // enabled. | 
| 69   //testEchoMode(); | 69   //testEchoMode(); | 
| 70   //testLineMode(); | 70   //testLineMode(); | 
| 71 } | 71 } | 
| OLD | NEW | 
|---|