Skip to content

Commit

Permalink
Add tests for trailing commas after parameters and arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Dec 12, 2024
1 parent 9b9002c commit 70f02f6
Show file tree
Hide file tree
Showing 2 changed files with 455 additions and 14 deletions.
250 changes: 236 additions & 14 deletions spec/callable/arguments.hrx
Original file line number Diff line number Diff line change
@@ -1,3 +1,125 @@
<===> mixin/_utils.scss
@use 'sass:meta';

@mixin a($args...) {
b {
positional: meta.inspect($args);
named: meta.inspect(meta.keywords($args));
}
}

<===>
================================================================================
<===> mixin/trailing_comma/positional/input.scss
@use 'callable/arguments/mixin/utils';
@include utils.a(1, );

<===> mixin/trailing_comma/positional/output.css
b {
positional: (1,);
named: ();
}

<===>
================================================================================
<===> mixin/trailing_comma/named/alone/input.scss
@use 'callable/arguments/mixin/utils';
@include utils.a($c: 1, );

<===> mixin/trailing_comma/named/alone/output.css
b {
positional: ();
named: (c: 1);
}

<===>
================================================================================
<===> mixin/trailing_comma/named/after_positional/input.scss
@use 'callable/arguments/mixin/utils';
@include utils.a(1, $c: 2, );

<===> mixin/trailing_comma/named/after_positional/output.css
b {
positional: (1,);
named: (c: 2);
}

<===>
================================================================================
<===> mixin/trailing_comma/rest/alone/input.scss
@use 'callable/arguments/mixin/utils';
@include utils.a(1..., );

<===> mixin/trailing_comma/rest/alone/output.css
b {
positional: (1,);
named: ();
}

<===>
================================================================================
<===> mixin/trailing_comma/rest/after_positional/input.scss
@use 'callable/arguments/mixin/utils';
@include utils.a(1, 2..., );

<===> mixin/trailing_comma/rest/after_positional/output.css
b {
positional: 1, 2;
named: ();
}

<===>
================================================================================
<===> mixin/trailing_comma/rest/after_named/input.scss
@use 'callable/arguments/mixin/utils';
@include utils.a($c: 1, 2..., );

<===> mixin/trailing_comma/rest/after_named/output.css
b {
positional: (2,);
named: (c: 1);
}

<===>
================================================================================
<===> mixin/trailing_comma/rest/after_both/input.scss
@use 'callable/arguments/mixin/utils';
@include utils.a(1, $c: 2, 3..., );

<===> mixin/trailing_comma/rest/after_both/output.css
b {
positional: 1, 3;
named: (c: 2);
}

<===>
================================================================================
<===> mixin/trailing_comma/keyword_rest/input.scss
@use 'callable/arguments/mixin/utils';
@include utils.a(1..., (c: 2)..., );

<===> mixin/trailing_comma/keyword_rest/output.css
b {
positional: (1,);
named: (c: 2);
}

<===>
================================================================================
<===> mixin/error/comma_only/input.scss
@use 'callable/arguments/mixin/utils';
@include utils.a( , );

<===> mixin/error/comma_only/error
Error: expected ")".
,
2 | @include utils.a( , );
| ^
'
input.scss 2:19 root stylesheet

<===>
================================================================================
<===> mixin/error/positional_after_named/input.scss
@mixin a($b, $c) {}

Expand Down Expand Up @@ -41,6 +163,120 @@ Error: Duplicate argument.
'
input.scss 3:21 root stylesheet

<===>
================================================================================
<===> function/_utils.scss
@use 'sass:meta';

@function a($args...) {
@return meta.inspect((
positional: $args,
named: meta.keywords($args),
));
}

<===>
================================================================================
<===> function/trailing_comma/positional/input.scss
@use 'callable/arguments/function/utils';
a {b: utils.a(1, )}

<===> function/trailing_comma/positional/output.css
a {
b: (positional: ((1,)), named: ());
}

<===>
================================================================================
<===> function/trailing_comma/named/alone/input.scss
@use 'callable/arguments/function/utils';
a {b: utils.a($c: 1, )}

<===> function/trailing_comma/named/alone/output.css
a {
b: (positional: (()), named: (c: 1));
}

<===>
================================================================================
<===> function/trailing_comma/named/after_positional/input.scss
@use 'callable/arguments/function/utils';
a {b: utils.a(1, $c: 2, )}

<===> function/trailing_comma/named/after_positional/output.css
a {
b: (positional: ((1,)), named: (c: 2));
}

<===>
================================================================================
<===> function/trailing_comma/rest/alone/input.scss
@use 'callable/arguments/function/utils';
a {b: utils.a(1..., )}

<===> function/trailing_comma/rest/alone/output.css
a {
b: (positional: ((1,)), named: ());
}

<===>
================================================================================
<===> function/trailing_comma/rest/after_positional/input.scss
@use 'callable/arguments/function/utils';
a {b: utils.a(1, 2..., )}

<===> function/trailing_comma/rest/after_positional/output.css
a {
b: (positional: (1, 2), named: ());
}

<===>
================================================================================
<===> function/trailing_comma/rest/after_named/input.scss
@use 'callable/arguments/function/utils';
a {b: utils.a($c: 1, 2..., )}

<===> function/trailing_comma/rest/after_named/output.css
a {
b: (positional: ((2,)), named: (c: 1));
}

<===>
================================================================================
<===> function/trailing_comma/rest/after_both/input.scss
@use 'callable/arguments/function/utils';
a {b: utils.a(1, $c: 2, 3..., )}

<===> function/trailing_comma/rest/after_both/output.css
a {
b: (positional: (1, 3), named: (c: 2));
}

<===>
================================================================================
<===> function/trailing_comma/keyword_rest/input.scss
@use 'callable/arguments/function/utils';
a {b: utils.a(1..., (c: 2)..., )}

<===> function/trailing_comma/keyword_rest/output.css
a {
b: (positional: ((1,)), named: (c: 2));
}

<===>
================================================================================
<===> function/error/comma_only/input.scss
@use 'callable/arguments/function/utils';
a {b: utils.a( , )};

<===> function/error/comma_only/error
Error: expected ")".
,
2 | a {b: utils.a( , )};
| ^
'
input.scss 2:16 root stylesheet

<===>
================================================================================
<===> function/error/positional_after_named/input.scss
Expand Down Expand Up @@ -95,17 +331,3 @@ Error: expected ")".
| ^
'
input.sass 5:8 root stylesheet

<===>
================================================================================
<===> function/arguments/sass/input.sass
@function a($b, $c)
@return d

e
f: a(g, h)

<===> function/arguments/sass/output.css
e {
f: d;
}
Loading

0 comments on commit 70f02f6

Please sign in to comment.