Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for bogus combinators #1803

Merged
merged 7 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib-js/spec-directory/virtual-directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ export default class VirtualDirectory extends SpecDirectory {
parentOpts?: SpecOptions
): Promise<VirtualDirectory> {
const stream = fs.createReadStream(hrxPath, {encoding: 'utf-8'});
const archive = await archiveFromStream(stream);
let archive;
try {
archive = await archiveFromStream(stream);
} catch (error: unknown) {
throw new Error(`Error parsing ${hrxPath}: ${error}`);
}

const {dir, name} = path.parse(hrxPath);
return new VirtualDirectory(
path.resolve(dir, name),
Expand Down
97 changes: 94 additions & 3 deletions spec/core_functions/selector/append.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,56 @@ a {
structure: true;
}

<===>
================================================================================
<===> combinator/initial_leading/input.scss
a {b: selector-append("> c", "d")}

<===> combinator/initial_leading/output.css
a {
b: > cd;
}

<===>
================================================================================
<===> combinator/final_trailing/input.scss
a {b: selector-append("c", "d ~")}

<===> combinator/final_trailing/output.css
a {
b: cd ~;
}

<===>
================================================================================
<===> combinator/multiple/middle/input.scss
a {b: selector-append("c > > d", "e")}

<===> combinator/multiple/middle/output.css
a {
b: c > > de;
}

<===>
================================================================================
<===> combinator/multiple/initial_leading/input.scss
a {b: selector-append("~ ~ c", "d")}

<===> combinator/multiple/initial_leading/output.css
a {
b: ~ ~ cd;
}

<===>
================================================================================
<===> combinator/multiple/final_trailing/input.scss
a {b: selector-append("c", "d + >")}

<===> combinator/multiple/final_trailing/output.css
a {
b: cd + >;
}

<===>
================================================================================
<===> error/universal/options.yml
Expand All @@ -139,25 +189,66 @@ Error: Can't append * to .c.

<===>
================================================================================
<===> error/leading_combinator/input.scss
<===> error/combinator/leading/input.scss
a {b: selector-append(".c", "> .d")}

<===> error/leading_combinator/error
<===> error/combinator/leading/error
Error: Can't append > .d to .c.
,
1 | a {b: selector-append(".c", "> .d")}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===> error/leading_combinator/error-libsass
<===> error/combinator/leading/error-libsass
Error: Can't append "> .d" to ".c" for `selector-append'
on line 1:7 of input.scss, in function `selector-append`
from line 1:7 of input.scss
>> a {b: selector-append(".c", "> .d")}

------^

<===>
================================================================================
<===> error/combinator/trailing/input.scss
a {b: selector-append(".c ~", ".d")}

<===> error/combinator/trailing/error
Error: Parent ".c ~" is incompatible with this selector.
,
1 | a {b: selector-append(".c ~", ".d")}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===> error/combinator/trailing/error-libsass
Error: Invalid parent selector for "&.d": "&.c ~"
on line 1:7 of input.scss
>> a {b: selector-append(".c ~", ".d")}

----------------------------------^

<===>
================================================================================
<===> error/combinator/only/input.scss
a {b: selector-append(".c", ">", ".d")}

<===> error/combinator/only/error
Error: Can't append > to .c.
,
1 | a {b: selector-append(".c", ">", ".d")}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===> error/combinator/only/error-libsass
Error: Can't append ">" to ".c" for `selector-append'
on line 1:7 of input.scss, in function `selector-append`
from line 1:7 of input.scss
>> a {b: selector-append(".c", ">", ".d")}

------^

<===>
================================================================================
<===> error/namespace/options.yml
Expand Down
87 changes: 0 additions & 87 deletions spec/core_functions/selector/extend/complex.hrx

This file was deleted.

45 changes: 45 additions & 0 deletions spec/core_functions/selector/extend/complex/combinator_only.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<===> selector/input.scss
a {b: selector-extend("+", ".c", ".d")}

<===> selector/output.css
a {
b: +;
}

<===> selector/warning
DEPRECATION WARNING: $selector: + is not valid CSS.
This will be an error in Dart Sass 2.0.0.

More info: https://sass-lang.com/d/bogus-combinators

,
1 | a {b: selector-extend("+", ".c", ".d")}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===> selector/warning-libsass

<===>
================================================================================
<===> extender/input.scss
a {b: selector-extend(".c", ".c", ">")}

<===> extender/output.css
a {
b: .c, >;
}

<===> extender/warning
DEPRECATION WARNING: $extender: > is not valid CSS.
This will be an error in Dart Sass 2.0.0.

More info: https://sass-lang.com/d/bogus-combinators

,
1 | a {b: selector-extend(".c", ".c", ">")}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 1:7 root stylesheet

<===> extender/warning-libsass
Loading