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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a0f46690eb06907ace8062ae3f8611e0ec15e52a |
--- /dev/null |
+++ b/tests/standalone/io/ansi_supported_test.dart |
@@ -0,0 +1,23 @@ |
+// Copyright (c) 2017, 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 "package:expect/expect.dart"; |
+ |
+main() { |
+ try { |
+ Platform.ansiSupported; |
+ } catch (e, s) { |
+ Expect.fail("Platform.ansiSupported threw: $e\n$s\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.'); |
+ } else { |
+ stdout.writeln('ANSI codes not supported on this platform'); |
+ } |
+} |