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

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

Issue 2753233002: [dart:io] Move Platform.ansiSupported to {Stdin,Stdout}.supportsAnsiEscapes (Closed)
Patch Set: . Created 3 years, 9 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
« sdk/lib/io/stdio.dart ('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/ansi_supported_test.dart
diff --git a/tests/standalone/io/ansi_supported_test.dart b/tests/standalone/io/ansi_supported_test.dart
index a0f46690eb06907ace8062ae3f8611e0ec15e52a..00525e1255657084c452c80aba13a2379843383a 100644
--- a/tests/standalone/io/ansi_supported_test.dart
+++ b/tests/standalone/io/ansi_supported_test.dart
@@ -6,18 +6,30 @@ import 'dart:io';
import "package:expect/expect.dart";
-main() {
+testStdout(Stdout s) {
try {
- Platform.ansiSupported;
- } catch (e, s) {
- Expect.fail("Platform.ansiSupported threw: $e\n$s\n");
+ s.ansiSupported;
+ } catch (e, st) {
+ Expect.fail("$s.ansiSupported threw: $e\n$st\n");
}
- Expect.isNotNull(Platform.ansiSupported);
- Expect.isTrue(Platform.ansiSupported is bool);
- if (stdout.hasTerminal && Platform.ansiSupported) {
- stdout.writeln('\x1b[31mThis text has a red foreground using SGR.31.');
- stdout.writeln('\x1b[39mThis text has restored the foreground color.');
+ Expect.isNotNull(s.ansiSupported);
+ Expect.isTrue(s.ansiSupported is bool);
+ if (s.ansiSupported) {
+ s.writeln('\x1b[31mThis text has a red foreground using SGR.31.');
+ s.writeln('\x1b[39mThis text has restored the foreground color.');
} else {
- stdout.writeln('ANSI codes not supported on this platform');
+ s.writeln('ANSI codes not supported on this platform');
+ }
+}
+
+main() {
+ testStdout(stdout);
+ testStdout(stderr);
+ try {
+ stdin.ansiSupported;
+ } catch (e, st) {
+ Expect.fail("stdin.ansiSupported threw: $e\n$st\n");
}
+ Expect.isNotNull(stdin.ansiSupported);
+ Expect.isTrue(stdin.ansiSupported is bool);
}
« sdk/lib/io/stdio.dart ('K') | « sdk/lib/io/stdio.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698