| 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:test/test.dart'; | 7 import 'package:test/test.dart'; |
| 8 | 8 |
| 9 import 'testing.dart'; | 9 import 'testing.dart'; |
| 10 | 10 |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 height: 30px; | 334 height: 30px; |
| 335 } | 335 } |
| 336 span { | 336 span { |
| 337 color: #1f1f2f; | 337 color: #1f1f2f; |
| 338 }'''; | 338 }'''; |
| 339 | 339 |
| 340 compileAndValidate(input, generated); | 340 compileAndValidate(input, generated); |
| 341 } | 341 } |
| 342 | 342 |
| 343 void mediaNesting() { | 343 void mediaNesting() { |
| 344 var errors = []; | |
| 345 | |
| 346 final input = r''' | 344 final input = r''' |
| 347 @media screen and (-webkit-min-device-pixel-ratio:0) { | 345 @media screen and (-webkit-min-device-pixel-ratio:0) { |
| 348 #toggle-all { | 346 #toggle-all { |
| 349 image: url(test.jpb); | 347 image: url(test.jpb); |
| 350 div, table { | 348 div, table { |
| 351 background: none; | 349 background: none; |
| 352 a { width: 100px; } | 350 a { width: 100px; } |
| 353 } | 351 } |
| 354 color: red; | 352 color: red; |
| 355 } | 353 } |
| 356 } | 354 } |
| 357 '''; | 355 '''; |
| 358 final generated = r'''@media screen AND (-webkit-min-device-pixel-ratio:0) { | 356 final generated = r'''@media screen AND (-webkit-min-device-pixel-ratio:0) { |
| 359 #toggle-all { | 357 #toggle-all { |
| 360 image: url("test.jpb"); | 358 image: url("test.jpb"); |
| 361 color: #f00; | 359 color: #f00; |
| 362 } | 360 } |
| 363 #toggle-all div, #toggle-all table { | 361 #toggle-all div, #toggle-all table { |
| 364 background: none; | 362 background: none; |
| 365 } | 363 } |
| 366 #toggle-all div a, #toggle-all table a { | 364 #toggle-all div a, #toggle-all table a { |
| 367 width: 100px; | 365 width: 100px; |
| 368 } | 366 } |
| 369 }'''; | 367 }'''; |
| 370 | 368 |
| 371 compileAndValidate(input, generated); | 369 compileAndValidate(input, generated); |
| 372 } | 370 } |
| 373 | 371 |
| 374 void simpleThis() { | 372 void simpleThis() { |
| 375 final errors = []; | |
| 376 final input = '''#header { | 373 final input = '''#header { |
| 377 h1 { | 374 h1 { |
| 378 font-size: 26px; | 375 font-size: 26px; |
| 379 font-weight: bold; | 376 font-weight: bold; |
| 380 } | 377 } |
| 381 p { font-size: 12px; | 378 p { font-size: 12px; |
| 382 a { text-decoration: none; | 379 a { text-decoration: none; |
| 383 &:hover { border-width: 1px } | 380 &:hover { border-width: 1px } |
| 384 } | 381 } |
| 385 } | 382 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 399 text-decoration: none; | 396 text-decoration: none; |
| 400 } | 397 } |
| 401 #header p a:hover { | 398 #header p a:hover { |
| 402 border-width: 1px; | 399 border-width: 1px; |
| 403 }'''; | 400 }'''; |
| 404 | 401 |
| 405 compileAndValidate(input, generated); | 402 compileAndValidate(input, generated); |
| 406 } | 403 } |
| 407 | 404 |
| 408 void complexThis() { | 405 void complexThis() { |
| 409 var errors = []; | |
| 410 | |
| 411 final input1 = r''' | 406 final input1 = r''' |
| 412 .light { | 407 .light { |
| 413 .leftCol { | 408 .leftCol { |
| 414 .textLink { | 409 .textLink { |
| 415 color: fooL1; | 410 color: fooL1; |
| 416 &:hover { color: barL1;} | 411 &:hover { color: barL1;} |
| 417 } | 412 } |
| 418 .picLink { | 413 .picLink { |
| 419 background-image: url(/fooL1.jpg); | 414 background-image: url(/fooL1.jpg); |
| 420 &:hover { background-image: url(/barL1.jpg);} | 415 &:hover { background-image: url(/barL1.jpg);} |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 color: fooL3; | 472 color: fooL3; |
| 478 } | 473 } |
| 479 .light .rightCol .textLink:hover { | 474 .light .rightCol .textLink:hover { |
| 480 color: barL3; | 475 color: barL3; |
| 481 }'''; | 476 }'''; |
| 482 | 477 |
| 483 compileAndValidate(input2, generated2); | 478 compileAndValidate(input2, generated2); |
| 484 } | 479 } |
| 485 | 480 |
| 486 variationsThis() { | 481 variationsThis() { |
| 487 var errors = []; | |
| 488 | |
| 489 final input1 = r''' | 482 final input1 = r''' |
| 490 .textLink { | 483 .textLink { |
| 491 a { | 484 a { |
| 492 light .leftCol & { | 485 light .leftCol & { |
| 493 color: red; | 486 color: red; |
| 494 } | 487 } |
| 495 } | 488 } |
| 496 }'''; | 489 }'''; |
| 497 final generated1 = r'''.textLink { | 490 final generated1 = r'''.textLink { |
| 498 } | 491 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 final input10 = r'''.textLink { a { & & { color: red; } } }'''; | 583 final input10 = r'''.textLink { a { & & { color: red; } } }'''; |
| 591 final generated10 = r'''.textLink { | 584 final generated10 = r'''.textLink { |
| 592 } | 585 } |
| 593 .textLink a .textLink a { | 586 .textLink a .textLink a { |
| 594 color: #f00; | 587 color: #f00; |
| 595 }'''; | 588 }'''; |
| 596 compileAndValidate(input10, generated10); | 589 compileAndValidate(input10, generated10); |
| 597 } | 590 } |
| 598 | 591 |
| 599 thisCombinator() { | 592 thisCombinator() { |
| 600 var errors = []; | |
| 601 var input = r''' | 593 var input = r''' |
| 602 .btn { | 594 .btn { |
| 603 color: red; | 595 color: red; |
| 604 } | 596 } |
| 605 .btn + .btn { | 597 .btn + .btn { |
| 606 margin-left: 5px; | 598 margin-left: 5px; |
| 607 } | 599 } |
| 608 input.second { | 600 input.second { |
| 609 & + label { | 601 & + label { |
| 610 color: blue; | 602 color: blue; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 630 main() { | 622 main() { |
| 631 test('Selector and Nested Variations', selectorVariations); | 623 test('Selector and Nested Variations', selectorVariations); |
| 632 test('Simple nesting', simpleNest); | 624 test('Simple nesting', simpleNest); |
| 633 test('Complex nesting', complexNest); | 625 test('Complex nesting', complexNest); |
| 634 test('@media nesting', mediaNesting); | 626 test('@media nesting', mediaNesting); |
| 635 test('Simple &', simpleThis); | 627 test('Simple &', simpleThis); |
| 636 test("Variations &", variationsThis); | 628 test("Variations &", variationsThis); |
| 637 test('Complex &', complexThis); | 629 test('Complex &', complexThis); |
| 638 test('& with + selector', thisCombinator); | 630 test('& with + selector', thisCombinator); |
| 639 } | 631 } |
| OLD | NEW |