| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 compiler_test; | 5 library compiler_test; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 import 'package:csslib/parser.dart'; | 9 import 'package:csslib/parser.dart'; |
| 10 import 'package:csslib/visitor.dart'; | 10 import 'package:csslib/visitor.dart'; |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 expect(simpleSelector1 is ClassSelector, true); | 509 expect(simpleSelector1 is ClassSelector, true); |
| 510 expect(selector1.isCombinatorNone, true); | 510 expect(selector1.isCombinatorNone, true); |
| 511 expect("foobar", simpleSelector1.name); | 511 expect("foobar", simpleSelector1.name); |
| 512 } | 512 } |
| 513 | 513 |
| 514 /** Test List<int> as input to parser. */ | 514 /** Test List<int> as input to parser. */ |
| 515 void testArrayOfChars() { | 515 void testArrayOfChars() { |
| 516 var errors = []; | 516 var errors = []; |
| 517 var input = '<![CDATA[.foo { ' | 517 var input = '<![CDATA[.foo { ' |
| 518 'color: red; left: 20px; top: 20px; width: 100px; height:200px' | 518 'color: red; left: 20px; top: 20px; width: 100px; height:200px' |
| 519 '}' | 519 '}' |
| 520 '#div {' | 520 '#div {' |
| 521 'color : #00F578; border-color: #878787;' | 521 'color : #00F578; border-color: #878787;' |
| 522 '}]]>'; | 522 '}]]>'; |
| 523 | 523 |
| 524 var stylesheet = parse(UTF8.encode(input), errors: errors); | 524 var stylesheet = parse(UTF8.encode(input), errors: errors); |
| 525 | 525 |
| 526 expect(stylesheet != null, true); | 526 expect(stylesheet != null, true); |
| 527 expect(errors.isEmpty, true, reason: errors.toString()); | 527 expect(errors.isEmpty, true, reason: errors.toString()); |
| 528 | 528 |
| 529 expect(prettyPrint(stylesheet), r''' | 529 expect(prettyPrint(stylesheet), r''' |
| 530 .foo { | 530 .foo { |
| 531 color: #f00; | 531 color: #f00; |
| 532 left: 20px; | 532 left: 20px; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 577 |
| 578 *|*:not(:hover) { | 578 *|*:not(:hover) { |
| 579 color: magenta; | 579 color: magenta; |
| 580 } | 580 } |
| 581 | 581 |
| 582 p:nth-child(3n-3) { } | 582 p:nth-child(3n-3) { } |
| 583 | 583 |
| 584 div:nth-child(2n) { color : red; } | 584 div:nth-child(2n) { color : red; } |
| 585 '''; | 585 '''; |
| 586 | 586 |
| 587 var stylesheet = parseCss(input, errors: errors, | 587 var stylesheet = |
| 588 opts: ['--no-colors', 'memory']); | 588 parseCss(input, errors: errors, opts: ['--no-colors', 'memory']); |
| 589 | 589 |
| 590 expect(stylesheet != null, true); | 590 expect(stylesheet != null, true); |
| 591 expect(errors.isEmpty, true, reason: errors.toString()); | 591 expect(errors.isEmpty, true, reason: errors.toString()); |
| 592 expect(prettyPrint(stylesheet), r''' | 592 expect(prettyPrint(stylesheet), r''' |
| 593 html:lang(fr-ca) { | 593 html:lang(fr-ca) { |
| 594 quotes: '" ' ' "'; | 594 quotes: '" ' ' "'; |
| 595 } | 595 } |
| 596 zoom { | 596 zoom { |
| 597 } | 597 } |
| 598 a:link { | 598 a:link { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 } | 640 } |
| 641 | 641 |
| 642 void testNegation() { | 642 void testNegation() { |
| 643 // TODO(terry): Implement | 643 // TODO(terry): Implement |
| 644 } | 644 } |
| 645 | 645 |
| 646 void testHost() { | 646 void testHost() { |
| 647 var errors = []; | 647 var errors = []; |
| 648 var input = '@host { ' | 648 var input = '@host { ' |
| 649 ':scope {' | 649 ':scope {' |
| 650 'white-space: nowrap;' | 650 'white-space: nowrap;' |
| 651 'overflow-style: marquee-line;' | 651 'overflow-style: marquee-line;' |
| 652 'overflow-x: marquee;' | 652 'overflow-x: marquee;' |
| 653 '}' | 653 '}' |
| 654 '* { color: red; }' | 654 '* { color: red; }' |
| 655 '*:hover { font-weight: bold; }' | 655 '*:hover { font-weight: bold; }' |
| 656 ':nth-child(odd) { color: blue; }' | 656 ':nth-child(odd) { color: blue; }' |
| 657 '}'; | 657 '}'; |
| 658 var stylesheet = parseCss(input, errors: errors, | 658 var stylesheet = |
| 659 opts: ['--no-colors', 'memory']); | 659 parseCss(input, errors: errors, opts: ['--no-colors', 'memory']); |
| 660 | 660 |
| 661 expect(stylesheet != null, true); | 661 expect(stylesheet != null, true); |
| 662 expect(errors.isEmpty, true, reason: errors.toString()); | 662 expect(errors.isEmpty, true, reason: errors.toString()); |
| 663 expect(prettyPrint(stylesheet), r''' | 663 expect(prettyPrint(stylesheet), r''' |
| 664 @host { | 664 @host { |
| 665 :scope { | 665 :scope { |
| 666 white-space: nowrap; | 666 white-space: nowrap; |
| 667 overflow-style: marquee-line; | 667 overflow-style: marquee-line; |
| 668 overflow-x: marquee; | 668 overflow-x: marquee; |
| 669 } | 669 } |
| 670 * { | 670 * { |
| 671 color: #f00; | 671 color: #f00; |
| 672 } | 672 } |
| 673 *:hover { | 673 *:hover { |
| 674 font-weight: bold; | 674 font-weight: bold; |
| 675 } | 675 } |
| 676 :nth-child(odd) { | 676 :nth-child(odd) { |
| 677 color: #00f; | 677 color: #00f; |
| 678 } | 678 } |
| 679 }'''); | 679 }'''); |
| 680 } | 680 } |
| 681 | 681 |
| 682 // TODO(terry): Move to emitter_test.dart when real emitter exist. | 682 // TODO(terry): Move to emitter_test.dart when real emitter exist. |
| 683 void testEmitter() { | 683 void testEmitter() { |
| 684 var errors = []; | 684 var errors = []; |
| 685 var input = '.foo { ' | 685 var input = '.foo { ' |
| 686 'color: red; left: 20px; top: 20px; width: 100px; height:200px' | 686 'color: red; left: 20px; top: 20px; width: 100px; height:200px' |
| 687 '}' | 687 '}' |
| 688 '#div {' | 688 '#div {' |
| 689 'color : #00F578; border-color: #878787;' | 689 'color : #00F578; border-color: #878787;' |
| 690 '}'; | 690 '}'; |
| 691 var stylesheet = parseCss(input, errors: errors); | 691 var stylesheet = parseCss(input, errors: errors); |
| 692 | 692 |
| 693 expect(stylesheet != null, true); | 693 expect(stylesheet != null, true); |
| 694 expect(errors.isEmpty, true, reason: errors.toString()); | 694 expect(errors.isEmpty, true, reason: errors.toString()); |
| 695 | 695 |
| 696 walkTree(stylesheet); | 696 walkTree(stylesheet); |
| 697 | 697 |
| 698 expect(prettyPrint(stylesheet), r''' | 698 expect(prettyPrint(stylesheet), r''' |
| 699 .foo { | 699 .foo { |
| 700 color: #f00; | 700 color: #f00; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 719 test('Selector Groups', testSelectorGroups); | 719 test('Selector Groups', testSelectorGroups); |
| 720 test('Combinator', testCombinator); | 720 test('Combinator', testCombinator); |
| 721 test('Wildcards', testWildcard); | 721 test('Wildcards', testWildcard); |
| 722 test('Pseudo', testPseudo); | 722 test('Pseudo', testPseudo); |
| 723 test('Attributes', testAttribute); | 723 test('Attributes', testAttribute); |
| 724 test('Negation', testNegation); | 724 test('Negation', testNegation); |
| 725 test('@host', testHost); | 725 test('@host', testHost); |
| 726 test('Parse List<int> as input', testArrayOfChars); | 726 test('Parse List<int> as input', testArrayOfChars); |
| 727 test('Simple Emitter', testEmitter); | 727 test('Simple Emitter', testEmitter); |
| 728 } | 728 } |
| OLD | NEW |