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

Side by Side Diff: utils/tests/css/expression_tests.dart

Issue 9956037: Simplify tests under utils/tests to follow StandardTestSuite convention. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #import("../../../css/css.dart"); 5 #import("../../css/css.dart");
6 6
7 class ExpressionTest { 7 class ExpressionTest {
8 8
9 static testMain() { 9 static testMain() {
10 initCssWorld(); 10 initCssWorld();
11 11
12 testClass(); 12 testClass();
13 testId(); 13 testId();
14 testElement(); 14 testElement();
15 testNamespace(); 15 testNamespace();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 stylesheet = parser.parse(); 50 stylesheet = parser.parse();
51 Expect.isNotNull(stylesheet); 51 Expect.isNotNull(stylesheet);
52 Expect.equals(stylesheet.topLevels.length, 1); 52 Expect.equals(stylesheet.topLevels.length, 1);
53 53
54 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); 54 Expect.isTrue(stylesheet.topLevels[0] is RuleSet);
55 ruleset = stylesheet.topLevels[0]; 55 ruleset = stylesheet.topLevels[0];
56 Expect.equals(ruleset.selectorGroup.selectors.length, 1); 56 Expect.equals(ruleset.selectorGroup.selectors.length, 1);
57 Expect.equals(ruleset.declarationGroup.declarations.length, 0); 57 Expect.equals(ruleset.declarationGroup.declarations.length, 0);
58 58
59 simpleSeqs = ruleset.selectorGroup.selectors[0].simpleSelectorSequences; 59 simpleSeqs = ruleset.selectorGroup.selectors[0].simpleSelectorSequences;
60 60
61 var idx = 0; 61 var idx = 0;
62 for (final selector in simpleSeqs) { 62 for (final selector in simpleSeqs) {
63 final simpSelector = selector.simpleSelector; 63 final simpSelector = selector.simpleSelector;
64 if (idx == 0) { 64 if (idx == 0) {
65 Expect.isTrue(simpSelector is ClassSelector); 65 Expect.isTrue(simpSelector is ClassSelector);
66 Expect.isTrue(selector.isCombinatorNone()); 66 Expect.isTrue(selector.isCombinatorNone());
67 Expect.equals(simpSelector.name, "foobar"); 67 Expect.equals(simpSelector.name, "foobar");
68 } else if (idx == 1) { 68 } else if (idx == 1) {
69 Expect.isTrue(simpSelector is ClassSelector); 69 Expect.isTrue(simpSelector is ClassSelector);
70 Expect.isTrue(selector.isCombinatorDescendant()); 70 Expect.isTrue(selector.isCombinatorDescendant());
(...skipping 20 matching lines...) Expand all
91 Expect.isNotNull(stylesheet); 91 Expect.isNotNull(stylesheet);
92 Expect.equals(stylesheet.topLevels.length, 1); 92 Expect.equals(stylesheet.topLevels.length, 1);
93 93
94 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); 94 Expect.isTrue(stylesheet.topLevels[0] is RuleSet);
95 RuleSet ruleset = stylesheet.topLevels[0]; 95 RuleSet ruleset = stylesheet.topLevels[0];
96 Expect.equals(ruleset.selectorGroup.selectors.length, 1); 96 Expect.equals(ruleset.selectorGroup.selectors.length, 1);
97 Expect.equals(ruleset.declarationGroup.declarations.length, 0); 97 Expect.equals(ruleset.declarationGroup.declarations.length, 0);
98 98
99 List<SimpleSelectorSequence> simpleSeqs = 99 List<SimpleSelectorSequence> simpleSeqs =
100 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; 100 ruleset.selectorGroup.selectors[0].simpleSelectorSequences;
101 101
102 for (final selector in simpleSeqs) { 102 for (final selector in simpleSeqs) {
103 final simpSelector = selector.simpleSelector; 103 final simpSelector = selector.simpleSelector;
104 Expect.isTrue(simpSelector is IdSelector); 104 Expect.isTrue(simpSelector is IdSelector);
105 Expect.isTrue(selector.isCombinatorNone()); 105 Expect.isTrue(selector.isCombinatorNone());
106 Expect.equals(simpSelector.name, "elemId"); 106 Expect.equals(simpSelector.name, "elemId");
107 } 107 }
108 } 108 }
109 109
110 static void testElement() { 110 static void testElement() {
111 Parser parser = new Parser(new SourceFile( 111 Parser parser = new Parser(new SourceFile(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 Expect.isTrue(simpSelector is ElementSelector); 153 Expect.isTrue(simpSelector is ElementSelector);
154 Expect.isTrue(selector.isCombinatorDescendant()); 154 Expect.isTrue(selector.isCombinatorDescendant());
155 Expect.equals(simpSelector.name, "div"); 155 Expect.equals(simpSelector.name, "div");
156 } else if (idx == 2) { 156 } else if (idx == 2) {
157 Expect.isTrue(simpSelector is ElementSelector); 157 Expect.isTrue(simpSelector is ElementSelector);
158 Expect.isTrue(selector.isCombinatorDescendant()); 158 Expect.isTrue(selector.isCombinatorDescendant());
159 Expect.equals(simpSelector.name, "span"); 159 Expect.equals(simpSelector.name, "span");
160 } else { 160 } else {
161 Expect.fail("unexpected expression"); 161 Expect.fail("unexpected expression");
162 } 162 }
163 163
164 idx++; 164 idx++;
165 } 165 }
166 Expect.equals(simpleSeqs.length, idx); 166 Expect.equals(simpleSeqs.length, idx);
167 } 167 }
168 168
169 static void testNamespace() { 169 static void testNamespace() {
170 Parser parser = new Parser(new SourceFile( 170 Parser parser = new Parser(new SourceFile(
171 SourceFile.IN_MEMORY_FILE, "ns1|div {}")); 171 SourceFile.IN_MEMORY_FILE, "ns1|div {}"));
172 Stylesheet stylesheet = parser.parse(); 172 Stylesheet stylesheet = parser.parse();
173 Expect.isNotNull(stylesheet); 173 Expect.isNotNull(stylesheet);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 Expect.isTrue(elementSelector is ElementSelector); 230 Expect.isTrue(elementSelector is ElementSelector);
231 Expect.isFalse(elementSelector.isWildcard()); 231 Expect.isFalse(elementSelector.isWildcard());
232 Expect.equals(elementSelector.name, "span"); 232 Expect.equals(elementSelector.name, "span");
233 } else if (idx == 3) { 233 } else if (idx == 3) {
234 Expect.isTrue(simpSelector is ClassSelector); 234 Expect.isTrue(simpSelector is ClassSelector);
235 Expect.isTrue(selector.isCombinatorDescendant()); 235 Expect.isTrue(selector.isCombinatorDescendant());
236 Expect.equals(simpSelector.name, "foobar"); 236 Expect.equals(simpSelector.name, "foobar");
237 } else { 237 } else {
238 Expect.fail("unexpected expression"); 238 Expect.fail("unexpected expression");
239 } 239 }
240 240
241 idx++; 241 idx++;
242 } 242 }
243 243
244 Expect.equals(simpleSeqs.length, idx); 244 Expect.equals(simpleSeqs.length, idx);
245 } 245 }
246 246
247 static void testSelectorGroups() { 247 static void testSelectorGroups() {
248 Parser parser = new Parser(new SourceFile( 248 Parser parser = new Parser(new SourceFile(
249 SourceFile.IN_MEMORY_FILE, 249 SourceFile.IN_MEMORY_FILE,
250 "div, .foobar ,#elemId, .xyzzy .test, ns1|div div #elemId .foobar {}")); 250 "div, .foobar ,#elemId, .xyzzy .test, ns1|div div #elemId .foobar {}"));
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 stylesheet = parser.parse(); 409 stylesheet = parser.parse();
410 Expect.isNotNull(stylesheet); 410 Expect.isNotNull(stylesheet);
411 Expect.equals(stylesheet.topLevels.length, 1); 411 Expect.equals(stylesheet.topLevels.length, 1);
412 412
413 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); 413 Expect.isTrue(stylesheet.topLevels[0] is RuleSet);
414 ruleset = stylesheet.topLevels[0]; 414 ruleset = stylesheet.topLevels[0];
415 Expect.equals(ruleset.selectorGroup.selectors.length, 1); 415 Expect.equals(ruleset.selectorGroup.selectors.length, 1);
416 Expect.equals(ruleset.declarationGroup.declarations.length, 0); 416 Expect.equals(ruleset.declarationGroup.declarations.length, 0);
417 417
418 simpleSeqs = ruleset.selectorGroup.selectors[0].simpleSelectorSequences; 418 simpleSeqs = ruleset.selectorGroup.selectors[0].simpleSelectorSequences;
419 419
420 Expect.equals(simpleSeqs.length, 2); 420 Expect.equals(simpleSeqs.length, 2);
421 var idx = 0; 421 var idx = 0;
422 for (final selector in simpleSeqs) { 422 for (final selector in simpleSeqs) {
423 final simpSelector = selector.simpleSelector; 423 final simpSelector = selector.simpleSelector;
424 if (idx == 0) { 424 if (idx == 0) {
425 Expect.isTrue(simpSelector is ElementSelector); 425 Expect.isTrue(simpSelector is ElementSelector);
426 Expect.isTrue(selector.isCombinatorNone()); 426 Expect.isTrue(selector.isCombinatorNone());
427 Expect.isTrue(simpSelector.isWildcard()); 427 Expect.isTrue(simpSelector.isWildcard());
428 Expect.equals(simpSelector.name, "*"); 428 Expect.equals(simpSelector.name, "*");
429 } else if (idx == 1) { 429 } else if (idx == 1) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 479
480 stylesheet = parser.parse(); 480 stylesheet = parser.parse();
481 Expect.isNotNull(stylesheet); 481 Expect.isNotNull(stylesheet);
482 482
483 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); 483 Expect.isTrue(stylesheet.topLevels[0] is RuleSet);
484 ruleset = stylesheet.topLevels[0]; 484 ruleset = stylesheet.topLevels[0];
485 Expect.equals(ruleset.selectorGroup.selectors.length, 1); 485 Expect.equals(ruleset.selectorGroup.selectors.length, 1);
486 Expect.equals(ruleset.declarationGroup.declarations.length, 0); 486 Expect.equals(ruleset.declarationGroup.declarations.length, 0);
487 487
488 simpleSeqs = ruleset.selectorGroup.selectors[0].simpleSelectorSequences; 488 simpleSeqs = ruleset.selectorGroup.selectors[0].simpleSelectorSequences;
489 489
490 Expect.equals(simpleSeqs.length, 2); 490 Expect.equals(simpleSeqs.length, 2);
491 idx = 0; 491 idx = 0;
492 for (final selector in simpleSeqs) { 492 for (final selector in simpleSeqs) {
493 final simpSelector = selector.simpleSelector; 493 final simpSelector = selector.simpleSelector;
494 if (idx == 0) { 494 if (idx == 0) {
495 Expect.isTrue(simpSelector is NamespaceSelector); 495 Expect.isTrue(simpSelector is NamespaceSelector);
496 Expect.isTrue(selector.isCombinatorNone()); 496 Expect.isTrue(selector.isCombinatorNone());
497 Expect.isTrue(simpSelector.isNamespaceWildcard()); 497 Expect.isTrue(simpSelector.isNamespaceWildcard());
498 Expect.equals("*", simpSelector.namespace); 498 Expect.equals("*", simpSelector.namespace);
499 ElementSelector elementSelector = simpSelector.nameAsSimpleSelector; 499 ElementSelector elementSelector = simpSelector.nameAsSimpleSelector;
(...skipping 23 matching lines...) Expand all
523 static void testNegation() { 523 static void testNegation() {
524 // TODO(terry): Implement 524 // TODO(terry): Implement
525 } 525 }
526 526
527 } 527 }
528 528
529 529
530 main() { 530 main() {
531 ExpressionTest.testMain(); 531 ExpressionTest.testMain();
532 } 532 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698