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 @use member usage and load error tests #1349

Merged
merged 14 commits into from
Feb 26, 2019
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
201 changes: 201 additions & 0 deletions spec/core_functions/function_exists.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
<===> global/input.scss
@function global-function() {@return null}

a {b: function-exists(global-function)}

<===> global/output.css
a {
b: true;
}

<===>
================================================================================
<===> local/options.yml
---
:todo:
- libsass # sass/libsass#2831

<===> local/input.scss
a {
@function local-function() {@return null}
b: function-exists(local-function);
}

<===> local/output.css
a {
b: true;
}

<===>
================================================================================
<===> dash_insensitive/input.scss
@function global-function() {@return null}

a {b: function-exists(global_function)}

<===> dash_insensitive/output.css
a {
b: true;
}

<===>
================================================================================
<===> through_import/input.scss
@import "other";
a {b: function-exists(global-function)}

<===> through_import/other.scss
@function global-function() {@return null}

<===> through_import/output.css
a {
b: true;
}

<===>
================================================================================
<===> through_use/options.yml
---
:todo:
- libsass # sass/libsass#2807
:ignore_for:
- ruby-sass

<===> through_use/input.scss
@use "other" as *;
a {b: function-exists(global-function)}

<===> through_use/other.scss
@function global-function() {@return null}

<===> through_use/output.css
a {
b: true;
}

<===>
================================================================================
<===> non_existent/input.scss
a {
b: function-exists(non-existent);
}

<===> non_existent/output.css
a {
b: false;
}

<===>
================================================================================
<===> keyword/input.scss
a {b: function-exists($name: foo)}

<===> keyword/output.css
a {
b: false;
}

<===>
================================================================================
<===> error/argument/type/input.scss
a {b: function-exists(12px)}

<===> error/argument/type/error
Error: $name: 12px is not a string.
,
1 | a {b: function-exists(12px)}
| ^^^^^^^^^^^^^^^^^^^^^
'
/sass/spec/core_functions/function_exists/error/argument/type/input.scss 1:7 root stylesheet

<===> error/argument/type/error-ruby-sass
Error: $name: 12px is not a string for `function-exists'
on line 1 of /sass/spec/core_functions/function_exists/error/argument/type/input.scss
Use --trace for backtrace.

<===> error/argument/type/error-libsass
Error: $name: 12px is not a string for `function-exists'
on line 1:7 of /sass/spec/core_functions/function_exists/error/argument/type/input.scss, in function `function-exists`
from line 1:7 of /sass/spec/core_functions/function_exists/error/argument/type/input.scss
>> a {b: function-exists(12px)}

------^

<===>
================================================================================
<===> error/argument/too_few/input.scss
a {b: function-exists()}

<===> error/argument/too_few/error
Error: Missing argument $name.
,
1 | a {b: function-exists()}
| ^^^^^^^^^^^^^^^^^
'
/sass/spec/core_functions/function_exists/error/argument/too_few/input.scss 1:7 root stylesheet

<===> error/argument/too_few/error-ruby-sass
Error: wrong number of arguments (0 for 1) for `function-exists'
on line 1 of /sass/spec/core_functions/function_exists/error/argument/too_few/input.scss
Use --trace for backtrace.

<===> error/argument/too_few/error-libsass
Error: Function function-exists is missing argument $name.
on line 1 of /sass/spec/core_functions/function_exists/error/argument/too_few/input.scss
>> a {b: function-exists()}

------^

<===>
================================================================================
<===> error/argument/too_many/input.scss
a {b: function-exists(foo, bar)}

<===> error/argument/too_many/error
Error: Only 1 argument allowed, but 2 were passed.
,
1 | a {b: function-exists(foo, bar)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
'
/sass/spec/core_functions/function_exists/error/argument/too_many/input.scss 1:7 root stylesheet

<===> error/argument/too_many/error-ruby-sass
Error: wrong number of arguments (2 for 1) for `function-exists'
on line 1 of /sass/spec/core_functions/function_exists/error/argument/too_many/input.scss
Use --trace for backtrace.

<===> error/argument/too_many/error-libsass
Error: wrong number of arguments (2 for 1) for `function-exists'
on line 1:7 of /sass/spec/core_functions/function_exists/error/argument/too_many/input.scss
>> a {b: function-exists(foo, bar)}

------^

<===>
================================================================================
<===> conflict/options.yml
---
:todo:
- libsass # sass/libsass#2807
:ignore_for:
- ruby-sass

<===> conflict/input.scss
@use "other1" as *;
@use "other2" as *;

a {b: function-exists(member)}

<===> conflict/other1.scss
@function member() {@return from other1}

<===> conflict/other2.scss
@function member() {@return from other2}

<===> conflict/error
Error: Multiple global modules have a function named "member".
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where this error is coming from in dart-sass but could it include the names of the modules that have conflicting functions? It would make it easier to track down when many modules are used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,
4 | a {b: function-exists(member)}
| ^^^^^^^^^^^^^^^^^^^^^^^
'
/sass/spec/core_functions/function_exists/conflict/input.scss 4:7 root stylesheet
19 changes: 0 additions & 19 deletions spec/core_functions/get-function/basic.hrx

This file was deleted.

15 changes: 0 additions & 15 deletions spec/core_functions/get-function/builtins.hrx

This file was deleted.

19 changes: 0 additions & 19 deletions spec/core_functions/get-function/css-fn-reference.hrx

This file was deleted.

29 changes: 0 additions & 29 deletions spec/core_functions/get-function/equality.hrx

This file was deleted.

24 changes: 0 additions & 24 deletions spec/core_functions/get-function/errors/function-exists.hrx

This file was deleted.

15 changes: 0 additions & 15 deletions spec/core_functions/get-function/errors/illegal-argument.hrx

This file was deleted.

21 changes: 0 additions & 21 deletions spec/core_functions/get-function/errors/illegal-kwarg.hrx

This file was deleted.

17 changes: 0 additions & 17 deletions spec/core_functions/get-function/errors/math/division.hrx

This file was deleted.

15 changes: 0 additions & 15 deletions spec/core_functions/get-function/errors/non-existent.hrx

This file was deleted.

Loading