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

Side by Side Diff: test/testing.dart

Issue 998843003: pkg/csslib: formatting (Closed) Base URL: https://github.com/dart-lang/csslib@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** Common definitions used for setting up the test environment. */ 5 /** Common definitions used for setting up the test environment. */
6 library testing; 6 library testing;
7 7
8 import 'package:csslib/parser.dart'; 8 import 'package:csslib/parser.dart';
9 import 'package:csslib/visitor.dart'; 9 import 'package:csslib/visitor.dart';
10 import 'package:csslib/src/messages.dart'; 10 import 'package:csslib/src/messages.dart';
11 11
12 void useMockMessages() { 12 void useMockMessages() {
13 messages = new Messages(printHandler: (message) {}); 13 messages = new Messages(printHandler: (message) {});
14 } 14 }
15 15
16 /** 16 /**
17 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, 17 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
18 * CSS will allow any property/value pairs regardless of validity; all of our 18 * CSS will allow any property/value pairs regardless of validity; all of our
19 * tests (by default) will ensure that the CSS is really valid. 19 * tests (by default) will ensure that the CSS is really valid.
20 */ 20 */
21 StyleSheet parseCss(String cssInput, {List<Message> errors, 21 StyleSheet parseCss(String cssInput,
22 List<String> opts}) => 22 {List<Message> errors, List<String> opts}) => parse(cssInput,
23 parse(cssInput, errors: errors, options: opts == null ? 23 errors: errors,
24 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts); 24 options: opts == null
25 ? ['--no-colors', '--checked', '--warnings_as_errors', 'memory']
26 : opts);
25 27
26 /** 28 /**
27 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, 29 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
28 * CSS will allow any property/value pairs regardless of validity; all of our 30 * CSS will allow any property/value pairs regardless of validity; all of our
29 * tests (by default) will ensure that the CSS is really valid. 31 * tests (by default) will ensure that the CSS is really valid.
30 */ 32 */
31 StyleSheet compileCss(String cssInput, {List<Message> errors, List<String> opts, 33 StyleSheet compileCss(String cssInput, {List<Message> errors, List<String> opts,
32 bool polyfill: false, List<StyleSheet> includes: null}) => 34 bool polyfill: false, List<StyleSheet> includes: null}) => compile(cssInput,
33 compile(cssInput, errors: errors, options: opts == null ? 35 errors: errors,
34 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts, 36 options: opts == null
35 polyfill: polyfill, includes: includes); 37 ? ['--no-colors', '--checked', '--warnings_as_errors', 'memory']
38 : opts,
39 polyfill: polyfill,
40 includes: includes);
36 41
37 StyleSheet polyFillCompileCss(input, {List<Message> errors, 42 StyleSheet polyFillCompileCss(input,
38 List<String> opts}) => 43 {List<Message> errors, List<String> opts}) =>
39 compileCss(input, errors: errors, polyfill: true, opts: opts); 44 compileCss(input, errors: errors, polyfill: true, opts: opts);
40 45
41 /** CSS emitter walks the style sheet tree and emits readable CSS. */ 46 /** CSS emitter walks the style sheet tree and emits readable CSS. */
42 final _emitCss = new CssPrinter(); 47 final _emitCss = new CssPrinter();
43 48
44 /** Simple Visitor does nothing but walk tree. */ 49 /** Simple Visitor does nothing but walk tree. */
45 final _cssVisitor = new Visitor(); 50 final _cssVisitor = new Visitor();
46 51
47 /** Pretty printer for CSS. */ 52 /** Pretty printer for CSS. */
48 String prettyPrint(StyleSheet ss) { 53 String prettyPrint(StyleSheet ss) {
(...skipping 11 matching lines...) Expand all
60 walkTree(ss); 65 walkTree(ss);
61 return (_emitCss..visitTree(ss, pretty: false)).toString(); 66 return (_emitCss..visitTree(ss, pretty: false)).toString();
62 } 67 }
63 68
64 /** Walks the style sheet tree does nothing; insures the basic walker works. */ 69 /** Walks the style sheet tree does nothing; insures the basic walker works. */
65 void walkTree(StyleSheet ss) { 70 void walkTree(StyleSheet ss) {
66 _cssVisitor..visitTree(ss); 71 _cssVisitor..visitTree(ss);
67 } 72 }
68 73
69 String dumpTree(StyleSheet ss) => treeToDebugString(ss); 74 String dumpTree(StyleSheet ss) => treeToDebugString(ss);
OLDNEW
« pubspec.yaml ('K') | « test/selector_test.dart ('k') | test/var_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698