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

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

Issue 2753233002: [dart:io] Move Platform.ansiSupported to {Stdin,Stdout}.supportsAnsiEscapes (Closed)
Patch Set: Fix typo 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
« runtime/bin/stdio_patch.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..643ae7a95b73c459cd420634c2005160cc422590 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.supportsAnsiEscapes;
+ } catch (e, st) {
+ Expect.fail("$s.supportsAnsiEscapes 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.supportsAnsiEscapes);
+ Expect.isTrue(s.supportsAnsiEscapes is bool);
+ if (s.supportsAnsiEscapes) {
+ 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 escape codes are not supported on this platform');
+ }
+}
+
+main() {
+ testStdout(stdout);
+ testStdout(stderr);
+ try {
+ stdin.supportsAnsiEscapes;
+ } catch (e, st) {
+ Expect.fail("stdin.supportsAnsiEscapes threw: $e\n$st\n");
}
+ Expect.isNotNull(stdin.supportsAnsiEscapes);
+ Expect.isTrue(stdin.supportsAnsiEscapes is bool);
}
« runtime/bin/stdio_patch.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