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

Side by Side Diff: test/var_test.dart

Issue 1022963002: pkg/csslib: fixes for args (Closed) Base URL: https://github.com/dart-lang/csslib@master
Patch Set: nits Created 5 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
« no previous file with comments | « test/testing.dart ('k') | test/visitor_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 var_test; 5 library var_test;
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'testing.dart'; 8 import 'testing.dart';
9 9
10 List options = ['--no-colors', '--warnings_as_errors', 'memory'];
11
12 compileAndValidate(String input, String generated) { 10 compileAndValidate(String input, String generated) {
13 var errors = []; 11 var errors = [];
14 var stylesheet = compileCss(input, errors: errors, opts: options); 12 var stylesheet = compileCss(input, errors: errors, opts: options);
15 expect(stylesheet != null, true); 13 expect(stylesheet != null, true);
16 expect(errors.isEmpty, true, reason: errors.toString()); 14 expect(errors.isEmpty, true, reason: errors.toString());
17 expect(prettyPrint(stylesheet), generated); 15 expect(prettyPrint(stylesheet), generated);
18 } 16 }
19 17
20 compilePolyfillAndValidate(String input, String generated) { 18 compilePolyfillAndValidate(String input, String generated) {
21 var errors = []; 19 var errors = [];
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 '''; 635 ''';
638 final generated = ''' 636 final generated = '''
639 var-color-background: #f00; 637 var-color-background: #f00;
640 var-color-foreground: #00f; 638 var-color-foreground: #00f;
641 639
642 .test { 640 .test {
643 background-color: var(color-background); 641 background-color: var(color-background);
644 color: var(color-foreground); 642 color: var(color-foreground);
645 }'''; 643 }''';
646 644
647 var stylesheet = 645 var stylesheet = parseCss(input, errors: errors, opts: simpleOptions);
648 parseCss(input, errors: errors, opts: ['--no-colors', 'memory']);
649 646
650 expect(stylesheet != null, true); 647 expect(stylesheet != null, true);
651 expect(errors.isEmpty, true, reason: errors.toString()); 648 expect(errors.isEmpty, true, reason: errors.toString());
652 expect(prettyPrint(stylesheet), generated); 649 expect(prettyPrint(stylesheet), generated);
653 650
654 compileAndValidate(input, generated); 651 compileAndValidate(input, generated);
655 652
656 final input2 = ''' 653 final input2 = '''
657 @color-background: red; 654 @color-background: red;
658 @color-foreground: blue; 655 @color-foreground: blue;
659 656
660 .test { 657 .test {
661 background-color: @color-background; 658 background-color: @color-background;
662 color: @color-foreground; 659 color: @color-foreground;
663 } 660 }
664 '''; 661 ''';
665 final generated2 = '''var-color-background: #f00; 662 final generated2 = '''var-color-background: #f00;
666 var-color-foreground: #00f; 663 var-color-foreground: #00f;
667 664
668 .test { 665 .test {
669 background-color: var(color-background); 666 background-color: var(color-background);
670 color: var(color-foreground); 667 color: var(color-foreground);
671 }'''; 668 }''';
672 669
673 stylesheet = 670 stylesheet = parseCss(input, errors: errors..clear(), opts: simpleOptions);
674 parseCss(input, errors: errors..clear(), opts: ['--no-colors', 'memory']);
675 671
676 expect(stylesheet != null, true); 672 expect(stylesheet != null, true);
677 expect(errors.isEmpty, true, reason: errors.toString()); 673 expect(errors.isEmpty, true, reason: errors.toString());
678 expect(prettyPrint(stylesheet), generated2); 674 expect(prettyPrint(stylesheet), generated2);
679 675
680 compileAndValidate(input2, generated2); 676 compileAndValidate(input2, generated2);
681 } 677 }
682 678
683 testLess() { 679 testLess() {
684 final errors = []; 680 final errors = [];
685 final input = ''' 681 final input = '''
686 @color-background: red; 682 @color-background: red;
687 @color-foreground: blue; 683 @color-foreground: blue;
688 684
689 .test { 685 .test {
690 background-color: var(color-background); 686 background-color: var(color-background);
691 color: var(color-foreground); 687 color: var(color-foreground);
692 } 688 }
693 '''; 689 ''';
694 final generated = '''var-color-background: #f00; 690 final generated = '''var-color-background: #f00;
695 var-color-foreground: #00f; 691 var-color-foreground: #00f;
696 692
697 .test { 693 .test {
698 background-color: var(color-background); 694 background-color: var(color-background);
699 color: var(color-foreground); 695 color: var(color-foreground);
700 }'''; 696 }''';
701 697
702 var stylesheet = 698 var stylesheet = parseCss(input, errors: errors, opts: simpleOptions);
703 parseCss(input, errors: errors, opts: ['--no-colors', 'memory']);
704 699
705 expect(stylesheet != null, true); 700 expect(stylesheet != null, true);
706 expect(errors.isEmpty, true, reason: errors.toString()); 701 expect(errors.isEmpty, true, reason: errors.toString());
707 expect(prettyPrint(stylesheet), generated); 702 expect(prettyPrint(stylesheet), generated);
708 703
709 compileAndValidate(input, generated); 704 compileAndValidate(input, generated);
710 705
711 final input2 = ''' 706 final input2 = '''
712 @color-background: red; 707 @color-background: red;
713 @color-foreground: blue; 708 @color-foreground: blue;
714 709
715 .test { 710 .test {
716 background-color: @color-background; 711 background-color: @color-background;
717 color: @color-foreground; 712 color: @color-foreground;
718 } 713 }
719 '''; 714 ''';
720 final generated2 = '''var-color-background: #f00; 715 final generated2 = '''var-color-background: #f00;
721 var-color-foreground: #00f; 716 var-color-foreground: #00f;
722 717
723 .test { 718 .test {
724 background-color: var(color-background); 719 background-color: var(color-background);
725 color: var(color-foreground); 720 color: var(color-foreground);
726 }'''; 721 }''';
727 722
728 stylesheet = 723 stylesheet = parseCss(input, errors: errors..clear(), opts: simpleOptions);
729 parseCss(input, errors: errors..clear(), opts: ['--no-colors', 'memory']);
730 724
731 expect(stylesheet != null, true); 725 expect(stylesheet != null, true);
732 expect(errors.isEmpty, true, reason: errors.toString()); 726 expect(errors.isEmpty, true, reason: errors.toString());
733 expect(prettyPrint(stylesheet), generated2); 727 expect(prettyPrint(stylesheet), generated2);
734 728
735 compileAndValidate(input2, generated2); 729 compileAndValidate(input2, generated2);
736 } 730 }
737 731
738 void polyfill() { 732 void polyfill() {
739 compilePolyfillAndValidate(r''' 733 compilePolyfillAndValidate(r'''
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 test('Expressions var', expressionsVar); 916 test('Expressions var', expressionsVar);
923 test('Default value in var()', defaultVar); 917 test('Default value in var()', defaultVar);
924 test('CSS Parser only var', parserVar); 918 test('CSS Parser only var', parserVar);
925 test('Var syntax', testVar); 919 test('Var syntax', testVar);
926 test('Indirects', testIndirects); 920 test('Indirects', testIndirects);
927 test('Forward Refs', undefinedVars); 921 test('Forward Refs', undefinedVars);
928 test('Less syntax', testLess); 922 test('Less syntax', testLess);
929 test('Polyfill', polyfill); 923 test('Polyfill', polyfill);
930 test('Multi-file', includes); 924 test('Multi-file', includes);
931 } 925 }
OLDNEW
« no previous file with comments | « test/testing.dart ('k') | test/visitor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698