Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: packages/csslib/test/declaration_test.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packages/csslib/pubspec.yaml ('k') | packages/dart_style/._.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 expect(errors.length, 1, reason: errors.toString()); 998 expect(errors.length, 1, reason: errors.toString());
999 999
1000 errorMessage = errors[0]; 1000 errorMessage = errors[0];
1001 expect(errorMessage.message, contains('unexpected end of file')); 1001 expect(errorMessage.message, contains('unexpected end of file'));
1002 expect(errorMessage.span, isNotNull); 1002 expect(errorMessage.span, isNotNull);
1003 expect(errorMessage.span.start.line, 7); 1003 expect(errorMessage.span.start.line, 7);
1004 expect(errorMessage.span.start.column, 0); 1004 expect(errorMessage.span.start.column, 0);
1005 expect(errorMessage.span.text.trim(), ''); 1005 expect(errorMessage.span.text.trim(), '');
1006 } 1006 }
1007 1007
1008 void testExpressionSpans() {
1009 final input = r'''.foo { width: 50px; }''';
1010 var stylesheet = parseCss(input);
1011 var decl = stylesheet.topLevels.single.declarationGroup.declarations.single;
1012 // This passes
1013 expect(decl.span.text, 'width: 50px');
1014 // This currently fails
1015 expect(decl.expression.span.text, '50px');
1016 }
1017
1018 void simpleCalc() {
1019 final input = r'''.foo { height: calc(100% - 55px); }''';
1020 var stylesheet = parseCss(input);
1021 var decl = stylesheet.topLevels.single.declarationGroup.declarations.single;
1022 expect(decl.span.text, 'height: calc(100% - 55px)');
1023 }
1024
1025 void complexCalc() {
1026 final input = r'''.foo { left: calc((100%/3 - 2) * 1em - 2 * 1px); }''';
1027 var stylesheet = parseCss(input);
1028 var decl = stylesheet.topLevels.single.declarationGroup.declarations.single;
1029 expect(decl.span.text, 'left: calc((100%/3 - 2) * 1em - 2 * 1px)');
1030 }
1031
1032 void twoCalcs() {
1033 final input = r'''.foo { margin: calc(1rem - 2px) calc(1rem - 1px); }''';
1034 var stylesheet = parseCss(input);
1035 var decl = stylesheet.topLevels.single.declarationGroup.declarations.single;
1036 expect(decl.span.text, 'margin: calc(1rem - 2px) calc(1rem - 1px)');
1037 }
1038
1039 void selectorWithCalcs() {
1040 var errors = [];
1041 final String input = r'''
1042 .foo {
1043 width: calc(1em + 5 * 2em);
1044 height: calc(1px + 2%) !important;
1045 border: 5px calc(1pt + 2cm) 6px calc(1em + 1in + 2px) red;
1046 border: calc(5px + 1em) 0px 1px calc(10 + 20 + 1px);
1047 margin: 25px calc(50px + (100% / (3 - 1em) - 20%)) calc(10px + 10 * 20) calc(1 00% - 10px);
1048 }''';
1049 final String generated = r'''
1050 .foo {
1051 width: calc(1em + 5 * 2em);
1052 height: calc(1px + 2%) !important;
1053 border: 5px calc(1pt + 2cm) 6px calc(1em + 1in + 2px) #f00;
1054 border: calc(5px + 1em) 0px 1px calc(10 + 20 + 1px);
1055 margin: 25px calc(50px + (100% / (3 - 1em) - 20%)) calc(10px + 10 * 20) calc(1 00% - 10px);
1056 }''';
1057
1058 var stylesheet = parseCss(input, errors: errors);
1059 expect(stylesheet != null, true);
1060 expect(errors.isEmpty, true, reason: errors.toString());
1061 expect(prettyPrint(stylesheet), generated);
1062 }
1063
1008 main() { 1064 main() {
1009 test('Simple Terms', testSimpleTerms); 1065 test('Simple Terms', testSimpleTerms);
1010 test('Declarations', testDeclarations); 1066 test('Declarations', testDeclarations);
1011 test('Identifiers', testIdentifiers); 1067 test('Identifiers', testIdentifiers);
1012 test('Composites', testComposites); 1068 test('Composites', testComposites);
1013 test('Units', testUnits); 1069 test('Units', testUnits);
1014 test('Unicode', testUnicode); 1070 test('Unicode', testUnicode);
1015 test('Newer CSS', testNewerCss); 1071 test('Newer CSS', testNewerCss);
1016 test('Media Queries', testMediaQueries); 1072 test('Media Queries', testMediaQueries);
1017 test('Font-Face', testFontFace); 1073 test('Font-Face', testFontFace);
1018 test('CSS file', testCssFile); 1074 test('CSS file', testCssFile);
1019 test('Compact Emitter', testCompactEmitter); 1075 test('Compact Emitter', testCompactEmitter);
1020 test('Selector Negation', testNotSelectors); 1076 test('Selector Negation', testNotSelectors);
1021 test('IE stuff', testIE); 1077 test('IE stuff', testIE);
1022 test('IE declaration syntax', testIEDeclaration); 1078 test('IE declaration syntax', testIEDeclaration);
1023 test('Hanging bugs', testHangs); 1079 test('Hanging bugs', testHangs);
1080 test('Expression spans', testExpressionSpans,
1081 skip: 'expression spans are broken'
1082 ' (https://github.com/dart-lang/csslib/issues/15)');
1083 group('calc function', () {
1084 test('simple calc', simpleCalc);
1085 test('single complex', complexCalc);
1086 test('two calc terms for same declaration', twoCalcs);
1087 test('selector with many calc declarations', selectorWithCalcs);
1088 });
1024 } 1089 }
1090
OLDNEW
« no previous file with comments | « packages/csslib/pubspec.yaml ('k') | packages/dart_style/._.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698