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

Unified Diff: tests/standalone/io/stdin_sync_test.dart

Issue 19627004: Add echo and line modes to Stdin. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing files. 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 side-by-side diff with in-line comments
Download patch
« runtime/bin/stdin_linux.cc ('K') | « sdk/lib/io/stdio.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
index bb0c113a9c5546cd6ac0930a3432bc662e56818e..902487451f33d6a6d29b20d71c4acd96193b280a 100644
--- a/tests/standalone/io/stdin_sync_test.dart
+++ b/tests/standalone/io/stdin_sync_test.dart
@@ -6,31 +6,31 @@ import "package:path/path.dart";
import "dart:io";
import "dart:json";
-void test(String line, List<String> expected) {
- var script = join(dirname(Platform.script), "stdin_sync_script.dart");
- Process.start(Platform.executable,
- [script]..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 testReadByte() {
+ void test(String line, List<String> expected) {
+ var script = join(dirname(Platform.script), "stdin_sync_script.dart");
+ Process.start(Platform.executable,
+ [script]..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']);
@@ -46,3 +46,29 @@ void main() {
test("hej", ['hej']);
}
+
+void testEchoMode() {
+ stdin.echoMode = false;
+ var line;
+ while ((line = stdin.readLineSync()) != null) {
+ print("You typed: $line");
+ }
+}
+
+void testRawMode() {
+ stdin.lineMode = false;
+ var char;
+ while ((char = stdin.readByteSync()) != -1) {
+ print("You typed: $char");
+ }
+}
+
+
+void main() {
+ testReadByte();
+
+ // testEchoMode and testRawMode is an developer-interactive test, thus not
+ // enabled.
+ //testEchoMode();
+ //testRawMode();
+}
« runtime/bin/stdin_linux.cc ('K') | « sdk/lib/io/stdio.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698