Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "dart:io"; | |
| 6 import "dart:json"; | |
| 7 | |
| 8 void test(String line, List<String> expected) { | |
| 9 var script = new Path(Platform.script).directoryPath; | |
| 10 script = script.append("stdin_sync_script.dart"); | |
| 11 Process.start(Platform.executable, | |
| 12 [script.toNativePath()]..addAll( | |
| 13 expected.map(stringify))).then((process) { | |
| 14 process.stdin.write(line); | |
| 15 process.stdin.close(); | |
| 16 process.stderr | |
| 17 .transform(new StringDecoder()) | |
| 18 .transform(new LineTransformer()) | |
| 19 .fold(new StringBuffer(), (b, d) => b..write(d)) | |
| 20 .then((data) { | |
| 21 if (data.toString() != '') throw "Bad output: '$data'"; | |
| 22 }); | |
| 23 process.stdout | |
| 24 .transform(new StringDecoder()) | |
| 25 .transform(new LineTransformer()) | |
| 26 .fold(new StringBuffer(), (b, d) => b..write(d)) | |
| 27 .then((data) { | |
| 28 // if (data.toString() != 'true') throw "Bad output: '$data'"; | |
| 29 }); | |
| 30 }); | |
| 31 } | |
| 32 | |
| 33 void main() { | |
| 34 test("hej\x01\x00\x0d\x0a\x0a4\x0a", ['hej\x01\x00', '', '4']); | |
| 35 | |
| 36 test("hej\xFF\x00", ['hej\xFF\x00']); | |
|
Bill Hesse
2013/07/02 13:08:27
This should fail on Windows, since you are writing
Anders Johnsen
2013/07/02 13:17:15
Done.
| |
| 37 | |
| 38 test("hej\rhej\nhej\r", ['hej\rhej', 'hej\r']); | |
| 39 | |
|
Bill Hesse
2013/07/02 13:08:27
"hej\r\r\nhej\r\rhej\n"
Anders Johnsen
2013/07/02 13:17:15
Done.
| |
| 40 test("hej", ['hej']); | |
| 41 } | |
| OLD | NEW |