Skip to content

Commit 88258ae

Browse files
authored
Tests for fix to crash when mixing @import and @use (#2060)
* Tests for fix to crash when mixing @import and @use * Add tests for meta.load-css * Add tests for top-level imports with top-level declarations
1 parent 45b5cc4 commit 88258ae

File tree

5 files changed

+322
-5
lines changed

5 files changed

+322
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ X. Exit testing.
277277
278278
[implementation-specific expectations]: #implementation-specific-expectations
279279
280-
Any option can also be applied to all future occurences of that type of failure
280+
Any option can also be applied to all future occurrences of that type of failure
281281
by adding `!` after it. For example, if you want to mark *all* failing specs as
282282
`:todo` for the current implementation you'd type `I!`.
283283

spec/core_functions/meta/load_css/error/load.hrx

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,71 @@ Error: Module loop: input.scss is already being loaded.
3434
'
3535
_other.scss 2:1 load-css()
3636
input.scss 2:1 root stylesheet
37+
38+
<===>
39+
================================================================================
40+
<===> top_level_include_declaration/input.scss
41+
@use "sass:meta";
42+
@include meta.load-css("upstream");
43+
44+
<===> top_level_include_declaration/_upstream.scss
45+
@mixin a { b: c }
46+
@include a;
47+
48+
<===> top_level_include_declaration/error
49+
Error: Declarations may only be used within style rules.
50+
,
51+
1 | @mixin a { b: c }
52+
| ^^^^^
53+
'
54+
_upstream.scss 1:12 a()
55+
_upstream.scss 2:1 load-css()
56+
input.scss 2:1 root stylesheet
57+
58+
<===>
59+
================================================================================
60+
<===> nested/without_use/input.scss
61+
@use 'sass:meta';
62+
.a {
63+
@include meta.load-css('upstream');
64+
}
65+
66+
<===> nested/without_use/_upstream.scss
67+
@mixin b { c: d }
68+
@include b;
69+
70+
<===> nested/without_use/error
71+
Error: Declarations may only be used within style rules.
72+
,
73+
1 | @mixin b { c: d }
74+
| ^^^^^
75+
'
76+
_upstream.scss 1:12 b()
77+
_upstream.scss 2:1 load-css()
78+
input.scss 3:3 root stylesheet
79+
80+
<===>
81+
================================================================================
82+
<===> nested/with_use/input.scss
83+
@use 'sass:meta';
84+
.a {
85+
@include meta.load-css('midstream');
86+
}
87+
88+
<===> nested/with_use/_midstream.scss
89+
@use 'upstream';
90+
@mixin b { c: d }
91+
@include b;
92+
93+
<===> nested/with_use/_upstream.scss
94+
// Intentionally empty.
95+
96+
<===> nested/with_use/error
97+
Error: Declarations may only be used within style rules.
98+
,
99+
2 | @mixin b { c: d }
100+
| ^^^^^
101+
'
102+
_midstream.scss 2:12 b()
103+
_midstream.scss 3:1 load-css()
104+
input.scss 3:3 root stylesheet
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<===> include/input.scss
2+
3+
@import 'upstream';
4+
5+
6+
<===> include/_upstream.scss
7+
@mixin a { b: c }
8+
@include a;
9+
10+
<===> include/error
11+
DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
12+
13+
More info and automated migrator: https://sass-lang.com/d/import
14+
15+
,
16+
2 | @import 'upstream';
17+
| ^^^^^^^^^^
18+
'
19+
input.scss 2:9 root stylesheet
20+
21+
Error: Declarations may only be used within style rules.
22+
,
23+
1 | @mixin a { b: c }
24+
| ^^^^^
25+
'
26+
_upstream.scss 1:12 a()
27+
_upstream.scss 2:1 @import
28+
input.scss 2:9 root stylesheet
29+
30+
<===>
31+
================================================================================
32+
<===> root/input.scss
33+
@import 'upstream';
34+
35+
<===> root/_upstream.scss
36+
a: b;
37+
38+
<===> root/error
39+
DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
40+
41+
More info and automated migrator: https://sass-lang.com/d/import
42+
43+
,
44+
1 | @import 'upstream';
45+
| ^^^^^^^^^^
46+
'
47+
input.scss 1:9 root stylesheet
48+
49+
Error: expected "{".
50+
,
51+
1 | a: b;
52+
| ^
53+
'
54+
_upstream.scss 1:5 @import
55+
input.scss 1:9 root stylesheet
56+
57+
<===>
58+
================================================================================
59+
<===> parent_selector/input.scss
60+
@import 'upstream';
61+
62+
<===> parent_selector/_upstream.scss
63+
&{ a: b; }
64+
65+
<===> parent_selector/error
66+
DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
67+
68+
More info and automated migrator: https://sass-lang.com/d/import
69+
70+
,
71+
1 | @import 'upstream';
72+
| ^^^^^^^^^^
73+
'
74+
input.scss 1:9 root stylesheet
75+
76+
Error: Top-level selectors may not contain the parent selector "&".
77+
,
78+
1 | &{ a: b; }
79+
| ^
80+
'
81+
_upstream.scss 1:1 @import
82+
input.scss 1:9 root stylesheet

spec/directives/import/nested.hrx

Lines changed: 134 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ More info and automated migrator: https://sass-lang.com/d/import
211211
/* Y */
212212

213213
<===> with_comment/_b.scss
214-
@import 'a'
214+
@import 'a';
215215

216216
<===> with_comment/_c.scss
217-
@import 'a'
217+
@import 'a';
218218

219219
<===> with_comment/output.css
220220
/* Y */
@@ -246,7 +246,7 @@ DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be remo
246246
More info and automated migrator: https://sass-lang.com/d/import
247247

248248
,
249-
1 | @import 'a'
249+
1 | @import 'a';
250250
| ^^^
251251
'
252252
_b.scss 1:9 @import
@@ -257,8 +257,138 @@ DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be remo
257257
More info and automated migrator: https://sass-lang.com/d/import
258258

259259
,
260-
1 | @import 'a'
260+
1 | @import 'a';
261261
| ^^^
262262
'
263263
_c.scss 1:9 @import
264264
input.scss 2:9 root stylesheet
265+
266+
<===>
267+
================================================================================
268+
<===> top_level_declaration/README.md
269+
These are regression tests for https://github.com/sass/dart-sass/issues/2588.
270+
271+
<===>
272+
================================================================================
273+
<===> top_level_declaration/include/without_use/input.scss
274+
.a {
275+
@import 'upstream';
276+
}
277+
278+
<===> top_level_declaration/include/without_use/_upstream.scss
279+
@mixin b { c: d }
280+
@include b;
281+
282+
<===> top_level_declaration/include/without_use/output.css
283+
.a {
284+
c: d;
285+
}
286+
287+
<===> top_level_declaration/include/without_use/warning
288+
DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
289+
More info and automated migrator: https://sass-lang.com/d/import
290+
,
291+
2 | @import 'upstream';
292+
| ^^^^^^^^^^
293+
'
294+
input.scss 2:11 root stylesheet
295+
296+
<===>
297+
================================================================================
298+
<===> top_level_declaration/include/with_use/input.scss
299+
.a {
300+
@import 'midstream';
301+
}
302+
303+
<===> top_level_declaration/include/with_use/_midstream.scss
304+
@use 'upstream';
305+
@mixin b { c: d }
306+
@include b;
307+
308+
<===> top_level_declaration/include/with_use/_upstream.scss
309+
// Intentionally empty.
310+
311+
<===> top_level_declaration/include/with_use/output.css
312+
.a {
313+
c: d;
314+
}
315+
316+
<===> top_level_declaration/include/with_use/warning
317+
DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
318+
319+
More info and automated migrator: https://sass-lang.com/d/import
320+
321+
,
322+
2 | @import 'midstream';
323+
| ^^^^^^^^^^^
324+
'
325+
input.scss 2:11 root stylesheet
326+
327+
<===>
328+
================================================================================
329+
<===> top_level_declaration/include/with_use_two_levels_deep/input.scss
330+
.a {
331+
@import 'midstream1';
332+
}
333+
334+
<===> top_level_declaration/include/with_use_two_levels_deep/_midstream1.scss
335+
@import 'midstream2';
336+
337+
<===> top_level_declaration/include/with_use_two_levels_deep/_midstream2.scss
338+
@use 'upstream';
339+
@mixin b { c: d }
340+
@include b;
341+
342+
<===> top_level_declaration/include/with_use_two_levels_deep/_upstream.scss
343+
// Intentionally empty.
344+
345+
<===> top_level_declaration/include/with_use_two_levels_deep/output.css
346+
.a {
347+
c: d;
348+
}
349+
350+
<===> top_level_declaration/include/with_use_two_levels_deep/warning
351+
DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
352+
353+
More info and automated migrator: https://sass-lang.com/d/import
354+
355+
,
356+
2 | @import 'midstream1';
357+
| ^^^^^^^^^^^^
358+
'
359+
input.scss 2:11 root stylesheet
360+
361+
DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
362+
363+
More info and automated migrator: https://sass-lang.com/d/import
364+
365+
,
366+
1 | @import 'midstream2';
367+
| ^^^^^^^^^^^^
368+
'
369+
_midstream1.scss 1:9 @import
370+
input.scss 2:11 root stylesheet
371+
372+
<===>
373+
================================================================================
374+
<===> top_level_declaration/parent_selector/input.scss
375+
.a {
376+
@import 'upstream';
377+
}
378+
379+
<===> top_level_declaration/parent_selector/_upstream.scss
380+
& { b: c }
381+
382+
<===> top_level_declaration/parent_selector/output.css
383+
.a {
384+
b: c;
385+
}
386+
387+
<===> top_level_declaration/parent_selector/warning
388+
DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
389+
More info and automated migrator: https://sass-lang.com/d/import
390+
,
391+
2 | @import 'upstream';
392+
| ^^^^^^^^^^
393+
'
394+
input.scss 2:11 root stylesheet

spec/directives/use/error/load.hrx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,40 @@ Error: There's already a module with namespace "other".
328328
| ^^^^^^^^^^^^^^^^^^^^^^ new @use
329329
'
330330
input.scss 2:1 root stylesheet
331+
332+
<===>
333+
================================================================================
334+
<===> top_level_include_declaration/upstream_mixin/input.scss
335+
@use "upstream";
336+
@include upstream.a;
337+
338+
<===> top_level_include_declaration/upstream_mixin/_upstream.scss
339+
@mixin a { b: c }
340+
341+
<===> top_level_include_declaration/upstream_mixin/error
342+
Error: Declarations may only be used within style rules.
343+
,
344+
1 | @mixin a { b: c }
345+
| ^^^^^
346+
'
347+
_upstream.scss 1:12 a()
348+
input.scss 2:1 root stylesheet
349+
350+
<===>
351+
================================================================================
352+
<===> top_level_include_declaration/input_mixin/input.scss
353+
@use 'upstream';
354+
@mixin a { b: c }
355+
@include a;
356+
357+
<===> top_level_include_declaration/input_mixin/_upstream.scss
358+
// Intentionally empty.
359+
360+
<===> top_level_include_declaration/input_mixin/error
361+
Error: Declarations may only be used within style rules.
362+
,
363+
2 | @mixin a { b: c }
364+
| ^^^^^
365+
'
366+
input.scss 2:12 a()
367+
input.scss 3:1 root stylesheet

0 commit comments

Comments
 (0)