sass 3.2.0.alpha.275 → 3.2.0.alpha.277
Sign up to get free protection for your applications and to get access to all the features.
- data/REVISION +1 -1
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/lib/sass/environment.rb +5 -14
- data/lib/sass/exec.rb +4 -20
- data/lib/sass/tree/visitors/check_nesting.rb +19 -19
- data/lib/sass/tree/visitors/convert.rb +17 -1
- data/lib/sass/tree/visitors/extend.rb +1 -0
- data/lib/sass/tree/visitors/perform.rb +7 -6
- data/test/Gemfile +0 -1
- data/test/Gemfile.lock +0 -9
- data/test/sass/conversion_test.rb +12 -3
- data/test/sass/engine_test.rb +3 -22
- data/test/sass/extend_test.rb +3 -0
- data/test/sass/plugin_test.rb +8 -1
- data/test/sass/results/filename_fn.css +3 -0
- data/test/sass/script_test.rb +2 -2
- data/test/sass/scss/scss_test.rb +69 -3
- data/test/sass/templates/_filename_fn_import.scss +11 -0
- data/test/sass/templates/filename_fn.scss +18 -0
- metadata +17 -19
- data/lib/sass/less.rb +0 -382
- data/test/sass/less_conversion_test.rb +0 -736
- data/test/sass/templates/bork5.sass +0 -3
- data/test/sass/templates/nested_bork5.sass +0 -2
@@ -1,736 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'sass/less'
|
6
|
-
|
7
|
-
class LessConversionTest < Test::Unit::TestCase
|
8
|
-
def test_variable_declarations
|
9
|
-
assert_renders <<SCSS, <<LESS
|
10
|
-
$var1: 2px 3px;
|
11
|
-
$var2: $var1 + 7px;
|
12
|
-
|
13
|
-
$var3: fizz;
|
14
|
-
|
15
|
-
foo {
|
16
|
-
prop: $var1 $var2 $var3;
|
17
|
-
}
|
18
|
-
SCSS
|
19
|
-
@var1: 2px 3px;
|
20
|
-
@var2: @var1 + 7px;
|
21
|
-
|
22
|
-
@var3: fizz;
|
23
|
-
|
24
|
-
foo {prop: @var1 @var2 @var3}
|
25
|
-
LESS
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_nested_variable_declarations
|
29
|
-
assert_renders <<SCSS, <<LESS
|
30
|
-
.foo {
|
31
|
-
$var: 2px;
|
32
|
-
prop: $var;
|
33
|
-
}
|
34
|
-
SCSS
|
35
|
-
.foo {
|
36
|
-
@var: 2px;
|
37
|
-
prop: @var;
|
38
|
-
}
|
39
|
-
LESS
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_import
|
43
|
-
path = relative_path_to(File.dirname(__FILE__) + "/templates/importee.less")
|
44
|
-
resolved_path = relative_path_to(File.dirname(__FILE__) + "/templates/importee")
|
45
|
-
assert_renders <<SCSS, <<LESS
|
46
|
-
@import "#{resolved_path}";
|
47
|
-
@import "#{resolved_path}";
|
48
|
-
|
49
|
-
@import "#{resolved_path}";
|
50
|
-
@import "#{resolved_path}";
|
51
|
-
@import "#{resolved_path}";
|
52
|
-
SCSS
|
53
|
-
@import url(#{path});
|
54
|
-
@import url("#{path}");
|
55
|
-
|
56
|
-
@import url('#{path}');
|
57
|
-
@import '#{path}';
|
58
|
-
@import "#{path}";
|
59
|
-
LESS
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_mixins_found_through_import
|
63
|
-
path = relative_path_to(File.dirname(__FILE__) + "/templates/importee.less")
|
64
|
-
resolved_path = relative_path_to(File.dirname(__FILE__) + "/templates/importee")
|
65
|
-
assert_renders <<SCSS, <<LESS
|
66
|
-
@import "#{resolved_path}";
|
67
|
-
|
68
|
-
.baz {
|
69
|
-
@extend .foo;
|
70
|
-
@include bar;
|
71
|
-
}
|
72
|
-
SCSS
|
73
|
-
@import "#{path}";
|
74
|
-
|
75
|
-
.baz {.foo; .bar;}
|
76
|
-
LESS
|
77
|
-
end
|
78
|
-
|
79
|
-
# Selectors
|
80
|
-
|
81
|
-
def test_element_selector
|
82
|
-
assert_renders <<SCSS, <<LESS
|
83
|
-
foo {
|
84
|
-
a: b;
|
85
|
-
}
|
86
|
-
SCSS
|
87
|
-
foo {a: b}
|
88
|
-
LESS
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_class_selector
|
92
|
-
assert_renders <<SCSS, <<LESS
|
93
|
-
.foo {
|
94
|
-
a: b;
|
95
|
-
}
|
96
|
-
SCSS
|
97
|
-
.foo {a: b}
|
98
|
-
LESS
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_id_selector
|
102
|
-
assert_renders <<SCSS, <<LESS
|
103
|
-
#foo {
|
104
|
-
a: b;
|
105
|
-
}
|
106
|
-
SCSS
|
107
|
-
#foo {a: b}
|
108
|
-
LESS
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_pseudoclass_selector
|
112
|
-
assert_renders <<SCSS, <<LESS
|
113
|
-
:foo {
|
114
|
-
a: b;
|
115
|
-
}
|
116
|
-
SCSS
|
117
|
-
:foo {a: b}
|
118
|
-
LESS
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_pseudoelement_selector
|
122
|
-
assert_renders <<SCSS, <<LESS
|
123
|
-
::foo {
|
124
|
-
a: b;
|
125
|
-
}
|
126
|
-
SCSS
|
127
|
-
::foo {a: b}
|
128
|
-
LESS
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_comma_selector
|
132
|
-
assert_renders <<SCSS, <<LESS
|
133
|
-
foo, .bar .baz, :bang {
|
134
|
-
a: b;
|
135
|
-
}
|
136
|
-
SCSS
|
137
|
-
foo, .bar .baz, :bang {a: b}
|
138
|
-
LESS
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_nested_comma_selector
|
142
|
-
assert_renders <<SCSS, <<LESS
|
143
|
-
foo bar, .baz {
|
144
|
-
.bang, &:bip bap {
|
145
|
-
a: b;
|
146
|
-
}
|
147
|
-
}
|
148
|
-
SCSS
|
149
|
-
foo bar, .baz {
|
150
|
-
.bang, :bip bap {a: b}
|
151
|
-
}
|
152
|
-
LESS
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_simple_selector_sequence
|
156
|
-
assert_renders <<SCSS, <<LESS
|
157
|
-
a.foo#bar[attr=val] {
|
158
|
-
a: b;
|
159
|
-
}
|
160
|
-
SCSS
|
161
|
-
a.foo#bar[attr=val] {a: b}
|
162
|
-
LESS
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_descendant_selector
|
166
|
-
assert_renders <<SCSS, <<LESS
|
167
|
-
.foo .bar {
|
168
|
-
a: b;
|
169
|
-
}
|
170
|
-
SCSS
|
171
|
-
.foo .bar {a: b}
|
172
|
-
LESS
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_child_selector
|
176
|
-
assert_renders <<SCSS, <<LESS
|
177
|
-
.foo > .bar {
|
178
|
-
a: b;
|
179
|
-
}
|
180
|
-
SCSS
|
181
|
-
.foo > .bar {a: b}
|
182
|
-
LESS
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_adjacent_selector
|
186
|
-
assert_renders <<SCSS, <<LESS
|
187
|
-
.foo + .bar {
|
188
|
-
a: b;
|
189
|
-
}
|
190
|
-
SCSS
|
191
|
-
.foo + .bar {a: b}
|
192
|
-
LESS
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_pseudoclass_in_sequence
|
196
|
-
assert_renders <<SCSS, <<LESS
|
197
|
-
.foo:bar {
|
198
|
-
a: b;
|
199
|
-
}
|
200
|
-
SCSS
|
201
|
-
.foo:bar {a: b}
|
202
|
-
LESS
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_pseudoelement_in_sequence
|
206
|
-
assert_renders <<SCSS, <<LESS
|
207
|
-
.foo::bar {
|
208
|
-
a: b;
|
209
|
-
}
|
210
|
-
SCSS
|
211
|
-
.foo::bar {a: b}
|
212
|
-
LESS
|
213
|
-
end
|
214
|
-
|
215
|
-
# Properties
|
216
|
-
|
217
|
-
def test_space_separated_props
|
218
|
-
assert_renders <<SCSS, <<LESS
|
219
|
-
foo {
|
220
|
-
a: foo bar baz;
|
221
|
-
}
|
222
|
-
SCSS
|
223
|
-
foo {a: foo bar baz}
|
224
|
-
LESS
|
225
|
-
end
|
226
|
-
|
227
|
-
def test_comma_separated_props
|
228
|
-
assert_renders <<SCSS, <<LESS
|
229
|
-
foo {
|
230
|
-
a: foo, bar, baz;
|
231
|
-
}
|
232
|
-
SCSS
|
233
|
-
foo {a: foo, bar, baz}
|
234
|
-
LESS
|
235
|
-
end
|
236
|
-
|
237
|
-
def test_numbers
|
238
|
-
assert_renders <<SCSS, <<LESS
|
239
|
-
foo {
|
240
|
-
a: 1 2.3 -8 5px 3%;
|
241
|
-
}
|
242
|
-
SCSS
|
243
|
-
foo {a: 1 2.3 -8 5px 3%}
|
244
|
-
LESS
|
245
|
-
end
|
246
|
-
|
247
|
-
def test_colors
|
248
|
-
assert_renders <<SCSS, <<LESS
|
249
|
-
foo {
|
250
|
-
a: red #abcdef blue;
|
251
|
-
}
|
252
|
-
SCSS
|
253
|
-
foo {a: #f00 #abcdef blue}
|
254
|
-
LESS
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_strings
|
258
|
-
assert_renders <<SCSS, <<LESS
|
259
|
-
foo {
|
260
|
-
a: "foo @var bar" "baz bang" "quote'quote" 'quote"quote';
|
261
|
-
}
|
262
|
-
SCSS
|
263
|
-
foo {a: "foo @var bar" 'baz bang' "quote'quote" 'quote"quote'}
|
264
|
-
LESS
|
265
|
-
end
|
266
|
-
|
267
|
-
def test_slash
|
268
|
-
assert_renders <<SCSS, <<LESS
|
269
|
-
foo {
|
270
|
-
a: small/8px 7em/8px;
|
271
|
-
b: 8/4;
|
272
|
-
c: (8 / 4);
|
273
|
-
}
|
274
|
-
SCSS
|
275
|
-
foo {
|
276
|
-
a: small/8px 7em/8px;
|
277
|
-
b: 8/4;
|
278
|
-
c: 8 / 4;
|
279
|
-
}
|
280
|
-
LESS
|
281
|
-
end
|
282
|
-
|
283
|
-
def test_url
|
284
|
-
assert_renders <<SCSS, <<LESS
|
285
|
-
foo {
|
286
|
-
a: url("http://foobar.com/fizzle.html?foo=bar&bar=baz");
|
287
|
-
b: url("http://foobar.com/fizzle.html?foo=bar&bar=baz");
|
288
|
-
c: url("http://foobar.com/fizzle.html?foo=bar&bar=baz");
|
289
|
-
}
|
290
|
-
SCSS
|
291
|
-
foo {
|
292
|
-
a: url(http://foobar.com/fizzle.html?foo=bar&bar=baz);
|
293
|
-
b: url("http://foobar.com/fizzle.html?foo=bar&bar=baz");
|
294
|
-
c: url('http://foobar.com/fizzle.html?foo=bar&bar=baz');
|
295
|
-
}
|
296
|
-
LESS
|
297
|
-
end
|
298
|
-
|
299
|
-
def test_functions
|
300
|
-
assert_renders <<SCSS, <<LESS
|
301
|
-
foo {
|
302
|
-
a: baz(12px) rgba(80, 70 120, 0.76);
|
303
|
-
b: faz(1px + 3px) bang($var, #aaaaaa * 3);
|
304
|
-
}
|
305
|
-
SCSS
|
306
|
-
foo {
|
307
|
-
a: baz(12px) rgba(80, 70 120, 0.76);
|
308
|
-
b: faz(1px + 3px) bang(@var, #aaa * 3);
|
309
|
-
}
|
310
|
-
LESS
|
311
|
-
end
|
312
|
-
|
313
|
-
def test_alpha_function
|
314
|
-
assert_renders <<SCSS, <<LESS
|
315
|
-
foo {
|
316
|
-
a: alpha(opacity=2px);
|
317
|
-
b: alpha(opacity = $var);
|
318
|
-
}
|
319
|
-
SCSS
|
320
|
-
foo {
|
321
|
-
a: alpha(opacity=2px);
|
322
|
-
b: alpha(opacity=@var);
|
323
|
-
}
|
324
|
-
LESS
|
325
|
-
end
|
326
|
-
|
327
|
-
def test_variables
|
328
|
-
assert_renders <<SCSS, <<LESS
|
329
|
-
foo {
|
330
|
-
a: $var1 $var-foo;
|
331
|
-
}
|
332
|
-
SCSS
|
333
|
-
foo {a: @var1 @var-foo}
|
334
|
-
LESS
|
335
|
-
end
|
336
|
-
|
337
|
-
def test_operators
|
338
|
-
assert_renders <<SCSS, <<LESS
|
339
|
-
foo {
|
340
|
-
a: 1px + 2px;
|
341
|
-
b: #bbaa88 - #aa1122;
|
342
|
-
c: 5 * 3;
|
343
|
-
d: (8 / 4);
|
344
|
-
}
|
345
|
-
SCSS
|
346
|
-
foo {
|
347
|
-
a: 1px + 2px;
|
348
|
-
b: #ba8 - #a12;
|
349
|
-
c: 5 * 3;
|
350
|
-
d: 8 / 4;
|
351
|
-
}
|
352
|
-
LESS
|
353
|
-
end
|
354
|
-
|
355
|
-
def test_operator_precedence
|
356
|
-
assert_renders <<SCSS, <<LESS
|
357
|
-
foo {
|
358
|
-
a: 1 + 2 * 3 + 4;
|
359
|
-
b: 1 * 2 + 3 * 4;
|
360
|
-
c: 1 - 2 + 2 - 4;
|
361
|
-
d: 1 + 2 - 3 + 4;
|
362
|
-
e: 1 / 2 - 3 / 4;
|
363
|
-
f: 1 - 2 / 3 - 4;
|
364
|
-
g: 1 / 2 * 3 / 4;
|
365
|
-
h: (1 + 2) * (3 + 4);
|
366
|
-
i: 1 * (2 + 3) * 4;
|
367
|
-
j: 1 - (2 + 2) - 4;
|
368
|
-
k: 1 + 2 - (3 + 4);
|
369
|
-
l: 1 / (2 - 3) / 4;
|
370
|
-
m: (1 - 2) / (3 - 4);
|
371
|
-
n: 1 / (2 * 3) / 4;
|
372
|
-
}
|
373
|
-
SCSS
|
374
|
-
foo {
|
375
|
-
a: 1 + 2 * 3 + 4;
|
376
|
-
b: 1 * 2 + 3 * 4;
|
377
|
-
c: 1 - 2 + 2 - 4;
|
378
|
-
d: 1 + 2 - 3 + 4;
|
379
|
-
e: 1 / 2 - 3 / 4;
|
380
|
-
f: 1 - 2 / 3 - 4;
|
381
|
-
g: 1 / 2 * 3 / 4;
|
382
|
-
h: (1 + 2) * (3 + 4);
|
383
|
-
i: 1 * (2 + 3) * 4;
|
384
|
-
j: 1 - (2 + 2) - 4;
|
385
|
-
k: 1 + 2 - (3 + 4);
|
386
|
-
l: 1 / (2 - 3) / 4;
|
387
|
-
m: (1 - 2) / (3 - 4);
|
388
|
-
n: 1 / (2 * 3) / 4;
|
389
|
-
}
|
390
|
-
LESS
|
391
|
-
end
|
392
|
-
|
393
|
-
def test_operators_with_parens
|
394
|
-
assert_renders <<SCSS, <<LESS
|
395
|
-
foo {
|
396
|
-
a: 1px + 2px * 3;
|
397
|
-
b: (1px - 2px) / 3;
|
398
|
-
}
|
399
|
-
SCSS
|
400
|
-
foo {
|
401
|
-
a: 1px + (2px * 3);
|
402
|
-
b: (1px - (2px)) / 3;
|
403
|
-
}
|
404
|
-
LESS
|
405
|
-
end
|
406
|
-
|
407
|
-
def test_unary_minus
|
408
|
-
assert_renders <<SCSS, <<LESS
|
409
|
-
foo {
|
410
|
-
a: 1px + -3px;
|
411
|
-
}
|
412
|
-
SCSS
|
413
|
-
foo {a: 1px + (- 3px)}
|
414
|
-
LESS
|
415
|
-
end
|
416
|
-
|
417
|
-
# Nested Rules
|
418
|
-
|
419
|
-
def test_single_nested_rule
|
420
|
-
assert_renders <<SCSS, <<LESS
|
421
|
-
foo bar {
|
422
|
-
a: b;
|
423
|
-
}
|
424
|
-
SCSS
|
425
|
-
foo {bar {a: b}}
|
426
|
-
LESS
|
427
|
-
end
|
428
|
-
|
429
|
-
def test_single_nested_rule_with_props
|
430
|
-
assert_renders <<SCSS, <<LESS
|
431
|
-
foo {
|
432
|
-
bar {
|
433
|
-
a: b;
|
434
|
-
}
|
435
|
-
c: d;
|
436
|
-
e: f;
|
437
|
-
}
|
438
|
-
SCSS
|
439
|
-
foo {
|
440
|
-
bar {a: b}
|
441
|
-
c: d;
|
442
|
-
e: f;
|
443
|
-
}
|
444
|
-
LESS
|
445
|
-
end
|
446
|
-
|
447
|
-
def test_two_nested_rules
|
448
|
-
assert_renders <<SCSS, <<LESS
|
449
|
-
foo {
|
450
|
-
bar {
|
451
|
-
a: b;
|
452
|
-
}
|
453
|
-
baz {
|
454
|
-
c: d;
|
455
|
-
}
|
456
|
-
}
|
457
|
-
SCSS
|
458
|
-
foo {
|
459
|
-
bar {a: b}
|
460
|
-
baz {c: d}
|
461
|
-
}
|
462
|
-
LESS
|
463
|
-
end
|
464
|
-
|
465
|
-
def test_two_nested_rules_with_props
|
466
|
-
assert_renders <<SCSS, <<LESS
|
467
|
-
foo {
|
468
|
-
bar {
|
469
|
-
a: b;
|
470
|
-
}
|
471
|
-
baz {
|
472
|
-
c: d;
|
473
|
-
}
|
474
|
-
e: f;
|
475
|
-
g: h;
|
476
|
-
}
|
477
|
-
SCSS
|
478
|
-
foo {
|
479
|
-
bar {a: b}
|
480
|
-
baz {c: d}
|
481
|
-
e: f;
|
482
|
-
g: h;
|
483
|
-
}
|
484
|
-
LESS
|
485
|
-
end
|
486
|
-
|
487
|
-
def test_nested_rules_with_combinators
|
488
|
-
assert_renders <<SCSS, <<LESS
|
489
|
-
foo {
|
490
|
-
> bar {
|
491
|
-
a: b;
|
492
|
-
}
|
493
|
-
+ baz {
|
494
|
-
c: d;
|
495
|
-
}
|
496
|
-
}
|
497
|
-
SCSS
|
498
|
-
foo {
|
499
|
-
> bar {a: b}
|
500
|
-
+ baz {c: d}
|
501
|
-
}
|
502
|
-
LESS
|
503
|
-
end
|
504
|
-
|
505
|
-
def test_nested_pseudo_rules
|
506
|
-
assert_renders <<SCSS, <<LESS
|
507
|
-
foo {
|
508
|
-
&:bar {
|
509
|
-
a: b;
|
510
|
-
}
|
511
|
-
&::baz {
|
512
|
-
c: d;
|
513
|
-
}
|
514
|
-
}
|
515
|
-
SCSS
|
516
|
-
foo {
|
517
|
-
:bar {a: b}
|
518
|
-
::baz {c: d}
|
519
|
-
}
|
520
|
-
LESS
|
521
|
-
end
|
522
|
-
|
523
|
-
# Mixins
|
524
|
-
|
525
|
-
def test_class_inheritance
|
526
|
-
assert_renders <<SCSS, <<LESS
|
527
|
-
.foo {
|
528
|
-
a: b;
|
529
|
-
}
|
530
|
-
|
531
|
-
.bar {
|
532
|
-
@extend .foo;
|
533
|
-
}
|
534
|
-
SCSS
|
535
|
-
.foo {a: b}
|
536
|
-
.bar {.foo;}
|
537
|
-
LESS
|
538
|
-
end
|
539
|
-
|
540
|
-
def test_multiple_class_inheritance
|
541
|
-
assert_renders <<SCSS, <<LESS
|
542
|
-
.foo {
|
543
|
-
a: b;
|
544
|
-
}
|
545
|
-
|
546
|
-
.bar {
|
547
|
-
c: d;
|
548
|
-
}
|
549
|
-
|
550
|
-
.baz {
|
551
|
-
@extend .foo;
|
552
|
-
@extend .bar;
|
553
|
-
}
|
554
|
-
SCSS
|
555
|
-
.foo {a: b}
|
556
|
-
.bar {c: d}
|
557
|
-
.baz {.foo, .bar;}
|
558
|
-
LESS
|
559
|
-
end
|
560
|
-
|
561
|
-
def test_pseudoclass_inheritance
|
562
|
-
assert_renders <<SCSS, <<LESS
|
563
|
-
:foo {
|
564
|
-
a: b;
|
565
|
-
}
|
566
|
-
|
567
|
-
:bar {
|
568
|
-
@extend :foo;
|
569
|
-
}
|
570
|
-
SCSS
|
571
|
-
:foo {a: b}
|
572
|
-
:bar {:foo;}
|
573
|
-
LESS
|
574
|
-
end
|
575
|
-
|
576
|
-
def test_multiple_pseudoclass_inheritance
|
577
|
-
assert_renders <<SCSS, <<LESS
|
578
|
-
:foo:bar {
|
579
|
-
a: b;
|
580
|
-
}
|
581
|
-
|
582
|
-
:baz {
|
583
|
-
@extend :foo:bar;
|
584
|
-
}
|
585
|
-
SCSS
|
586
|
-
:foo:bar {a: b}
|
587
|
-
:baz {:foo:bar;}
|
588
|
-
LESS
|
589
|
-
end
|
590
|
-
|
591
|
-
def test_abstract_mixin
|
592
|
-
assert_renders <<SCSS, <<LESS
|
593
|
-
@mixin foo {
|
594
|
-
a: b;
|
595
|
-
}
|
596
|
-
|
597
|
-
.bar {
|
598
|
-
@include foo;
|
599
|
-
}
|
600
|
-
SCSS
|
601
|
-
.foo() {a: b}
|
602
|
-
.bar {.foo;}
|
603
|
-
LESS
|
604
|
-
end
|
605
|
-
|
606
|
-
def test_mixin_with_args
|
607
|
-
assert_renders <<SCSS, <<LESS
|
608
|
-
@mixin foo($a: 2px, $b: red) {
|
609
|
-
a: $a;
|
610
|
-
}
|
611
|
-
|
612
|
-
.bar {
|
613
|
-
@include foo;
|
614
|
-
}
|
615
|
-
SCSS
|
616
|
-
.foo(@a: 2px, @b: #f00) {a: @a}
|
617
|
-
.bar {.foo;}
|
618
|
-
LESS
|
619
|
-
|
620
|
-
assert_renders <<SCSS, <<LESS
|
621
|
-
@mixin foo($a: 2px + 3px, $b: red) {
|
622
|
-
a: $a;
|
623
|
-
}
|
624
|
-
|
625
|
-
.bar {
|
626
|
-
@include foo(5px);
|
627
|
-
}
|
628
|
-
SCSS
|
629
|
-
.foo(@a: 2px + 3px, @b: #f00) {a: @a}
|
630
|
-
.bar {.foo(5px);}
|
631
|
-
LESS
|
632
|
-
end
|
633
|
-
|
634
|
-
## Disallowed Mixins
|
635
|
-
|
636
|
-
def test_nested_mixin
|
637
|
-
assert_warning(<<WARN) {assert_renders <<SCSS, <<LESS}
|
638
|
-
WARNING: Sass doesn't support mixing in selector sequences.
|
639
|
-
Replacing ".foo .bar" with "@extend .bar"
|
640
|
-
WARN
|
641
|
-
.foo .bar {
|
642
|
-
a: b;
|
643
|
-
}
|
644
|
-
|
645
|
-
.bar {
|
646
|
-
// .foo .bar;
|
647
|
-
@extend .bar;
|
648
|
-
}
|
649
|
-
SCSS
|
650
|
-
.foo .bar {a: b}
|
651
|
-
.bar {.foo .bar;}
|
652
|
-
LESS
|
653
|
-
end
|
654
|
-
|
655
|
-
def test_child_selector_mixin
|
656
|
-
assert_warning(<<WARN) {assert_renders <<SCSS, <<LESS}
|
657
|
-
WARNING: Sass doesn't support mixing in selector sequences.
|
658
|
-
Replacing "> .bar" with "@extend .bar"
|
659
|
-
WARN
|
660
|
-
.foo > .bar {
|
661
|
-
a: b;
|
662
|
-
}
|
663
|
-
|
664
|
-
.bar {
|
665
|
-
// > .bar;
|
666
|
-
@extend .bar;
|
667
|
-
}
|
668
|
-
SCSS
|
669
|
-
.foo > .bar {a: b}
|
670
|
-
.bar {> .bar;}
|
671
|
-
LESS
|
672
|
-
end
|
673
|
-
|
674
|
-
# Accessors
|
675
|
-
|
676
|
-
def test_property_accessor
|
677
|
-
assert_warning(<<WARN) {assert_renders <<SCSS, <<LESS}
|
678
|
-
WARNING: Sass doesn't support attribute accessors.
|
679
|
-
Ignoring .magic-box['content']
|
680
|
-
WARN
|
681
|
-
.magic-box {
|
682
|
-
content: "gold";
|
683
|
-
}
|
684
|
-
|
685
|
-
.foo {
|
686
|
-
content: /* .magic-box['content'] */;
|
687
|
-
}
|
688
|
-
SCSS
|
689
|
-
.magic-box {content: "gold"}
|
690
|
-
.foo {content: .magic-box['content']}
|
691
|
-
LESS
|
692
|
-
end
|
693
|
-
|
694
|
-
def test_variable_accessor
|
695
|
-
assert_warning(<<WARN) {assert_renders <<SCSS, <<LESS}
|
696
|
-
WARNING: Sass doesn't support attribute accessors.
|
697
|
-
Ignoring .magic-box[@content]
|
698
|
-
WARN
|
699
|
-
.magic-box {
|
700
|
-
$content: "gold";
|
701
|
-
content: $content;
|
702
|
-
}
|
703
|
-
|
704
|
-
.foo {
|
705
|
-
content: /* .magic-box[@content] */;
|
706
|
-
}
|
707
|
-
SCSS
|
708
|
-
.magic-box {@content: "gold"; content: @content}
|
709
|
-
.foo {content: .magic-box[@content]}
|
710
|
-
LESS
|
711
|
-
end
|
712
|
-
|
713
|
-
private
|
714
|
-
|
715
|
-
def assert_renders(scss, less)
|
716
|
-
assert_equal(scss, Less::Engine.new(less).to_tree.to_sass_tree.to_scss)
|
717
|
-
end
|
718
|
-
|
719
|
-
# Necessary because Less can't import absolute files
|
720
|
-
def relative_path_to(file)
|
721
|
-
file = Pathname.new(file)
|
722
|
-
pwd = file.absolute? ? Dir.pwd : "."
|
723
|
-
file.relative_path_from(Pathname.new(pwd))
|
724
|
-
end
|
725
|
-
end
|
726
|
-
|
727
|
-
rescue LoadError => e
|
728
|
-
unless defined?(Gem)
|
729
|
-
begin
|
730
|
-
require 'rubygems'
|
731
|
-
retry
|
732
|
-
rescue Exception
|
733
|
-
end
|
734
|
-
end
|
735
|
-
puts "\nCouldn't require less, skipping some tests."
|
736
|
-
end
|