Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: tests/standalone/io/stdin_sync_test.dart

Issue 18516002: Add Stdio.readByteSync and Stdio.readLineSync. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle \r\r\n. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/standalone/io/stdin_sync_script.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « tests/standalone/io/stdin_sync_script.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698