| 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 "dart:io"; | 6 import "dart:io"; |
| 6 import "dart:json"; | 7 import "dart:json"; |
| 7 | 8 |
| 8 void test(String line, List<String> expected) { | 9 void test(String line, List<String> expected) { |
| 9 var script = new Path(Platform.script).directoryPath; | 10 var script = join(dirname(Platform.script), "stdin_sync_script.dart"); |
| 10 script = script.append("stdin_sync_script.dart"); | |
| 11 Process.start(Platform.executable, | 11 Process.start(Platform.executable, |
| 12 [script.toNativePath()]..addAll( | 12 [script]..addAll( |
| 13 expected.map(stringify))).then((process) { | 13 expected.map(stringify))).then((process) { |
| 14 process.stdin.write(line); | 14 process.stdin.write(line); |
| 15 process.stdin.close(); | 15 process.stdin.close(); |
| 16 process.stderr | 16 process.stderr |
| 17 .transform(new StringDecoder()) | 17 .transform(new StringDecoder()) |
| 18 .transform(new LineTransformer()) | 18 .transform(new LineTransformer()) |
| 19 .fold(new StringBuffer(), (b, d) => b..write(d)) | 19 .fold(new StringBuffer(), (b, d) => b..write(d)) |
| 20 .then((data) { | 20 .then((data) { |
| 21 if (data.toString() != '') throw "Bad output: '$data'"; | 21 if (data.toString() != '') throw "Bad output: '$data'"; |
| 22 }); | 22 }); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 if (Platform.isWindows) { | 40 if (Platform.isWindows) { |
| 41 // Windows trim one of the \r. | 41 // Windows trim one of the \r. |
| 42 test("hej\r\r\r\nhej\r\nhej\r", ['hej\r', 'hej', 'hej\r']); | 42 test("hej\r\r\r\nhej\r\nhej\r", ['hej\r', 'hej', 'hej\r']); |
| 43 } else { | 43 } else { |
| 44 test("hej\r\r\nhej\r\nhej\r", ['hej\r', 'hej', 'hej\r']); | 44 test("hej\r\r\nhej\r\nhej\r", ['hej\r', 'hej', 'hej\r']); |
| 45 } | 45 } |
| 46 | 46 |
| 47 test("hej", ['hej']); | 47 test("hej", ['hej']); |
| 48 } | 48 } |
| OLD | NEW |