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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/stdin_sync_script.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/stdin_sync_test.dart
diff --git a/tests/standalone/io/stdin_sync_test.dart b/tests/standalone/io/stdin_sync_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3c2bf803329eb59e70afade9d4df6a3287f29b26
--- /dev/null
+++ b/tests/standalone/io/stdin_sync_test.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "dart:io";
+import "dart:json";
+
+void test(String line, List<String> expected) {
+ var script = new Path(Platform.script).directoryPath;
+ script = script.append("stdin_sync_script.dart");
+ Process.start(Platform.executable,
+ [script.toNativePath()]..addAll(
+ expected.map(stringify))).then((process) {
+ process.stdin.write(line);
+ process.stdin.close();
+ process.stderr
+ .transform(new StringDecoder())
+ .transform(new LineTransformer())
+ .fold(new StringBuffer(), (b, d) => b..write(d))
+ .then((data) {
+ if (data.toString() != '') throw "Bad output: '$data'";
+ });
+ process.stdout
+ .transform(new StringDecoder())
+ .transform(new LineTransformer())
+ .fold(new StringBuffer(), (b, d) => b..write(d))
+ .then((data) {
+ if (data.toString() != 'true') throw "Bad output: '$data'";
+ });
+ });
+}
+
+void main() {
+ test("hej\x01\x00\x0d\x0a\x0a4\x0a", ['hej\x01\x00', '', '4']);
+
+ test("hej\u0187", ['hej\u0187']);
+
+ test("hej\rhej\nhej\r", ['hej\rhej', 'hej\r']);
+
+ test("hej\r\r\nhej\r\nhej\r", ['hej\r', 'hej', 'hej\r']);
+
+ test("hej", ['hej']);
+}
« 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