Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 3206 Bytes
- Properties:
- Property svn:executable is set to *
1 | #!/usr/bin/env ruby |
2 | require 'test/unit' |
3 | require File.dirname(__FILE__) + '/../test_helper' |
4 | require 'sass/css' |
5 | |
6 | class CSS2SassTest < Test::Unit::TestCase |
7 | def test_basic |
8 | css = <<CSS |
9 | h1 { |
10 | color: red; |
11 | } |
12 | CSS |
13 | assert_equal(<<SASS, css2sass(css)) |
14 | h1 |
15 | color: red |
16 | SASS |
17 | assert_equal(<<SASS, css2sass(css, :old => true)) |
18 | h1 |
19 | :color red |
20 | SASS |
21 | end |
22 | |
23 | def test_nesting |
24 | assert_equal(<<SASS, css2sass(<<CSS)) |
25 | li |
26 | display: none |
27 | |
28 | a |
29 | text-decoration: none |
30 | |
31 | span |
32 | color: yellow |
33 | |
34 | &:hover |
35 | text-decoration: underline |
36 | SASS |
37 | li { |
38 | display: none; |
39 | } |
40 | |
41 | li a { |
42 | text-decoration: none; |
43 | } |
44 | |
45 | li a span { |
46 | color: yellow; |
47 | } |
48 | |
49 | li a:hover { |
50 | text-decoration: underline; |
51 | } |
52 | CSS |
53 | end |
54 | |
55 | def test_no_nesting_around_rules |
56 | assert_equal(<<SASS, css2sass(<<CSS)) |
57 | div .warning |
58 | color: #d21a19 |
59 | |
60 | |
61 | span .debug |
62 | cursor: crosshair |
63 | |
64 | |
65 | div .debug |
66 | cursor: default |
67 | SASS |
68 | div .warning { |
69 | color: #d21a19; } |
70 | span .debug { |
71 | cursor: crosshair;} |
72 | div .debug { |
73 | cursor: default; } |
74 | CSS |
75 | end |
76 | |
77 | def test_comments_multiline |
78 | css = <<CSS |
79 | /* comment */ |
80 | elephant.rawr { |
81 | rampages: excessively; |
82 | } |
83 | |
84 | /* actual multiline |
85 | comment */ |
86 | span.turkey { |
87 | isdinner: true; |
88 | } |
89 | |
90 | .turducken { |
91 | /* Sounds funny |
92 | doesn't it */ |
93 | chimera: not_really; |
94 | } |
95 | |
96 | #overhere { |
97 | bored: sorta; /* it's for a good |
98 | cause */ |
99 | better_than: thread_pools; |
100 | } |
101 | |
102 | #one_more { |
103 | finally: srsly; |
104 | } /* just a line here */ |
105 | CSS |
106 | sass = <<SASS |
107 | elephant.rawr |
108 | rampages: excessively |
109 | |
110 | |
111 | span.turkey |
112 | isdinner: true |
113 | |
114 | |
115 | .turducken |
116 | chimera: not_really |
117 | |
118 | |
119 | #overhere |
120 | bored: sorta |
121 | better_than: thread_pools |
122 | |
123 | |
124 | #one_more |
125 | finally: srsly |
126 | SASS |
127 | assert_equal(css2sass(css), sass) |
128 | end |
129 | |
130 | def test_fold_commas |
131 | assert_equal(<<SASS, css2sass(<<CSS)) |
132 | li |
133 | .one, .two |
134 | color: red |
135 | SASS |
136 | li .one { |
137 | color: red; |
138 | } |
139 | li .two { |
140 | color: red; |
141 | } |
142 | CSS |
143 | |
144 | assert_equal(<<SASS, css2sass(<<CSS)) |
145 | .one |
146 | color: green |
147 | |
148 | |
149 | .two |
150 | color: green |
151 | color: red |
152 | |
153 | |
154 | .three |
155 | color: red |
156 | SASS |
157 | .one, .two { |
158 | color: green; |
159 | } |
160 | |
161 | .two, .three { |
162 | color: red; |
163 | } |
164 | CSS |
165 | end |
166 | |
167 | def test_bad_formatting |
168 | assert_equal(<<SASS, css2sass(<<CSS)) |
169 | hello |
170 | parent: true |
171 | |
172 | there |
173 | parent: false |
174 | |
175 | who |
176 | hoo: false |
177 | |
178 | why |
179 | y: true |
180 | |
181 | when |
182 | wen: nao |
183 | |
184 | |
185 | down_here |
186 | yeah: true |
187 | SASS |
188 | hello { |
189 | parent: true; |
190 | } |
191 | |
192 | hello there { |
193 | parent: false; |
194 | } |
195 | hello who { |
196 | hoo: false; |
197 | } |
198 | hello why { |
199 | y: true; |
200 | } |
201 | hello when { |
202 | wen: nao; |
203 | } |
204 | |
205 | |
206 | |
207 | down_here { yeah: true; } |
208 | CSS |
209 | end |
210 | |
211 | def test_comments_in_selectors |
212 | assert_equal(<<SASS, css2sass(<<CSS)) |
213 | .js |
214 | #location-navigation-form .form-submit, #business-listing-form .form-submit, #detailTabs ul, #detailsEnhanced #addTags, #locationSearchList, #moreHoods |
215 | display: none |
216 | |
217 | |
218 | #navListLeft |
219 | display: none |
220 | SASS |
221 | .js #location-navigation-form .form-submit, |
222 | .js #business-listing-form .form-submit, |
223 | .js #detailTabs ul, |
224 | /* .js #addReview, */ |
225 | /* .js #addTags, */ |
226 | .js #detailsEnhanced #addTags, |
227 | .js #locationSearchList, |
228 | .js #moreHoods, |
229 | #navListLeft |
230 | { display: none; } |
231 | CSS |
232 | end |
233 | |
234 | def test_pseudo_classes_are_escaped |
235 | assert_equal(<<SASS, css2sass(<<CSS)) |
236 | \\:focus |
237 | a: b |
238 | |
239 | \\:foo |
240 | bar: baz |
241 | SASS |
242 | :focus {a: b;} |
243 | :focus :foo {bar: baz;} |
244 | CSS |
245 | end |
246 | |
247 | private |
248 | |
249 | def css2sass(string, opts={}) |
250 | Sass::CSS.new(string, opts).render |
251 | end |
252 | end |