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'; |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 const options = const PreprocessorOptions( | 24 const options = const PreprocessorOptions( |
25 useColors: false, warningsAsErrors: true, inputFile: 'memory'); | 25 useColors: false, warningsAsErrors: true, inputFile: 'memory'); |
26 | 26 |
27 /** | 27 /** |
28 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, | 28 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, |
29 * CSS will allow any property/value pairs regardless of validity; all of our | 29 * CSS will allow any property/value pairs regardless of validity; all of our |
30 * tests (by default) will ensure that the CSS is really valid. | 30 * tests (by default) will ensure that the CSS is really valid. |
31 */ | 31 */ |
32 StyleSheet parseCss(String cssInput, | 32 StyleSheet parseCss(String cssInput, |
33 {List<Message> errors, PreprocessorOptions opts}) => parse(cssInput, | 33 {List<Message> errors, PreprocessorOptions opts}) => |
| 34 parse(cssInput, |
34 errors: errors, | 35 errors: errors, |
35 options: opts == null | 36 options: |
36 ? simpleOptionsWithCheckedAndWarningsAsErrors | 37 opts == null ? simpleOptionsWithCheckedAndWarningsAsErrors : opts); |
37 : opts); | |
38 | 38 |
39 /** | 39 /** |
40 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, | 40 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, |
41 * CSS will allow any property/value pairs regardless of validity; all of our | 41 * CSS will allow any property/value pairs regardless of validity; all of our |
42 * tests (by default) will ensure that the CSS is really valid. | 42 * tests (by default) will ensure that the CSS is really valid. |
43 */ | 43 */ |
44 StyleSheet compileCss(String cssInput, {List<Message> errors, | 44 StyleSheet compileCss(String cssInput, |
45 PreprocessorOptions opts, bool polyfill: false, | 45 {List<Message> errors, |
46 List<StyleSheet> includes: null}) => compile(cssInput, | 46 PreprocessorOptions opts, |
| 47 bool polyfill: false, |
| 48 List<StyleSheet> includes: null}) => |
| 49 compile(cssInput, |
47 errors: errors, | 50 errors: errors, |
48 options: opts == null | 51 options: |
49 ? simpleOptionsWithCheckedAndWarningsAsErrors | 52 opts == null ? simpleOptionsWithCheckedAndWarningsAsErrors : opts, |
50 : opts, | |
51 polyfill: polyfill, | 53 polyfill: polyfill, |
52 includes: includes); | 54 includes: includes); |
53 | 55 |
54 StyleSheet polyFillCompileCss(input, | 56 StyleSheet polyFillCompileCss(input, |
55 {List<Message> errors, PreprocessorOptions opts}) => | 57 {List<Message> errors, PreprocessorOptions opts}) => |
56 compileCss(input, errors: errors, polyfill: true, opts: opts); | 58 compileCss(input, errors: errors, polyfill: true, opts: opts); |
57 | 59 |
58 /** CSS emitter walks the style sheet tree and emits readable CSS. */ | 60 /** CSS emitter walks the style sheet tree and emits readable CSS. */ |
59 final _emitCss = new CssPrinter(); | 61 final _emitCss = new CssPrinter(); |
60 | 62 |
(...skipping 16 matching lines...) Expand all Loading... |
77 walkTree(ss); | 79 walkTree(ss); |
78 return (_emitCss..visitTree(ss, pretty: false)).toString(); | 80 return (_emitCss..visitTree(ss, pretty: false)).toString(); |
79 } | 81 } |
80 | 82 |
81 /** Walks the style sheet tree does nothing; insures the basic walker works. */ | 83 /** Walks the style sheet tree does nothing; insures the basic walker works. */ |
82 void walkTree(StyleSheet ss) { | 84 void walkTree(StyleSheet ss) { |
83 _cssVisitor..visitTree(ss); | 85 _cssVisitor..visitTree(ss); |
84 } | 86 } |
85 | 87 |
86 String dumpTree(StyleSheet ss) => treeToDebugString(ss); | 88 String dumpTree(StyleSheet ss) => treeToDebugString(ss); |
OLD | NEW |