| OLD | NEW | 
|   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  Loading... | 
|  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); | 
| OLD | NEW |