| 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\u0187", ['hej\u0187']); |
| 37 |
| 38 test("hej\rhej\nhej\r", ['hej\rhej', 'hej\r']); |
| 39 |
| 40 test("hej\r\r\nhej\r\nhej\r", ['hej\r', 'hej', 'hej\r']); |
| 41 |
| 42 test("hej", ['hej']); |
| 43 } |
| OLD | NEW |