From ad782cdca84077c04435499f9a3e34676278be44 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 25 Aug 2023 03:58:02 +0000 Subject: [PATCH] add tests for first class mixins --- spec/core_functions/meta/accepts_content.hrx | 40 ++ spec/core_functions/meta/apply.hrx | 1 + .../core_functions/meta/get_mixin/content.hrx | 1 + .../meta/get_mixin/different_module.hrx | 137 +++++++ .../meta/get_mixin/equality.hrx | 74 ++++ spec/core_functions/meta/get_mixin/error.hrx | 262 ++++++++++++ spec/core_functions/meta/get_mixin/meta.hrx | 21 + .../meta/get_mixin/same_module.hrx | 71 ++++ spec/core_functions/meta/get_mixin/scope.hrx | 47 +++ spec/core_functions/meta/module_mixins.hrx | 372 ++++++++++++++++++ spec/core_functions/meta/type_of.hrx | 12 + 11 files changed, 1038 insertions(+) create mode 100644 spec/core_functions/meta/accepts_content.hrx create mode 100644 spec/core_functions/meta/apply.hrx create mode 100644 spec/core_functions/meta/get_mixin/content.hrx create mode 100644 spec/core_functions/meta/get_mixin/different_module.hrx create mode 100644 spec/core_functions/meta/get_mixin/equality.hrx create mode 100644 spec/core_functions/meta/get_mixin/error.hrx create mode 100644 spec/core_functions/meta/get_mixin/meta.hrx create mode 100644 spec/core_functions/meta/get_mixin/same_module.hrx create mode 100644 spec/core_functions/meta/get_mixin/scope.hrx create mode 100644 spec/core_functions/meta/module_mixins.hrx diff --git a/spec/core_functions/meta/accepts_content.hrx b/spec/core_functions/meta/accepts_content.hrx new file mode 100644 index 0000000000..89b5b7b6d7 --- /dev/null +++ b/spec/core_functions/meta/accepts_content.hrx @@ -0,0 +1,40 @@ +<===> accepts/direct-child/input.scss +@use "sass:meta"; + +@mixin foo() { + @content; +} + +a {b: meta.accepts-content(meta.get-mixin("foo"))} + +<===> accepts/direct-child/output.css +a { + b: true; +} + +<===> accepts/nested-child/input.scss +@use "sass:meta"; + +@mixin foo() { + @if false { + @content; + } +} + +a {b: meta.accepts-content(meta.get-mixin("foo"))} + +<===> accepts/nested-child/output.css +a { + b: true; +} + +<===> doesnt-accept/empty/input.scss +@use "sass:meta"; +@mixin foo() {} + +a {b: meta.accepts-content(meta.get-mixin("foo"))} + +<===> doesnt-accept/empty/output.css +a { + b: false; +} diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx new file mode 100644 index 0000000000..8826b5238d --- /dev/null +++ b/spec/core_functions/meta/apply.hrx @@ -0,0 +1 @@ +// todo \ No newline at end of file diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx new file mode 100644 index 0000000000..8826b5238d --- /dev/null +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -0,0 +1 @@ +// todo \ No newline at end of file diff --git a/spec/core_functions/meta/get_mixin/different_module.hrx b/spec/core_functions/meta/get_mixin/different_module.hrx new file mode 100644 index 0000000000..22fb6a18b1 --- /dev/null +++ b/spec/core_functions/meta/get_mixin/different_module.hrx @@ -0,0 +1,137 @@ +<===> +================================================================================ +<===> defined/input.scss +@use "sass:meta"; +@use "foo"; +a {@include meta.apply(meta.get-mixin("foo", $module: "color"), #abcdef)} + +<===> chosen_prefix/foo.scss +@mixin foo($color) { + b: red($color) +} + +<===> defined/output.css +a { + b: 171; +} + +<===> +================================================================================ +<===> chosen_prefix/input.scss +@use "sass:meta"; +@use "foo" as a; +b {@include meta.apply(meta.get-mixin("foo", $module: "a"), #abcdef)} + +<===> chosen_prefix/foo.scss +@mixin foo($color) { + c: red($color) +} + +<===> chosen_prefix/output.css +b { + c: 171; +} + +<===> +================================================================================ +<===> through_use/input.scss +@use "sass:meta"; +@use "other" as *; +a {@include meta.apply(meta.get-mixin(add-two), 10)} + +<===> through_use/other.scss +@mixin add-two($v) {b: $v + 2} + +<===> through_use/output.css +a { + b: 12; +} + +<===> +================================================================================ +<===> through_forward/bare/input.scss +@use "sass:meta"; +@use "midstream" as *; +a {@include meta.apply(meta.get-mixin(c))} + +<===> through_forward/bare/_midstream.scss +@forward "upstream"; + +<===> through_forward/bare/_upstream.scss +@mixin c() {b: c} + +<===> through_forward/bare/output.css +a { + b: c; +} + +<===> +================================================================================ +<===> through_forward/as/input.scss +@use "sass:meta"; +@use "midstream" as *; +a {@include meta.apply(meta.get-mixin(c-d))} + +<===> through_forward/as/_midstream.scss +@forward "upstream" as c-*; + +<===> through_forward/as/_upstream.scss +@mixin d() {b: d} + +<===> through_forward/as/output.css +a { + b: d; +} + +<===> +================================================================================ +<===> through_forward/show/input.scss +@use "sass:meta"; +@use "midstream" as *; +a {@include meta.apply(meta.get-mixin(c))} + +<===> through_forward/show/_midstream.scss +@forward "upstream" show c; + +<===> through_forward/show/_upstream.scss +@mixin c() {b: c} + +<===> through_forward/show/output.css +a { + b: c; +} + +<===> +================================================================================ +<===> through_forward/hide/input.scss +@use "sass:meta"; +@use "midstream" as *; +a {@include meta.apply(meta.get-mixin(d))} + +<===> through_forward/hide/_midstream.scss +@forward "upstream" hide c; + +<===> through_forward/hide/_upstream.scss +@mixin d() {b: d} + +<===> through_forward/hide/output.css +a { + b: d; +} + +<===> +================================================================================ +<===> named/input.scss +@use "sass:meta"; +@use "foo"; +a {@include meta.apply(meta.get-mixin($name: "foo", $module: "color"), #abcdef)} + +<===> named/foo.scss +@mixin foo($color) { + b: red($color) +} + +<===> named/output.css +a { + b: 171; +} diff --git a/spec/core_functions/meta/get_mixin/equality.hrx b/spec/core_functions/meta/get_mixin/equality.hrx new file mode 100644 index 0000000000..81df3a423f --- /dev/null +++ b/spec/core_functions/meta/get_mixin/equality.hrx @@ -0,0 +1,74 @@ +<===> same_value/input.scss +@use "sass:meta"; +@mixin foo() {} +$a: meta.get-mixin(foo); +a {b: $a == $a} + +<===> same_value/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> built_in/same/input.scss +@use "sass:meta"; +a {b: meta.get-mixin(load-css, meta) == meta.get-mixin(load-css, meta)} + +<===> built_in/same/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> built_in/different/input.scss +@use "sass:meta"; +@mixin foo() {} +a {b: meta.get-mixin(load-css, meta) == meta.get-mixin(foo)} + +<===> built_in/different/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> user_defined/same/input.scss +@use "sass:meta"; +@mixin user-defined() {} +a {b: meta.get-mixin(user-defined) == meta.get-mixin(user-defined)} + +<===> user_defined/same/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> user_defined/different/input.scss +@use "sass:meta"; +@mixin user-defined-1() {} +@mixin user-defined-2() {} +a {b: meta.get-mixin(user-defined-1) == meta.get-mixin(user-defined-2)} + +<===> user_defined/different/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> user_defined/redefined/input.scss +@use "sass:meta"; +@mixin user-defined() {} +$first-reference: meta.get-mixin(user-defined); + +@mixin user-defined() {} +$second-reference: meta.get-mixin(user-defined); +a {b: $first-reference == $second-reference} + +<===> user_defined/redefined/output.css +a { + b: false; +} diff --git a/spec/core_functions/meta/get_mixin/error.hrx b/spec/core_functions/meta/get_mixin/error.hrx new file mode 100644 index 0000000000..dd64231067 --- /dev/null +++ b/spec/core_functions/meta/get_mixin/error.hrx @@ -0,0 +1,262 @@ +<===> argument/type/name/input.scss +@use "sass:meta"; +a {b: meta.get-mixin(2px)} + +<===> argument/type/name/error +Error: $name: 2px is not a string. + , +1 | a {b: meta.get-mixin(2px)} + | ^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> argument/type/module/input.scss +@use "sass:meta"; +a {b: meta.get-mixin(c, $module: 1)} + +<===> argument/type/module/error +Error: $module: 1 is not a string. + , +1 | a {b: meta.get-mixin(c, $module: 1)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> argument/mixin_ref/input.scss +@use "sass:meta"; +@mixin foo() {} + +$foo-ref: meta.get-mixin(foo); +a {b: meta.get-mixin($foo-ref)} + +<===> argument/mixin_ref/error +Error: $name: get-mixin("foo") is not a string. + , +6 | a {b: meta.get-mixin($foo-ref)} + | ^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 6:7 root stylesheet + +<===> +================================================================================ +<===> argument/too_few/input.scss +@use "sass:meta"; +a {b: meta.get-mixin()} + +<===> argument/too_few/error +Error: Missing argument $name. + ,--> input.scss +1 | a {b: meta.get-mixin()} + | ^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @function get-mixin($name, $module: null) { + | ================================== declaration + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> argument/too_many/input.scss +@use "sass:meta"; +a {b: meta.get-mixin(c, true, d, e)} + +<===> argument/too_many/error +Error: Only 3 arguments allowed, but 4 were passed. + ,--> input.scss +1 | a {b: meta.get-mixin(c, true, d, e)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @function get-mixin($name, $module: null) { + | ================================== declaration + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> non_existent/input.scss +@use "sass:meta"; +a {b: meta.get-mixin(does-not-exist)} + +<===> non_existent/error +Error: Mixin not found: does-not-exist + , +1 | a {b: meta.get-mixin(does-not-exist)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> through_forward/show/input.scss +@use "sass:meta"; +@use "midstream" as *; +a { + @include meta.apply(meta.get-mixin(d)); +} + +<===> through_forward/show/_midstream.scss +@forward "upstream" show c; + +<===> through_forward/show/_upstream.scss +@mixin d() {a: c} + +<===> through_forward/show/error +Error: Mixin not found: d + , +3 | meta.apply(meta.get-mixin(d)); + | ^^^^^^^^^^^^^^^ + ' + input.scss 3:11 root stylesheet + +<===> +================================================================================ +<===> through_forward/hide/input.scss +@use "sass:meta"; +@use "midstream" as *; +a { + @include meta.apply(meta.get-mixin(c)); +} + +<===> through_forward/hide/_midstream.scss +@forward "upstream" hide c; + +<===> through_forward/hide/_upstream.scss +@mixin c() {a: c} + +<===> through_forward/hide/error +Error: Mixin not found: c + , +3 | meta.apply(meta.get-mixin(c)); + | ^^^^^^^^^^^^^^^ + ' + input.scss 3:11 root stylesheet + +<===> +================================================================================ +<===> division/input.scss +@use "sass:meta"; +@mixin foo() {} +@mixin bar() {} +a {b: meta.get-mixin(foo) / meta.get-mixin(bar)} + +<===> division/error +Error: meta.get-mixin("foo") isn't a valid CSS value. + , +1 | a {b: meta.get-mixin(foo) / meta.get-mixin(bar)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> mixin_exists/input.scss +@use "sass:meta"; +@mixin add-two($v) { + a: $v + 2; +} + +$add-two-mixin: meta.get-mixin(add-two); + +.error { + error: meta.get-mixin($add-two-mixin); +} + +<===> mixin_exists/error +Error: $name: meta.get-mixin("add-two") is not a string. + , +8 | error: meta.get-mixin($add-two-mixin); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 8:10 root stylesheet + +<===> +================================================================================ +<===> conflict/input.scss +@use "sass:meta"; +@use "other1" as *; +@use "other2" as *; + +a {b: meta.get-mixin(member)} + +<===> conflict/other1.scss +@mixin member() {a: other1} + +<===> conflict/other2.scss +@mixin member() {a: other2} + +<===> conflict/error +Error: This mixin is available from multiple global modules. + , +1 | @use "other1" as *; + | ================== includes mixin +2 | @use "other2" as *; + | ================== includes mixin +... | +4 | a {b: meta.get-mixin(member)} + | ^^^^^^^^^^^^^^^^^^^^ mixin use + ' + input.scss 4:7 root stylesheet + +<===> +================================================================================ +<===> module/undefined/input.scss +@use "sass:meta"; +@use "sass:color"; +a {b: meta.get-mixin("c", $module: "color")} + +<===> module/undefined/error +Error: Mixin not found: "c" + , +2 | a {b: meta.get-mixin("c", $module: "color")} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:7 root stylesheet + +<===> +================================================================================ +<===> module/non_existent/input.scss +@use "sass:meta"; +a {b: meta.get-mixin("c", $module: "d")} + +<===> module/non_existent/error +Error: There is no module with the namespace "d". + , +1 | a {b: meta.get-mixin("c", $module: "d")} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> module/built_in_but_not_loaded/input.scss +@use "sass:meta"; +a {b: meta.get-mixin("red", $module: "color")} + +<===> module/built_in_but_not_loaded/error +Error: There is no module with the namespace "color". + , +1 | a {b: meta.get-mixin("red", $module: "color")} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 1:7 root stylesheet + +<===> +================================================================================ +<===> module/dash_sensitive/input.scss +@use "sass:meta"; +@use "sass:color" as a-b; +c {d: meta.get-mixin("c", $module: "a_b")} + +<===> module/dash_sensitive/error +Error: There is no module with the namespace "a_b". + , +2 | c {d: meta.get-mixin("c", $module: "a_b")} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:7 root stylesheet diff --git a/spec/core_functions/meta/get_mixin/meta.hrx b/spec/core_functions/meta/get_mixin/meta.hrx new file mode 100644 index 0000000000..dc99b316bf --- /dev/null +++ b/spec/core_functions/meta/get_mixin/meta.hrx @@ -0,0 +1,21 @@ +<===> inspect/input.scss +@use "sass:meta"; +@mixin foo() {} +a {b: inspect(meta.get-mixin(foo))}; + +<===> inspect/output.css +a { + b: get-mixin("foo"); +} + +<===> +================================================================================ +<===> type_of/input.scss +@use "sass:meta"; +@mixin foo() {} +a {b: type-of(meta.get-mixin(foo))}; + +<===> type_of/output.css +a { + b: mixin; +} diff --git a/spec/core_functions/meta/get_mixin/same_module.hrx b/spec/core_functions/meta/get_mixin/same_module.hrx new file mode 100644 index 0000000000..288396a841 --- /dev/null +++ b/spec/core_functions/meta/get_mixin/same_module.hrx @@ -0,0 +1,71 @@ +<===> user_defined/input.scss +@use "sass:meta"; +@mixin add-two($v) {b: $v + 2} +$add-two-mixin: meta.get-mixin(add-two); + +a {@include meta.apply($add-two-mixin, 10)} + +<===> user_defined/output.css +a { + b: 12; +} + +<===> +================================================================================ +<===> redefined/input.scss +@use "sass:meta"; +@mixin add-two($v) {b: $v + 2} +$add-two-mixin: meta.get-mixin(add-two); + +// The mixin returned by `meta.get-mixin()` is locked in place when it's +// called. Redefining the mixin after the fact shouldn't affect the stored +// value. +@mixin add-two($v) {@error "Should not be called"} + +a {@include meta.apply($add-two-mixin, 10)} + +<===> redefined/output.css +a { + b: 12; +} + +<===> +================================================================================ +<===> through_import/input.scss +@use "sass:meta"; +@import "other"; +a {@include meta.apply(meta.get-mixin(add-two), 10)} + +<===> through_import/other.scss +@mixin add-two($v) {b: $v + 2} + +<===> through_import/output.css +a { + b: 12; +} + +<===> +================================================================================ +<===> dash_insensitive/dash_to_underscore/input.scss +@use "sass:meta"; +@mixin add_two($v) {b: $v + 2} + +a {@include meta.apply(meta.get-mixin(add-two), 10)} + +<===> dash_insensitive/dash_to_underscore/output.css +a { + b: 12; +} + +<===> +================================================================================ +<===> dash_insensitive/underscore_to_dash/input.scss +@use "sass:meta"; +@mixin add-two($v) {b: $v + 2} + +a {@include meta.apply(meta.get-mixin(add_two), 10)} + +<===> dash_insensitive/underscore_to_dash/output.css +a { + b: 12; +} diff --git a/spec/core_functions/meta/get_mixin/scope.hrx b/spec/core_functions/meta/get_mixin/scope.hrx new file mode 100644 index 0000000000..cee735e4b9 --- /dev/null +++ b/spec/core_functions/meta/get_mixin/scope.hrx @@ -0,0 +1,47 @@ +<===> stores_local_scope/options.yml +--- +:todo: +- sass/libsass#2830 + +<===> stores_local_scope/input.scss +@use "sass:meta"; +$add-two-mixin: null; + +.scope { + @mixin add-two($v) {b: $v + 2} + + // This mixin reference will still refer to this nested `add-two` mixin + // even when it goes out of scope. + $add-two-mixin: get-mixin(add-two) !global; +} + +a {@include meta.apply($add-two-mixin, 10)} + +<===> stores_local_scope/output.css +a { + b: 12; +} + +<===> +================================================================================ +<===> captures_inner_scope/input.scss +@use "sass:meta"; +@mixin add-two($v) {@error "Should not be called"} +.scope1 { + @mixin add-two($v) {@error "Should not be called"} + .scope2 { + @mixin add-two($v) {@error "Should not be called"} + .scope3 { + @mixin add-two($v) {a: $v + 2} + + // Like a normal mixin call, get-mixin() will always use the + // innermost definition of a mixin. + @include meta.apply(get-mixin(add-two), 10); + } + } +} + +<===> captures_inner_scope/output.css +.scope1 .scope2 .scope3 { + a: 12; +} diff --git a/spec/core_functions/meta/module_mixins.hrx b/spec/core_functions/meta/module_mixins.hrx new file mode 100644 index 0000000000..6000b56487 --- /dev/null +++ b/spec/core_functions/meta/module_mixins.hrx @@ -0,0 +1,372 @@ +<===> options.yml +--- +:todo: +- sass/libsass#2807 + +<===> _util.scss +@use "sass:meta"; + +@mixin print-mixin-map($mixins) { + a { + @each $name, $mixin in $mixins { + #{$name}: {@include meta.apply($mixin)}; + } + } +} + +<===> +================================================================================ +<===> empty/input.scss +@use "sass:meta"; +@use "other"; + +a {b: meta.inspect(meta.module-mixins("other"))} + +<===> empty/_other.scss +// This module defines no mixins. + +<===> empty/output.css +a { + b: (); +} + +<===> +================================================================================ +<===> multiple/input.scss +@use "sass:meta"; +@use "../util"; +@use "other"; + +@include util.print-mixin-map(meta.module-mixins("other")); + +<===> multiple/_other.scss +@mixin b() {b: value} +@mixin c() {c: value} +@mixin d() {d: value} + +<===> multiple/output.css +a { + b-b: value; + c-c: value; + d-d: value; +} + +<===> +================================================================================ +<===> dash_sensitive/input.scss +@use "sass:meta"; +@use "../util"; +@use "other"; + +@include util.print-mixin-map(meta.module-mixins("other")); + +<===> dash_sensitive/_other.scss +@mixin b-c() {b-c: value} +@mixin d_e() {d_e: value} + +<===> dash_sensitive/output.css +a { + b-c-b-c value; + d-e-d_e value; +} + +<===> +================================================================================ +<===> as/input.scss +@use "sass:meta"; +@use "../util"; +@use "other" as b; + +@include util.print-mixin-map(meta.module-mixins("b")) + +<===> as/_other.scss +@mixin c() {c: value} +@mixin d() {d: value} +@mixin e() {e: value} + +<===> as/output.css +a { + c-c: value; + d-d: value; + e-e: value; +} + +<===> +================================================================================ +<===> through_import/input.scss +@use "sass:meta"; +@use "../util"; +@use "used"; + +@include util.print-mixin-map(meta.module-mixins("used")); + +<===> through_import/_used.scss +@import "imported"; + +<===> through_import/_imported.scss +@mixin b() {b: value} +@mixin c() {c: value} +@mixin d() {d: value} + +<===> through_import/output.css +a { + b-b: value; + c-c: value; + d-d: value; +} + +<===> +================================================================================ +<===> core_module/input.scss +@use "sass:map"; +@use "sass:meta"; + +// We don't want to print every mixin name in this module, since that would +// make this test brittle when new mixins are added. Instead we just test +// that a couple mixins work. + +$mixins: meta.module-mixins("meta"); +a { + load-css-exists: map.has-key($mixins, "load-css"); +} + +<===> core_module/output.css +a { + load-css-exists: true; +} + +<===> +================================================================================ +<===> through_forward/bare/input.scss +@use "sass:meta"; +@use "../../util"; +@use "used"; + +@include util.print-mixin-map(meta.module-mixins("used")); + +<===> through_forward/bare/_used.scss +@forward "forwarded"; + +<===> through_forward/bare/_forwarded.scss +@mixin b() {b: value} +@mixin c() {c: value} +@mixin d() {d: value} + +<===> through_forward/bare/output.css +a { + b-b: value; + c-c: value; + d-d: value; +} + +<===> +================================================================================ +<===> through_forward/as/input.scss +@use "sass:meta"; +@use "../../util"; +@use "used"; + +@include util.print-mixin-map(meta.module-mixins("used")); + +<===> through_forward/as/_used.scss +@forward "forwarded" as b-*; + +<===> through_forward/as/_forwarded.scss +@mixin c() {c: value} +@mixin d() {d: value} +@mixin e() {e: value} + +<===> through_forward/as/output.css +a { + b-c-c: value; + b-d-d: value; + b-e-e: value; +} + +<===> +================================================================================ +<===> through_forward/show/input.scss +@use "sass:meta"; +@use "../../util"; +@use "used"; + +@include util.print-mixin-map(meta.module-mixins("used")); + +<===> through_forward/show/_used.scss +@forward "forwarded" show b, c; + +<===> through_forward/show/_forwarded.scss +@mixin b() {b: value} +@mixin c() {c: value} +@mixin d() {d: value} + +<===> through_forward/show/output.css +a { + b-b: value; + c-c: value; +} + +<===> +================================================================================ +<===> through_forward/hide/input.scss +@use "sass:meta"; +@use "../../util"; +@use "used"; + +@include util.print-mixin-map(meta.module-mixins("used")); + +<===> through_forward/hide/_used.scss +@forward "forwarded" hide b, c; + +<===> through_forward/hide/_forwarded.scss +@mixin b() {b: value} +@mixin c() {c: value} +@mixin d() {d: value} + +<===> through_forward/hide/output.css +a { + d-d: value; +} + +<===> +================================================================================ +<===> named/input.scss +@use "sass:meta"; +@use "../util"; +@use "other"; + +@include util.print-mixin-map(meta.module-mixins($module: "other")); + +<===> named/_other.scss +@mixin b() {b: value} +@mixin c() {c: value} +@mixin d() {d: value} + +<===> named/output.css +a { + b-b: value; + c-c: value; + d-d: value; +} + +<===> +================================================================================ +<===> error/type/input.scss +@use "sass:meta"; +$a: meta.module-mixins(1); + +<===> error/type/error +Error: $module: 1 is not a string. + , +2 | $a: meta.module-mixins(1); + | ^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:5 root stylesheet + +<===> +================================================================================ +<===> error/too_few_args/input.scss +@use "sass:meta"; +$a: meta.module-mixins(); + +<===> error/too_few_args/error +Error: Missing argument $module. + ,--> input.scss +2 | $a: meta.module-mixins(); + | ^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @mixin module-mixins($module) { + | ========================= declaration + ' + input.scss 2:5 root stylesheet + +<===> +================================================================================ +<===> error/too_many_args/input.scss +@use "sass:meta"; +$a: meta.module-mixins("meta", "c"); + +<===> error/too_many_args/error +Error: Only 1 argument allowed, but 2 were passed. + ,--> input.scss +2 | $a: meta.module-mixins("meta", "c"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @mixin module-mixins($module) { + | ========================= declaration + ' + input.scss 2:5 root stylesheet + +<===> +================================================================================ +<===> error/missing/input.scss +@use "sass:meta"; +$a: meta.module-mixins("other"); + +<===> error/missing/error +Error: There is no module with namespace "other". + , +2 | $a: meta.module-mixins("other"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:5 root stylesheet + +<===> +================================================================================ +<===> error/dash_sensitive/input.scss +@use "sass:meta"; +@use "other-module"; + +$a: meta.module-mixins("other_module"); + +<===> error/dash_sensitive/_other-module.scss +// This module defines no mixins. + +<===> error/dash_sensitive/error +Error: There is no module with namespace "other_module". + , +4 | $a: meta.module-mixins("other_module"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 4:5 root stylesheet + +<===> +================================================================================ +<===> error/global/input.scss +@use "sass:meta"; +@use "other" as *; + +$a: meta.module-mixins("other"); + +<===> error/global/_other.scss +// This module defines no mixins. + +<===> error/global/error +Error: There is no module with namespace "other". + , +4 | $a: meta.module-mixins("other"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 4:5 root stylesheet + +<===> +================================================================================ +<===> error/before_load/input.scss +@use "sass:meta"; + +$a: meta.module-mixins("other"); + +@use "other"; + +<===> error/before_load/_other.scss +// This module defines no mixins. + +<===> error/before_load/error +Error: There is no module with namespace "other". + , +3 | $a: meta.module-mixins("other"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 3:5 root stylesheet diff --git a/spec/core_functions/meta/type_of.hrx b/spec/core_functions/meta/type_of.hrx index 45b5379a64..692ff64489 100644 --- a/spec/core_functions/meta/type_of.hrx +++ b/spec/core_functions/meta/type_of.hrx @@ -177,6 +177,18 @@ a { b: calculation; } +<===> +================================================================================ +<===> mixin/input.scss +@use "sass:meta"; +@mixin foo() {} +a {b: type-of(meta.get-mixin(foo))} + +<===> mixin/output.css +a { + b: mixin; +} + <===> ================================================================================ <===> named/input.scss