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

Side by Side 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 unified diff | Download patch
« sdk/lib/io/stdio.dart ('K') | « sdk/lib/io/stdio.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:io'; 5 import 'dart:io';
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 main() { 9 testStdout(Stdout s) {
10 try { 10 try {
11 Platform.ansiSupported; 11 s.ansiSupported;
12 } catch (e, s) { 12 } catch (e, st) {
13 Expect.fail("Platform.ansiSupported threw: $e\n$s\n"); 13 Expect.fail("$s.ansiSupported threw: $e\n$st\n");
14 } 14 }
15 Expect.isNotNull(Platform.ansiSupported); 15 Expect.isNotNull(s.ansiSupported);
16 Expect.isTrue(Platform.ansiSupported is bool); 16 Expect.isTrue(s.ansiSupported is bool);
17 if (stdout.hasTerminal && Platform.ansiSupported) { 17 if (s.ansiSupported) {
18 stdout.writeln('\x1b[31mThis text has a red foreground using SGR.31.'); 18 s.writeln('\x1b[31mThis text has a red foreground using SGR.31.');
19 stdout.writeln('\x1b[39mThis text has restored the foreground color.'); 19 s.writeln('\x1b[39mThis text has restored the foreground color.');
20 } else { 20 } else {
21 stdout.writeln('ANSI codes not supported on this platform'); 21 s.writeln('ANSI codes not supported on this platform');
22 } 22 }
23 } 23 }
24
25 main() {
26 testStdout(stdout);
27 testStdout(stderr);
28 try {
29 stdin.ansiSupported;
30 } catch (e, st) {
31 Expect.fail("stdin.ansiSupported threw: $e\n$st\n");
32 }
33 Expect.isNotNull(stdin.ansiSupported);
34 Expect.isTrue(stdin.ansiSupported is bool);
35 }
OLDNEW
« 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