OLD | NEW |
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 #import('../../../../frog/lang.dart', prefix:'lang'); | |
7 | 6 |
8 class ExpressionTest { | 7 class ExpressionTest { |
9 | 8 |
10 static testMain() { | 9 static testMain() { |
11 initCssWorld(); | 10 initCssWorld(); |
12 | 11 |
13 testClass(); | 12 testClass(); |
14 testId(); | 13 testId(); |
15 testElement(); | 14 testElement(); |
16 testNamespace(); | 15 testNamespace(); |
17 testSelectorGroups(); | 16 testSelectorGroups(); |
18 testCombinator(); | 17 testCombinator(); |
19 testWildcard(); | 18 testWildcard(); |
20 testPseudo(); | 19 testPseudo(); |
21 testAttribute(); | 20 testAttribute(); |
22 testNegation(); | 21 testNegation(); |
23 } | 22 } |
24 | 23 |
25 static void testClass() { | 24 static void testClass() { |
26 Parser parser = new Parser(new lang.SourceFile( | 25 Parser parser = new Parser(new SourceFile( |
27 lang.SourceFile.IN_MEMORY_FILE, ".foobar {}")); | 26 SourceFile.IN_MEMORY_FILE, ".foobar {}")); |
28 | 27 |
29 Stylesheet stylesheet = parser.parse(); | 28 Stylesheet stylesheet = parser.parse(); |
30 Expect.isNotNull(stylesheet); | 29 Expect.isNotNull(stylesheet); |
31 Expect.equals(stylesheet.topLevels.length, 1); | 30 Expect.equals(stylesheet.topLevels.length, 1); |
32 | 31 |
33 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 32 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
34 RuleSet ruleset = stylesheet.topLevels[0]; | 33 RuleSet ruleset = stylesheet.topLevels[0]; |
35 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 34 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
36 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 35 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
37 | 36 |
38 List<SimpleSelectorSequence> simpleSeqs = | 37 List<SimpleSelectorSequence> simpleSeqs = |
39 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; | 38 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; |
40 Expect.equals(simpleSeqs.length, 1); | 39 Expect.equals(simpleSeqs.length, 1); |
41 for (final selector in simpleSeqs) { | 40 for (final selector in simpleSeqs) { |
42 final simpSelector = selector.simpleSelector; | 41 final simpSelector = selector.simpleSelector; |
43 Expect.isTrue(simpSelector is ClassSelector); | 42 Expect.isTrue(simpSelector is ClassSelector); |
44 Expect.isTrue(selector.isCombinatorNone()); | 43 Expect.isTrue(selector.isCombinatorNone()); |
45 Expect.equals(simpSelector.name, "foobar"); | 44 Expect.equals(simpSelector.name, "foobar"); |
46 } | 45 } |
47 | 46 |
48 parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, | 47 parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE, |
49 ".foobar .bar .no-story {}")); | 48 ".foobar .bar .no-story {}")); |
50 | 49 |
51 stylesheet = parser.parse(); | 50 stylesheet = parser.parse(); |
52 Expect.isNotNull(stylesheet); | 51 Expect.isNotNull(stylesheet); |
53 Expect.equals(stylesheet.topLevels.length, 1); | 52 Expect.equals(stylesheet.topLevels.length, 1); |
54 | 53 |
55 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 54 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
56 ruleset = stylesheet.topLevels[0]; | 55 ruleset = stylesheet.topLevels[0]; |
57 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 56 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
58 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 57 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
(...skipping 19 matching lines...) Expand all Loading... |
78 Expect.fail("unexpected expression"); | 77 Expect.fail("unexpected expression"); |
79 } | 78 } |
80 | 79 |
81 idx++; | 80 idx++; |
82 } | 81 } |
83 | 82 |
84 Expect.equals(simpleSeqs.length, idx); | 83 Expect.equals(simpleSeqs.length, idx); |
85 } | 84 } |
86 | 85 |
87 static void testId() { | 86 static void testId() { |
88 Parser parser = new Parser(new lang.SourceFile( | 87 Parser parser = new Parser(new SourceFile( |
89 lang.SourceFile.IN_MEMORY_FILE, "#elemId {}")); | 88 SourceFile.IN_MEMORY_FILE, "#elemId {}")); |
90 | 89 |
91 Stylesheet stylesheet = parser.parse(); | 90 Stylesheet stylesheet = parser.parse(); |
92 Expect.isNotNull(stylesheet); | 91 Expect.isNotNull(stylesheet); |
93 Expect.equals(stylesheet.topLevels.length, 1); | 92 Expect.equals(stylesheet.topLevels.length, 1); |
94 | 93 |
95 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 94 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
96 RuleSet ruleset = stylesheet.topLevels[0]; | 95 RuleSet ruleset = stylesheet.topLevels[0]; |
97 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 96 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
98 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 97 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
99 | 98 |
100 List<SimpleSelectorSequence> simpleSeqs = | 99 List<SimpleSelectorSequence> simpleSeqs = |
101 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; | 100 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; |
102 | 101 |
103 for (final selector in simpleSeqs) { | 102 for (final selector in simpleSeqs) { |
104 final simpSelector = selector.simpleSelector; | 103 final simpSelector = selector.simpleSelector; |
105 Expect.isTrue(simpSelector is IdSelector); | 104 Expect.isTrue(simpSelector is IdSelector); |
106 Expect.isTrue(selector.isCombinatorNone()); | 105 Expect.isTrue(selector.isCombinatorNone()); |
107 Expect.equals(simpSelector.name, "elemId"); | 106 Expect.equals(simpSelector.name, "elemId"); |
108 } | 107 } |
109 } | 108 } |
110 | 109 |
111 static void testElement() { | 110 static void testElement() { |
112 Parser parser = new Parser(new lang.SourceFile( | 111 Parser parser = new Parser(new SourceFile( |
113 lang.SourceFile.IN_MEMORY_FILE, "div {}")); | 112 SourceFile.IN_MEMORY_FILE, "div {}")); |
114 Stylesheet stylesheet = parser.parse(); | 113 Stylesheet stylesheet = parser.parse(); |
115 Expect.isNotNull(stylesheet); | 114 Expect.isNotNull(stylesheet); |
116 Expect.equals(stylesheet.topLevels.length, 1); | 115 Expect.equals(stylesheet.topLevels.length, 1); |
117 | 116 |
118 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 117 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
119 RuleSet ruleset = stylesheet.topLevels[0]; | 118 RuleSet ruleset = stylesheet.topLevels[0]; |
120 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 119 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
121 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 120 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
122 | 121 |
123 List<SimpleSelectorSequence> simpleSeqs = | 122 List<SimpleSelectorSequence> simpleSeqs = |
124 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; | 123 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; |
125 | 124 |
126 for (final selector in simpleSeqs) { | 125 for (final selector in simpleSeqs) { |
127 final simpSelector = selector.simpleSelector; | 126 final simpSelector = selector.simpleSelector; |
128 Expect.isTrue(simpSelector is ElementSelector); | 127 Expect.isTrue(simpSelector is ElementSelector); |
129 Expect.isTrue(selector.isCombinatorNone()); | 128 Expect.isTrue(selector.isCombinatorNone()); |
130 Expect.equals(simpSelector.name, "div"); | 129 Expect.equals(simpSelector.name, "div"); |
131 } | 130 } |
132 | 131 |
133 parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, | 132 parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE, |
134 "div div span {}")); | 133 "div div span {}")); |
135 stylesheet = parser.parse(); | 134 stylesheet = parser.parse(); |
136 Expect.isNotNull(stylesheet); | 135 Expect.isNotNull(stylesheet); |
137 Expect.equals(stylesheet.topLevels.length, 1); | 136 Expect.equals(stylesheet.topLevels.length, 1); |
138 | 137 |
139 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 138 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
140 ruleset = stylesheet.topLevels[0]; | 139 ruleset = stylesheet.topLevels[0]; |
141 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 140 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
142 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 141 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
143 | 142 |
(...skipping 17 matching lines...) Expand all Loading... |
161 } else { | 160 } else { |
162 Expect.fail("unexpected expression"); | 161 Expect.fail("unexpected expression"); |
163 } | 162 } |
164 | 163 |
165 idx++; | 164 idx++; |
166 } | 165 } |
167 Expect.equals(simpleSeqs.length, idx); | 166 Expect.equals(simpleSeqs.length, idx); |
168 } | 167 } |
169 | 168 |
170 static void testNamespace() { | 169 static void testNamespace() { |
171 Parser parser = new Parser(new lang.SourceFile( | 170 Parser parser = new Parser(new SourceFile( |
172 lang.SourceFile.IN_MEMORY_FILE, "ns1|div {}")); | 171 SourceFile.IN_MEMORY_FILE, "ns1|div {}")); |
173 Stylesheet stylesheet = parser.parse(); | 172 Stylesheet stylesheet = parser.parse(); |
174 Expect.isNotNull(stylesheet); | 173 Expect.isNotNull(stylesheet); |
175 Expect.equals(stylesheet.topLevels.length, 1); | 174 Expect.equals(stylesheet.topLevels.length, 1); |
176 | 175 |
177 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 176 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
178 RuleSet ruleset = stylesheet.topLevels[0]; | 177 RuleSet ruleset = stylesheet.topLevels[0]; |
179 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 178 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
180 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 179 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
181 | 180 |
182 List<SimpleSelectorSequence> simpleSeqs = | 181 List<SimpleSelectorSequence> simpleSeqs = |
183 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; | 182 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; |
184 | 183 |
185 for (final selector in simpleSeqs) { | 184 for (final selector in simpleSeqs) { |
186 final simpSelector = selector.simpleSelector; | 185 final simpSelector = selector.simpleSelector; |
187 Expect.isTrue(simpSelector is NamespaceSelector); | 186 Expect.isTrue(simpSelector is NamespaceSelector); |
188 Expect.isTrue(selector.isCombinatorNone()); | 187 Expect.isTrue(selector.isCombinatorNone()); |
189 Expect.isFalse(simpSelector.isNamespaceWildcard()); | 188 Expect.isFalse(simpSelector.isNamespaceWildcard()); |
190 Expect.equals(simpSelector.namespace, "ns1"); | 189 Expect.equals(simpSelector.namespace, "ns1"); |
191 ElementSelector elementSelector = simpSelector.nameAsSimpleSelector; | 190 ElementSelector elementSelector = simpSelector.nameAsSimpleSelector; |
192 Expect.isTrue(elementSelector is ElementSelector); | 191 Expect.isTrue(elementSelector is ElementSelector); |
193 Expect.isFalse(elementSelector.isWildcard()); | 192 Expect.isFalse(elementSelector.isWildcard()); |
194 Expect.equals(elementSelector.name, "div"); | 193 Expect.equals(elementSelector.name, "div"); |
195 } | 194 } |
196 | 195 |
197 parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, | 196 parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE, |
198 "ns1|div div ns2|span .foobar {}")); | 197 "ns1|div div ns2|span .foobar {}")); |
199 stylesheet = parser.parse(); | 198 stylesheet = parser.parse(); |
200 Expect.isNotNull(stylesheet); | 199 Expect.isNotNull(stylesheet); |
201 | 200 |
202 Expect.equals(stylesheet.topLevels.length, 1); | 201 Expect.equals(stylesheet.topLevels.length, 1); |
203 | 202 |
204 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 203 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
205 ruleset = stylesheet.topLevels[0]; | 204 ruleset = stylesheet.topLevels[0]; |
206 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 205 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
207 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 206 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 Expect.fail("unexpected expression"); | 238 Expect.fail("unexpected expression"); |
240 } | 239 } |
241 | 240 |
242 idx++; | 241 idx++; |
243 } | 242 } |
244 | 243 |
245 Expect.equals(simpleSeqs.length, idx); | 244 Expect.equals(simpleSeqs.length, idx); |
246 } | 245 } |
247 | 246 |
248 static void testSelectorGroups() { | 247 static void testSelectorGroups() { |
249 Parser parser = new Parser(new lang.SourceFile( | 248 Parser parser = new Parser(new SourceFile( |
250 lang.SourceFile.IN_MEMORY_FILE, | 249 SourceFile.IN_MEMORY_FILE, |
251 "div, .foobar ,#elemId, .xyzzy .test, ns1|div div #elemId .foobar {}")); | 250 "div, .foobar ,#elemId, .xyzzy .test, ns1|div div #elemId .foobar {}")); |
252 Stylesheet stylesheet = parser.parse(); | 251 Stylesheet stylesheet = parser.parse(); |
253 Expect.isNotNull(stylesheet); | 252 Expect.isNotNull(stylesheet); |
254 | 253 |
255 Expect.equals(stylesheet.topLevels.length, 1); | 254 Expect.equals(stylesheet.topLevels.length, 1); |
256 | 255 |
257 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 256 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
258 RuleSet ruleset = stylesheet.topLevels[0]; | 257 RuleSet ruleset = stylesheet.topLevels[0]; |
259 Expect.equals(ruleset.selectorGroup.selectors.length, 5); | 258 Expect.equals(ruleset.selectorGroup.selectors.length, 5); |
260 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 259 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 320 } |
322 break; | 321 break; |
323 } | 322 } |
324 idx++; | 323 idx++; |
325 } | 324 } |
326 groupIdx++; | 325 groupIdx++; |
327 } | 326 } |
328 } | 327 } |
329 | 328 |
330 static void testCombinator() { | 329 static void testCombinator() { |
331 Parser parser = new Parser(new lang.SourceFile( | 330 Parser parser = new Parser(new SourceFile( |
332 lang.SourceFile.IN_MEMORY_FILE, | 331 SourceFile.IN_MEMORY_FILE, |
333 ".foobar > .bar + .no-story ~ myNs|div #elemId {}")); | 332 ".foobar > .bar + .no-story ~ myNs|div #elemId {}")); |
334 | 333 |
335 Stylesheet stylesheet = parser.parse(); | 334 Stylesheet stylesheet = parser.parse(); |
336 Expect.isNotNull(stylesheet); | 335 Expect.isNotNull(stylesheet); |
337 Expect.equals(stylesheet.topLevels.length, 1); | 336 Expect.equals(stylesheet.topLevels.length, 1); |
338 | 337 |
339 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 338 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
340 RuleSet ruleset = stylesheet.topLevels[0]; | 339 RuleSet ruleset = stylesheet.topLevels[0]; |
341 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 340 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
342 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 341 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 Expect.equals(simpSelector.name, "elemId"); | 373 Expect.equals(simpSelector.name, "elemId"); |
375 } else { | 374 } else { |
376 Expect.fail("unexpected expression"); | 375 Expect.fail("unexpected expression"); |
377 } | 376 } |
378 | 377 |
379 idx++; | 378 idx++; |
380 } | 379 } |
381 } | 380 } |
382 | 381 |
383 static void testWildcard() { | 382 static void testWildcard() { |
384 Parser parser = new Parser(new lang.SourceFile( | 383 Parser parser = new Parser(new SourceFile( |
385 lang.SourceFile.IN_MEMORY_FILE, "* {}")); | 384 SourceFile.IN_MEMORY_FILE, "* {}")); |
386 | 385 |
387 Stylesheet stylesheet = parser.parse(); | 386 Stylesheet stylesheet = parser.parse(); |
388 Expect.isNotNull(stylesheet); | 387 Expect.isNotNull(stylesheet); |
389 Expect.equals(stylesheet.topLevels.length, 1); | 388 Expect.equals(stylesheet.topLevels.length, 1); |
390 | 389 |
391 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 390 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
392 RuleSet ruleset = stylesheet.topLevels[0]; | 391 RuleSet ruleset = stylesheet.topLevels[0]; |
393 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 392 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
394 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 393 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
395 | 394 |
396 List<SimpleSelectorSequence> simpleSeqs = | 395 List<SimpleSelectorSequence> simpleSeqs = |
397 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; | 396 ruleset.selectorGroup.selectors[0].simpleSelectorSequences; |
398 | 397 |
399 for (final selector in simpleSeqs) { | 398 for (final selector in simpleSeqs) { |
400 final simpSelector = selector.simpleSelector; | 399 final simpSelector = selector.simpleSelector; |
401 Expect.isTrue(simpSelector is ElementSelector); | 400 Expect.isTrue(simpSelector is ElementSelector); |
402 Expect.isTrue(selector.isCombinatorNone()); | 401 Expect.isTrue(selector.isCombinatorNone()); |
403 Expect.isTrue(simpSelector.isWildcard()); | 402 Expect.isTrue(simpSelector.isWildcard()); |
404 Expect.equals(simpSelector.name, "*"); | 403 Expect.equals(simpSelector.name, "*"); |
405 } | 404 } |
406 | 405 |
407 parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, | 406 parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE, |
408 "*.foobar {}")); | 407 "*.foobar {}")); |
409 | 408 |
410 stylesheet = parser.parse(); | 409 stylesheet = parser.parse(); |
411 Expect.isNotNull(stylesheet); | 410 Expect.isNotNull(stylesheet); |
412 Expect.equals(stylesheet.topLevels.length, 1); | 411 Expect.equals(stylesheet.topLevels.length, 1); |
413 | 412 |
414 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 413 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
415 ruleset = stylesheet.topLevels[0]; | 414 ruleset = stylesheet.topLevels[0]; |
416 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 415 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
417 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 416 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
(...skipping 13 matching lines...) Expand all Loading... |
431 Expect.isTrue(simpSelector is ClassSelector); | 430 Expect.isTrue(simpSelector is ClassSelector); |
432 Expect.isTrue(selector.isCombinatorNone()); | 431 Expect.isTrue(selector.isCombinatorNone()); |
433 Expect.equals(simpSelector.name, "foobar"); | 432 Expect.equals(simpSelector.name, "foobar"); |
434 } else { | 433 } else { |
435 Expect.fail("unexpected expression"); | 434 Expect.fail("unexpected expression"); |
436 } | 435 } |
437 | 436 |
438 idx++; | 437 idx++; |
439 } | 438 } |
440 | 439 |
441 parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, | 440 parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE, |
442 "myNs|*.foobar {}")); | 441 "myNs|*.foobar {}")); |
443 | 442 |
444 stylesheet = parser.parse(); | 443 stylesheet = parser.parse(); |
445 Expect.isNotNull(stylesheet); | 444 Expect.isNotNull(stylesheet); |
446 Expect.equals(stylesheet.topLevels.length, 1); | 445 Expect.equals(stylesheet.topLevels.length, 1); |
447 | 446 |
448 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 447 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
449 ruleset = stylesheet.topLevels[0]; | 448 ruleset = stylesheet.topLevels[0]; |
450 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 449 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
451 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 450 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
(...skipping 16 matching lines...) Expand all Loading... |
468 Expect.isTrue(simpSelector is ClassSelector); | 467 Expect.isTrue(simpSelector is ClassSelector); |
469 Expect.isTrue(selector.isCombinatorNone()); | 468 Expect.isTrue(selector.isCombinatorNone()); |
470 Expect.equals("foobar", simpSelector.name); | 469 Expect.equals("foobar", simpSelector.name); |
471 } else { | 470 } else { |
472 Expect.fail("unexpected expression"); | 471 Expect.fail("unexpected expression"); |
473 } | 472 } |
474 | 473 |
475 idx++; | 474 idx++; |
476 } | 475 } |
477 | 476 |
478 parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, | 477 parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE, |
479 "*|*.foobar {}")); | 478 "*|*.foobar {}")); |
480 | 479 |
481 stylesheet = parser.parse(); | 480 stylesheet = parser.parse(); |
482 Expect.isNotNull(stylesheet); | 481 Expect.isNotNull(stylesheet); |
483 | 482 |
484 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); | 483 Expect.isTrue(stylesheet.topLevels[0] is RuleSet); |
485 ruleset = stylesheet.topLevels[0]; | 484 ruleset = stylesheet.topLevels[0]; |
486 Expect.equals(ruleset.selectorGroup.selectors.length, 1); | 485 Expect.equals(ruleset.selectorGroup.selectors.length, 1); |
487 Expect.equals(ruleset.declarationGroup.declarations.length, 0); | 486 Expect.equals(ruleset.declarationGroup.declarations.length, 0); |
488 | 487 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 static void testNegation() { | 523 static void testNegation() { |
525 // TODO(terry): Implement | 524 // TODO(terry): Implement |
526 } | 525 } |
527 | 526 |
528 } | 527 } |
529 | 528 |
530 | 529 |
531 main() { | 530 main() { |
532 ExpressionTest.testMain(); | 531 ExpressionTest.testMain(); |
533 } | 532 } |
OLD | NEW |