| 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 var_test; | 5 library var_test; |
| 6 | 6 |
| 7 import 'package:csslib/src/messages.dart'; |
| 7 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
| 8 | 9 |
| 9 import 'testing.dart'; | 10 import 'testing.dart'; |
| 10 | 11 |
| 11 compileAndValidate(String input, String generated) { | 12 compileAndValidate(String input, String generated) { |
| 12 var errors = []; | 13 var errors = <Message>[]; |
| 13 var stylesheet = compileCss(input, errors: errors, opts: options); | 14 var stylesheet = compileCss(input, errors: errors, opts: options); |
| 14 expect(stylesheet != null, true); | 15 expect(stylesheet != null, true); |
| 15 expect(errors.isEmpty, true, reason: errors.toString()); | 16 expect(errors.isEmpty, true, reason: errors.toString()); |
| 16 expect(prettyPrint(stylesheet), generated); | 17 expect(prettyPrint(stylesheet), generated); |
| 17 } | 18 } |
| 18 | 19 |
| 19 compilePolyfillAndValidate(String input, String generated) { | 20 compilePolyfillAndValidate(String input, String generated) { |
| 20 var errors = []; | 21 var errors = <Message>[]; |
| 21 var stylesheet = polyFillCompileCss(input, errors: errors, opts: options); | 22 var stylesheet = polyFillCompileCss(input, errors: errors, opts: options); |
| 22 expect(stylesheet != null, true); | 23 expect(stylesheet != null, true); |
| 23 expect(errors.isEmpty, true, reason: errors.toString()); | 24 expect(errors.isEmpty, true, reason: errors.toString()); |
| 24 expect(prettyPrint(stylesheet), generated); | 25 expect(prettyPrint(stylesheet), generated); |
| 25 } | 26 } |
| 26 | 27 |
| 27 void simpleVar() { | 28 void simpleVar() { |
| 28 final input = ''':root { | 29 final input = ''':root { |
| 29 var-color-background: red; | 30 var-color-background: red; |
| 30 var-color-foreground: blue; | 31 var-color-foreground: blue; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 background: #0a0 url("test.png") no-repeat right top; | 334 background: #0a0 url("test.png") no-repeat right top; |
| 334 } | 335 } |
| 335 .test-6 { | 336 .test-6 { |
| 336 border: #f00 solid 20px; | 337 border: #f00 solid 20px; |
| 337 }'''; | 338 }'''; |
| 338 | 339 |
| 339 compilePolyfillAndValidate(input, generatedPolyfill); | 340 compilePolyfillAndValidate(input, generatedPolyfill); |
| 340 } | 341 } |
| 341 | 342 |
| 342 void undefinedVars() { | 343 void undefinedVars() { |
| 343 final errors = []; | 344 final errors = <Message>[]; |
| 344 final input = ''':root { | 345 final input = ''':root { |
| 345 var-color-background: red; | 346 var-color-background: red; |
| 346 var-color-foreground: blue; | 347 var-color-foreground: blue; |
| 347 | 348 |
| 348 var-a: var(b); | 349 var-a: var(b); |
| 349 var-b: var(c); | 350 var-b: var(c); |
| 350 var-c: #00ff00; | 351 var-c: #00ff00; |
| 351 | 352 |
| 352 var-one: var(two); | 353 var-one: var(two); |
| 353 var-two: var(one); | 354 var-two: var(one); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 src: local(Gentium Bold), local(Gentium-Bold), url("GentiumBold.ttf"); | 616 src: local(Gentium Bold), local(Gentium-Bold), url("GentiumBold.ttf"); |
| 616 unicode-range: U+0A-FF, U+980-9FF, U+????, U+3???; | 617 unicode-range: U+0A-FF, U+980-9FF, U+????, U+3???; |
| 617 } | 618 } |
| 618 .foobar { | 619 .foobar { |
| 619 grid-columns: 10px ("content" 1fr 10px) [4]; | 620 grid-columns: 10px ("content" 1fr 10px) [4]; |
| 620 }'''; | 621 }'''; |
| 621 compilePolyfillAndValidate(input, generatedPolyfill); | 622 compilePolyfillAndValidate(input, generatedPolyfill); |
| 622 } | 623 } |
| 623 | 624 |
| 624 testVar() { | 625 testVar() { |
| 625 final errors = []; | 626 final errors = <Message>[]; |
| 626 final input = ''' | 627 final input = ''' |
| 627 @color-background: red; | 628 @color-background: red; |
| 628 @color-foreground: blue; | 629 @color-foreground: blue; |
| 629 | 630 |
| 630 .test { | 631 .test { |
| 631 background-color: var(color-background); | 632 background-color: var(color-background); |
| 632 color: var(color-foreground); | 633 color: var(color-foreground); |
| 633 } | 634 } |
| 634 '''; | 635 '''; |
| 635 final generated = ''' | 636 final generated = ''' |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 stylesheet = parseCss(input, errors: errors..clear(), opts: simpleOptions); | 670 stylesheet = parseCss(input, errors: errors..clear(), opts: simpleOptions); |
| 670 | 671 |
| 671 expect(stylesheet != null, true); | 672 expect(stylesheet != null, true); |
| 672 expect(errors.isEmpty, true, reason: errors.toString()); | 673 expect(errors.isEmpty, true, reason: errors.toString()); |
| 673 expect(prettyPrint(stylesheet), generated2); | 674 expect(prettyPrint(stylesheet), generated2); |
| 674 | 675 |
| 675 compileAndValidate(input2, generated2); | 676 compileAndValidate(input2, generated2); |
| 676 } | 677 } |
| 677 | 678 |
| 678 testLess() { | 679 testLess() { |
| 679 final errors = []; | 680 final errors = <Message>[]; |
| 680 final input = ''' | 681 final input = ''' |
| 681 @color-background: red; | 682 @color-background: red; |
| 682 @color-foreground: blue; | 683 @color-foreground: blue; |
| 683 | 684 |
| 684 .test { | 685 .test { |
| 685 background-color: var(color-background); | 686 background-color: var(color-background); |
| 686 color: var(color-foreground); | 687 color: var(color-foreground); |
| 687 } | 688 } |
| 688 '''; | 689 '''; |
| 689 final generated = '''var-color-background: #f00; | 690 final generated = '''var-color-background: #f00; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 background-color: #fff; | 766 background-color: #fff; |
| 766 color: #fff; | 767 color: #fff; |
| 767 border-color: #fff; | 768 border-color: #fff; |
| 768 } | 769 } |
| 769 .test-1 { | 770 .test-1 { |
| 770 color: #000; | 771 color: #000; |
| 771 }'''); | 772 }'''); |
| 772 } | 773 } |
| 773 | 774 |
| 774 void includes() { | 775 void includes() { |
| 775 var errors = []; | 776 var errors = <Message>[]; |
| 776 var file1Input = r''' | 777 var file1Input = r''' |
| 777 :root { | 778 :root { |
| 778 var-redef: #0f0; | 779 var-redef: #0f0; |
| 779 | 780 |
| 780 var-a1: #fff; | 781 var-a1: #fff; |
| 781 var-a2: var(a1); | 782 var-a2: var(a1); |
| 782 var-a3: var(a2); | 783 var-a3: var(a2); |
| 783 | 784 |
| 784 var-redef: #000; | 785 var-redef: #000; |
| 785 } | 786 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 test('Expressions var', expressionsVar); | 916 test('Expressions var', expressionsVar); |
| 916 test('Default value in var()', defaultVar); | 917 test('Default value in var()', defaultVar); |
| 917 test('CSS Parser only var', parserVar); | 918 test('CSS Parser only var', parserVar); |
| 918 test('Var syntax', testVar); | 919 test('Var syntax', testVar); |
| 919 test('Indirects', testIndirects); | 920 test('Indirects', testIndirects); |
| 920 test('Forward Refs', undefinedVars); | 921 test('Forward Refs', undefinedVars); |
| 921 test('Less syntax', testLess); | 922 test('Less syntax', testLess); |
| 922 test('Polyfill', polyfill); | 923 test('Polyfill', polyfill); |
| 923 test('Multi-file', includes); | 924 test('Multi-file', includes); |
| 924 } | 925 } |
| OLD | NEW |