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

Unified Diff: test/declaration_test.dart

Issue 1407333002: Added beginning support for calc however, the expression is not fully parsed into the AST. (Closed) Base URL: https://github.com/dart-lang/csslib.git@master
Patch Set: Created 5 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« lib/src/tree.dart ('K') | « lib/visitor.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/declaration_test.dart
diff --git a/test/declaration_test.dart b/test/declaration_test.dart
index 702921d47d46cac1dc04dced4b88d5bff49d84a3..aa13ccde121b761292ee7ae9b34fc595f56c8ae1 100644
--- a/test/declaration_test.dart
+++ b/test/declaration_test.dart
@@ -1016,11 +1016,43 @@ void testExpressionSpans() {
}
void testDeclarationSpanWithCalc() {
- final input = r'''.foo { height: calc(100% - 55px); }''';
- var stylesheet = parseCss(input);
- var decl = stylesheet.topLevels.single.declarationGroup.declarations.single;
- // This fails, with span being "height: calc("
- expect(decl.span.text, 'height: calc(100% - 55px);');
+ final input1 = r'''.foo { height: calc(100% - 55px); }''';
+ var stylesheet1 = parseCss(input1);
+ var decl1 = stylesheet1.topLevels.single.declarationGroup.declarations.single;
+ expect(decl1.span.text, 'height: calc(100% - 55px)');
+
+ final input2 = r'''.foo { left: calc((100%/3 - 2) * 1em - 2 * 1px); }''';
+ var stylesheet2 = parseCss(input2);
+ var decl2 = stylesheet2.topLevels.single.declarationGroup.declarations.single;
+ expect(decl2.span.text, 'left: calc((100%/3 - 2) * 1em - 2 * 1px)');
+
+ final input3 = r'''.foo { margin: calc(1rem - 2px) calc(1rem - 1px); }''';
+ var stylesheet3 = parseCss(input3);
+ var decl3 = stylesheet3.topLevels.single.declarationGroup.declarations.single;
+ expect(decl3.span.text, 'margin: calc(1rem - 2px) calc(1rem - 1px)');
+
+ var errors = [];
+ final String input = r'''
+.foo {
+ width: calc(1em + 5 * 2em);
+ height: calc(1px + 2%) !important;
+ border: 5px calc(1pt + 2cm) 6px calc(1em + 1in + 2px) red;
+ border: calc(5px + 1em) 0px 1px calc(10 + 20 + 1px);
+ margin: 25px calc(50px + (100% / (3 - 1em) - 20%)) calc(10px + 10 * 20) calc(100% - 10px);
+}''';
+ final String generated = r'''
+.foo {
+ width: calc(1em + 5 * 2em);
+ height: calc(1px + 2%) !important;
+ border: 5px calc(1pt + 2cm) 6px calc(1em + 1in + 2px) #f00;
+ border: calc(5px + 1em) 0px 1px calc(10 + 20 + 1px);
+ margin: 25px calc(50px + (100% / (3 - 1em) - 20%)) calc(10px + 10 * 20) calc(100% - 10px);
+}''';
+
+ var stylesheet = parseCss(input, errors: errors);
+ expect(stylesheet != null, true);
+ expect(errors.isEmpty, true, reason: errors.toString());
+ expect(prettyPrint(stylesheet), generated);
}
main() {
@@ -1042,7 +1074,5 @@ main() {
test('Expression spans', testExpressionSpans,
skip: 'expression spans are broken'
' (https://github.com/dart-lang/csslib/issues/15)');
- test('Declaration span containing calc()', testDeclarationSpanWithCalc,
- skip: 'calc() declarations are broken'
- ' (https://github.com/dart-lang/csslib/issues/17)');
+ 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.
}
« lib/src/tree.dart ('K') | « lib/visitor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698