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

Side by Side Diff: pkg/csslib/test/transform/simple_test.dart

Issue 23576012: Added .scss transform (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cleanup Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library csslib.test.transform.simple_test;
6
7 import 'package:csslib/transform.dart';
8 import 'package:unittest/compact_vm_config.dart';
9
10 import 'common.dart';
11
12 void testPseudo() {
13 testSass('Pseudo', r"""
14 html:lang(fr-ca) { quotes: '" ' ' "' }
15 zoom: { }
16
17 a:link { color: red }
18 :link { color: blue }
19
20 a:focus { background: yellow }
21 a:focus:hover { background: white }
22
23 p.special:first-letter {color: #ffd800}
24
25 p:not(#example){
26 background-color: yellow;
27 }
28
29 input:not([DISABLED]){
30 background-color: yellow;
31 }
32
33 html|*:not(:link):not(:visited) {
34 border: 1px solid black;
35 }
36
37 *:not(FOO) {
38 height: 20px;
39 }
40
41 *|*:not(*) {
42 color: orange;
43 }
44
45 *|*:not(:hover) {
46 color: magenta;
47 }
48
49 p:nth-child(3n-3) { }
50
51 div:nth-child(2n) { color : red; }
52 """, r"""html:lang(fr-ca) {
53 quotes: "\" " " \"";
54 }
55 zoom {
56 }
57 a:link {
58 color: #f00;
59 }
60 :link {
61 color: #00f;
62 }
63 a:focus {
64 background: #ff0;
65 }
66 a:focus:hover {
67 background: #fff;
68 }
69 p.special:first-letter {
70 color: #ffd800;
71 }
72 p:not(#example) {
73 background-color: #ff0;
74 }
75 input:not([DISABLED]) {
76 background-color: #ff0;
77 }
78 html|*:not(:link):not(:visited) {
79 border: 1px solid #000;
80 }
81 *:not(FOO) {
82 height: 20px;
83 }
84 *|*:not(*) {
85 color: #ffa500;
86 }
87 *|*:not(:hover) {
88 color: #f0f;
89 }
90 p:nth-child(3n-3) {
91 }
92 div:nth-child(2n) {
93 color: #f00;
94 }""");
95 }
96
97 void testHost() {
98 var input = r"""
99 @host {
100 :scope {
101 white-space: nowrap;
102 overflow-style: marquee-line;
103 overflow-x: marquee;
104 }
105 * { color: red; }
106 *:hover { font-weight: bold; }
107 :nth-child(odd) { color: blue; }
108 };""";
109 var expected = r"""
110 @host {
111 :scope {
112 white-space: nowrap;
113 overflow-style: marquee-line;
114 overflow-x: marquee;
115 }
116 * {
117 color: #f00;
118 }
119 *:hover {
120 font-weight: bold;
121 }
122 :nth-child(odd) {
123 color: #00f;
124 }
125 }""";
126 testSass("@host", input, expected);
127 }
128
129 // TODO(terry): Move to emitter_test.dart when real emitter exist.
130 void testEmitter() {
131 var errors = [];
132 var input = r"""
133 .foo {
134 color: red; left: 20px; top: 20px; width: 100px; height:200px
135 }
136 #div {
137 color : #00F578; border-color: #878787;
138 }""";
139 var expected = r"""
140 .foo {
141 color: #f00;
142 left: 20px;
143 top: 20px;
144 width: 100px;
145 height: 200px;
146 }
147 #div {
148 color: #00F578;
149 border-color: #878787;
150 }""";
151 testSass("Emitter", input, expected);
152 }
153
154 void testSimple() {
155 var input = r"""
156 .foo {
157 color: red; left: 20px; top: 20px; width: 100px; height:200px
158 }
159 #div {
160 color : #00F578; border-color: #878787;
161 }""";
162 var expected = r""".foo {
163 color: #f00;
164 left: 20px;
165 top: 20px;
166 width: 100px;
167 height: 200px;
168 }
169 #div {
170 color: #00F578;
171 border-color: #878787;
172 }""";
173 testSass('Simple', input, expected);
174 }
175
176 testSass(String testName, String inputFile, String expectedFile) {
177 var transform = new ScssTransformer();
178 expectedFile = "/***** Generated by SCSS transform. *****/\n\n$expectedFile";
179 testPhases(testName, [[transform]], { 'a|web/test.scss' : inputFile },
180 { 'a|web/test.css' : expectedFile });
181 // TODO(terry): Test for any errors reported in logger.
182 }
183
184 void main() {
185 useCompactVMConfiguration();
186
187 testSimple();
188 testPseudo();
189 testHost();
190 testEmitter();
191 }
192
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698