| 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 useMockMessages() { | 12 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 errors, List opts}) => | 21 StyleSheet parseCss(String cssInput, {List errors, List opts}) => |
| 22 parse(cssInput, errors: errors, options: opts == null ? | 22 parse(cssInput, errors: errors, options: opts == null ? |
| 23 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts); | 23 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts); |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, | 26 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, |
| 27 * CSS will allow any property/value pairs regardless of validity; all of our | 27 * CSS will allow any property/value pairs regardless of validity; all of our |
| 28 * tests (by default) will ensure that the CSS is really valid. | 28 * tests (by default) will ensure that the CSS is really valid. |
| 29 */ | 29 */ |
| 30 StyleSheet compileCss(String cssInput, {List errors, List opts}) => | 30 StyleSheet compileCss(String cssInput, |
| 31 {List errors, List opts, bool polyfill: false}) => |
| 31 compile(cssInput, errors: errors, options: opts == null ? | 32 compile(cssInput, errors: errors, options: opts == null ? |
| 32 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts); | 33 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts, |
| 34 polyfill: polyfill); |
| 33 | 35 |
| 34 /** CSS emitter walks the style sheet tree and emits readable CSS. */ | 36 /** CSS emitter walks the style sheet tree and emits readable CSS. */ |
| 35 var _emitCss = new CssPrinter(); | 37 var _emitCss = new CssPrinter(); |
| 36 | 38 |
| 37 /** Simple Visitor does nothing but walk tree. */ | 39 /** Simple Visitor does nothing but walk tree. */ |
| 38 var _cssVisitor = new Visitor(); | 40 var _cssVisitor = new Visitor(); |
| 39 | 41 |
| 40 /** Pretty printer for CSS. */ | 42 /** Pretty printer for CSS. */ |
| 41 String prettyPrint(StyleSheet ss) { | 43 String prettyPrint(StyleSheet ss) { |
| 42 // Walk the tree testing basic Vistor class. | 44 // Walk the tree testing basic Vistor class. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 } | 57 } |
| 56 | 58 |
| 57 /** Walks the style sheet tree does nothing; insures the basic walker works. */ | 59 /** Walks the style sheet tree does nothing; insures the basic walker works. */ |
| 58 void walkTree(StyleSheet ss) { | 60 void walkTree(StyleSheet ss) { |
| 59 _cssVisitor..visitTree(ss); | 61 _cssVisitor..visitTree(ss); |
| 60 } | 62 } |
| 61 | 63 |
| 62 String dumpTree(StyleSheet ss) => treeToDebugString(ss); | 64 String dumpTree(StyleSheet ss) => treeToDebugString(ss); |
| 63 | 65 |
| 64 | 66 |
| OLD | NEW |