OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 nested_test; | 5 library nested_test; |
6 | 6 |
7 import 'package:unittest/unittest.dart'; | 7 import 'package:test/test.dart'; |
| 8 |
8 import 'testing.dart'; | 9 import 'testing.dart'; |
9 | 10 |
10 compileAndValidate(String input, String generated) { | 11 compileAndValidate(String input, String generated) { |
11 var errors = []; | 12 var errors = []; |
12 var stylesheet = compileCss(input, errors: errors, opts: simpleOptions); | 13 var stylesheet = compileCss(input, errors: errors, opts: simpleOptions); |
13 expect(stylesheet != null, true); | 14 expect(stylesheet != null, true); |
14 expect(errors.isEmpty, true, reason: errors.toString()); | 15 expect(errors.isEmpty, true, reason: errors.toString()); |
15 expect(prettyPrint(stylesheet), generated); | 16 expect(prettyPrint(stylesheet), generated); |
16 } | 17 } |
17 | 18 |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 407 |
407 void complexThis() { | 408 void complexThis() { |
408 var errors = []; | 409 var errors = []; |
409 | 410 |
410 final input1 = r''' | 411 final input1 = r''' |
411 .light { | 412 .light { |
412 .leftCol { | 413 .leftCol { |
413 .textLink { | 414 .textLink { |
414 color: fooL1; | 415 color: fooL1; |
415 &:hover { color: barL1;} | 416 &:hover { color: barL1;} |
416 } | 417 } |
417 .picLink { | 418 .picLink { |
418 background-image: url(/fooL1.jpg); | 419 background-image: url(/fooL1.jpg); |
419 &:hover { background-image: url(/barL1.jpg);} | 420 &:hover { background-image: url(/barL1.jpg);} |
420 } | 421 } |
421 .textWithIconLink { | 422 .textWithIconLink { |
422 color: fooL2; | 423 color: fooL2; |
423 background-image: url(/fooL2.jpg); | 424 background-image: url(/fooL2.jpg); |
424 &:hover { color: barL2; background-image: url(/barL2.jpg);} | 425 &:hover { color: barL2; background-image: url(/barL2.jpg);} |
425 } | 426 } |
426 } | 427 } |
427 }'''; | 428 }'''; |
428 | 429 |
429 final generated1 = r'''.light { | 430 final generated1 = r'''.light { |
430 } | 431 } |
431 .light .leftCol .textLink { | 432 .light .leftCol .textLink { |
432 color: fooL1; | 433 color: fooL1; |
433 } | 434 } |
434 .light .leftCol .textLink:hover { | 435 .light .leftCol .textLink:hover { |
435 color: barL1; | 436 color: barL1; |
436 } | 437 } |
(...skipping 12 matching lines...) Expand all Loading... |
449 background-image: url("/barL2.jpg"); | 450 background-image: url("/barL2.jpg"); |
450 }'''; | 451 }'''; |
451 | 452 |
452 compileAndValidate(input1, generated1); | 453 compileAndValidate(input1, generated1); |
453 | 454 |
454 final input2 = r''' | 455 final input2 = r''' |
455 .textLink { | 456 .textLink { |
456 .light .leftCol & { | 457 .light .leftCol & { |
457 color: fooL1; | 458 color: fooL1; |
458 &:hover { color: barL1; } | 459 &:hover { color: barL1; } |
459 } | 460 } |
460 .light .rightCol & { | 461 .light .rightCol & { |
461 color: fooL3; | 462 color: fooL3; |
462 &:hover { color: barL3; } | 463 &:hover { color: barL3; } |
463 } | 464 } |
464 }'''; | 465 }'''; |
465 | 466 |
466 final generated2 = r''' | 467 final generated2 = r''' |
467 .textLink { | 468 .textLink { |
468 } | 469 } |
469 .light .leftCol .textLink { | 470 .light .leftCol .textLink { |
470 color: fooL1; | 471 color: fooL1; |
471 } | 472 } |
472 .light .leftCol .textLink:hover { | 473 .light .leftCol .textLink:hover { |
473 color: barL1; | 474 color: barL1; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 main() { | 630 main() { |
630 test('Selector and Nested Variations', selectorVariations); | 631 test('Selector and Nested Variations', selectorVariations); |
631 test('Simple nesting', simpleNest); | 632 test('Simple nesting', simpleNest); |
632 test('Complex nesting', complexNest); | 633 test('Complex nesting', complexNest); |
633 test('@media nesting', mediaNesting); | 634 test('@media nesting', mediaNesting); |
634 test('Simple &', simpleThis); | 635 test('Simple &', simpleThis); |
635 test("Variations &", variationsThis); | 636 test("Variations &", variationsThis); |
636 test('Complex &', complexThis); | 637 test('Complex &', complexThis); |
637 test('& with + selector', thisCombinator); | 638 test('& with + selector', thisCombinator); |
638 } | 639 } |
OLD | NEW |