| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library error_test; | 5 library error_test; |
| 6 | 6 |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'testing.dart'; | 8 import 'testing.dart'; |
| 9 import 'package:csslib/src/messages.dart'; | 9 import 'package:csslib/src/messages.dart'; |
| 10 | 10 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 ^'''); | 216 ^'''); |
| 217 | 217 |
| 218 expect(stylesheet != null, true); | 218 expect(stylesheet != null, true); |
| 219 | 219 |
| 220 // Formating is off with an extra space. However, the entire value is bad | 220 // Formating is off with an extra space. However, the entire value is bad |
| 221 // and isn't processed anyway. | 221 // and isn't processed anyway. |
| 222 expect(prettyPrint(stylesheet), r''' | 222 expect(prettyPrint(stylesheet), r''' |
| 223 .foobar { | 223 .foobar { |
| 224 color: # 123 fff; | 224 color: # 123 fff; |
| 225 }'''); | 225 }'''); |
| 226 | |
| 227 } | 226 } |
| 228 | 227 |
| 229 void testBadUnicode() { | 228 void testBadUnicode() { |
| 230 var errors = []; | 229 var errors = []; |
| 231 final String input = ''' | 230 final String input = ''' |
| 232 @font-face { | 231 @font-face { |
| 233 src: url(fonts/BBCBengali.ttf) format("opentype"); | 232 src: url(fonts/BBCBengali.ttf) format("opentype"); |
| 234 unicode-range: U+400-200; | 233 unicode-range: U+400-200; |
| 235 }'''; | 234 }'''; |
| 236 | 235 |
| 237 var stylesheet = parseCss(input, errors: errors); | 236 var stylesheet = parseCss(input, errors: errors); |
| 238 | 237 |
| 239 expect(errors.isEmpty, false); | 238 expect(errors.isEmpty, false); |
| 240 expect(errors[0].toString(), | 239 expect(errors[0].toString(), |
| 241 'error on line 3, column 20: unicode first range can not be greater than ' | 240 'error on line 3, column 20: unicode first range can not be greater than ' |
| 242 'last\n' | 241 'last\n' |
| 243 ' unicode-range: U+400-200;\n' | 242 ' unicode-range: U+400-200;\n' |
| 244 ' ^^^^^^^'); | 243 ' ^^^^^^^'); |
| 245 | 244 |
| 246 final String input2 = ''' | 245 final String input2 = ''' |
| 247 @font-face { | 246 @font-face { |
| 248 src: url(fonts/BBCBengali.ttf) format("opentype"); | 247 src: url(fonts/BBCBengali.ttf) format("opentype"); |
| 249 unicode-range: U+12FFFF; | 248 unicode-range: U+12FFFF; |
| 250 }'''; | 249 }'''; |
| 251 | 250 |
| 252 stylesheet = parseCss(input2, errors: errors..clear()); | 251 stylesheet = parseCss(input2, errors: errors..clear()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 344 } |
| 346 | 345 |
| 347 main() { | 346 main() { |
| 348 test('font-weight value errors', testUnsupportedFontWeights); | 347 test('font-weight value errors', testUnsupportedFontWeights); |
| 349 test('line-height value errors', testUnsupportedLineHeights); | 348 test('line-height value errors', testUnsupportedLineHeights); |
| 350 test('bad selectors', testBadSelectors); | 349 test('bad selectors', testBadSelectors); |
| 351 test('bad Hex values', testBadHexValues); | 350 test('bad Hex values', testBadHexValues); |
| 352 test('bad unicode ranges', testBadUnicode); | 351 test('bad unicode ranges', testBadUnicode); |
| 353 test('nested rules', testBadNesting); | 352 test('nested rules', testBadNesting); |
| 354 } | 353 } |
| OLD | NEW |