Chromium Code Reviews| 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 library declaration_test; | 5 library declaration_test; |
| 6 | 6 |
| 7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
| 8 | 8 |
| 9 import 'testing.dart'; | 9 import 'testing.dart'; |
| 10 | 10 |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1009 final input = r'''.foo { width: 50px; }'''; | 1009 final input = r'''.foo { width: 50px; }'''; |
| 1010 var stylesheet = parseCss(input); | 1010 var stylesheet = parseCss(input); |
| 1011 var decl = stylesheet.topLevels.single.declarationGroup.declarations.single; | 1011 var decl = stylesheet.topLevels.single.declarationGroup.declarations.single; |
| 1012 // This passes | 1012 // This passes |
| 1013 expect(decl.span.text, 'width: 50px'); | 1013 expect(decl.span.text, 'width: 50px'); |
| 1014 // This currently fails | 1014 // This currently fails |
| 1015 expect(decl.expression.span.text, '50px'); | 1015 expect(decl.expression.span.text, '50px'); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 void testDeclarationSpanWithCalc() { | 1018 void testDeclarationSpanWithCalc() { |
| 1019 final input = r'''.foo { height: calc(100% - 55px); }'''; | 1019 final input1 = r'''.foo { height: calc(100% - 55px); }'''; |
| 1020 var stylesheet = parseCss(input); | 1020 var stylesheet1 = parseCss(input1); |
| 1021 var decl = stylesheet.topLevels.single.declarationGroup.declarations.single; | 1021 var decl1 = stylesheet1.topLevels.single.declarationGroup.declarations.single; |
| 1022 // This fails, with span being "height: calc(" | 1022 expect(decl1.span.text, 'height: calc(100% - 55px)'); |
| 1023 expect(decl.span.text, 'height: calc(100% - 55px);'); | 1023 |
| 1024 final input2 = r'''.foo { left: calc((100%/3 - 2) * 1em - 2 * 1px); }'''; | |
| 1025 var stylesheet2 = parseCss(input2); | |
| 1026 var decl2 = stylesheet2.topLevels.single.declarationGroup.declarations.single; | |
| 1027 expect(decl2.span.text, 'left: calc((100%/3 - 2) * 1em - 2 * 1px)'); | |
| 1028 | |
| 1029 final input3 = r'''.foo { margin: calc(1rem - 2px) calc(1rem - 1px); }'''; | |
| 1030 var stylesheet3 = parseCss(input3); | |
| 1031 var decl3 = stylesheet3.topLevels.single.declarationGroup.declarations.single; | |
| 1032 expect(decl3.span.text, 'margin: calc(1rem - 2px) calc(1rem - 1px)'); | |
| 1033 | |
| 1034 var errors = []; | |
| 1035 final String input = r''' | |
| 1036 .foo { | |
| 1037 width: calc(1em + 5 * 2em); | |
| 1038 height: calc(1px + 2%) !important; | |
| 1039 border: 5px calc(1pt + 2cm) 6px calc(1em + 1in + 2px) red; | |
| 1040 border: calc(5px + 1em) 0px 1px calc(10 + 20 + 1px); | |
| 1041 margin: 25px calc(50px + (100% / (3 - 1em) - 20%)) calc(10px + 10 * 20) calc(1 00% - 10px); | |
| 1042 }'''; | |
| 1043 final String generated = r''' | |
| 1044 .foo { | |
| 1045 width: calc(1em + 5 * 2em); | |
| 1046 height: calc(1px + 2%) !important; | |
| 1047 border: 5px calc(1pt + 2cm) 6px calc(1em + 1in + 2px) #f00; | |
| 1048 border: calc(5px + 1em) 0px 1px calc(10 + 20 + 1px); | |
| 1049 margin: 25px calc(50px + (100% / (3 - 1em) - 20%)) calc(10px + 10 * 20) calc(1 00% - 10px); | |
| 1050 }'''; | |
| 1051 | |
| 1052 var stylesheet = parseCss(input, errors: errors); | |
| 1053 expect(stylesheet != null, true); | |
| 1054 expect(errors.isEmpty, true, reason: errors.toString()); | |
| 1055 expect(prettyPrint(stylesheet), generated); | |
| 1024 } | 1056 } |
| 1025 | 1057 |
| 1026 main() { | 1058 main() { |
| 1027 test('Simple Terms', testSimpleTerms); | 1059 test('Simple Terms', testSimpleTerms); |
| 1028 test('Declarations', testDeclarations); | 1060 test('Declarations', testDeclarations); |
| 1029 test('Identifiers', testIdentifiers); | 1061 test('Identifiers', testIdentifiers); |
| 1030 test('Composites', testComposites); | 1062 test('Composites', testComposites); |
| 1031 test('Units', testUnits); | 1063 test('Units', testUnits); |
| 1032 test('Unicode', testUnicode); | 1064 test('Unicode', testUnicode); |
| 1033 test('Newer CSS', testNewerCss); | 1065 test('Newer CSS', testNewerCss); |
| 1034 test('Media Queries', testMediaQueries); | 1066 test('Media Queries', testMediaQueries); |
| 1035 test('Font-Face', testFontFace); | 1067 test('Font-Face', testFontFace); |
| 1036 test('CSS file', testCssFile); | 1068 test('CSS file', testCssFile); |
| 1037 test('Compact Emitter', testCompactEmitter); | 1069 test('Compact Emitter', testCompactEmitter); |
| 1038 test('Selector Negation', testNotSelectors); | 1070 test('Selector Negation', testNotSelectors); |
| 1039 test('IE stuff', testIE); | 1071 test('IE stuff', testIE); |
| 1040 test('IE declaration syntax', testIEDeclaration); | 1072 test('IE declaration syntax', testIEDeclaration); |
| 1041 test('Hanging bugs', testHangs); | 1073 test('Hanging bugs', testHangs); |
| 1042 test('Expression spans', testExpressionSpans, | 1074 test('Expression spans', testExpressionSpans, |
| 1043 skip: 'expression spans are broken' | 1075 skip: 'expression spans are broken' |
| 1044 ' (https://github.com/dart-lang/csslib/issues/15)'); | 1076 ' (https://github.com/dart-lang/csslib/issues/15)'); |
| 1045 test('Declaration span containing calc()', testDeclarationSpanWithCalc, | 1077 test('Declaration span containing calc()', testDeclarationSpanWithCalc); |
|
kevmoo
2015/10/16 17:39:12
make this a group and break the 'testDeclarationSp
terry
2015/10/16 18:28:47
Done.
| |
| 1046 skip: 'calc() declarations are broken' | |
| 1047 ' (https://github.com/dart-lang/csslib/issues/17)'); | |
| 1048 } | 1078 } |
| OLD | NEW |