From a03b8f7c22601583ff33d97675b3c148ee1baf78 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 25 Aug 2023 03:58:02 +0000 Subject: [PATCH 01/32] 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 From 99ebbf1295295a26124cc20c8b786e6b9100e07e Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Sun, 3 Sep 2023 05:02:53 +0000 Subject: [PATCH 02/32] add more apply and get-mixin tests --- spec/core_functions/meta/apply.hrx | 69 +++++++++++- .../core_functions/meta/get_mixin/content.hrx | 104 +++++++++++++++++- spec/core_functions/meta/get_mixin/scope.hrx | 47 ++++++++ 3 files changed, 218 insertions(+), 2 deletions(-) diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 8826b5238d..673b7f2b3f 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -1 +1,68 @@ -// todo \ No newline at end of file +<===> use-as-function/input.scss +@use "sass:meta"; + +@mixin foo {} +$foo: meta.get-mixin("foo"); + +a {b: meta.apply($foo)} + +<===> use-as-function/error +// todo + +<===> +================================================================================ +<===> no-args/input.scss +@use "sass:meta"; + +a {@include meta.apply()} + +<===> no-args/error +// todo +<===> +================================================================================ +<===> wrong-arg-type/input.scss +@use "sass:meta"; + +a {@include meta.apply(2px)} + +<===> wrong-arg-type/error +// todo + +<===> +================================================================================ +<===> too-many-args/input.scss +@use "sass:meta"; + +@mixin foo {} +$foo: meta.get-mixin("foo"); + +a {@include meta.apply($foo, 2px)} + +<===> too-many-args/error +// todo + +<===> +================================================================================ +<===> missing-mixin-args/input.scss +@use "sass:meta"; + +@mixin foo($a) {} +$foo: meta.get-mixin("foo"); + +a {@include meta.apply($foo)} + +<===> missing-mixin-args/error +// todo + +<===> +================================================================================ +<===> too-many-args/mixin-accepts-args/input.scss +@use "sass:meta"; + +@mixin foo($a) {} +$foo: meta.get-mixin("foo"); + +a {@include meta.apply($foo, 2px, 3px)} + +<===> too-many-args/mixin-accepts-args/error +// todo diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index 8826b5238d..b1ab40b0b4 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -1 +1,103 @@ -// todo \ No newline at end of file +<===> +================================================================================ +<===> passes-content/input.scss +@use "sass:meta"; + +@mixin foo { + @content; +} + +a { + @include meta.apply(meta.get-mixin("foo")) { + b: red; + } +} + +<===> passes-content/output.css +a { + b: red; +} + +<===> +================================================================================ +<===> passes-content/empty/input.scss +@use "sass:meta"; + +@mixin foo { + @content; +} + +a { + @include meta.apply(meta.get-mixin("foo")) {} +} + +<===> passes-content/empty/output.css +<===> +================================================================================ +<===> denies-content/input.scss +@use "sass:meta"; +@mixin foo {} + +a { + @include meta.apply(meta.get-mixin("foo")) {} +} + +<===> denies-content/error +// todo +<===> +================================================================================ +<===> scope/redeclare/input.scss +@use "sass:meta"; +@mixin foo($a: a) { + $b: b; + @content; + a: $a; + b: $b; +} + +$c: c; + +a { + $d: d; + @include meta.apply(meta.get-mixin("foo")) { + $a: x; + $b: x; + $c: x; + $d: x; + } + c: $c; + d: $d; +} + +<===> scope/redeclare/output.css +a { + a: a; + b: b; + c: c; + d: x; +} + +<===> +================================================================================ +<===> scope/redeclare/using/input.scss +@use "sass:meta"; +@mixin foo($a: x) { + @content(a); +} + +$a: y; + +a { + $a: z; + @include meta.apply(meta.get-mixin("foo")) using ($a) { + a: $a; + $a: a; + } + b: $a; +} + +<===> scope/redeclare/using/output.css +a { + a: a; + b: z; +} diff --git a/spec/core_functions/meta/get_mixin/scope.hrx b/spec/core_functions/meta/get_mixin/scope.hrx index cee735e4b9..1940d48bdf 100644 --- a/spec/core_functions/meta/get_mixin/scope.hrx +++ b/spec/core_functions/meta/get_mixin/scope.hrx @@ -45,3 +45,50 @@ a { .scope1 .scope2 .scope3 { a: 12; } + +<===> +================================================================================ +<===> scope/doesnt-capture-global/input.scss +@use "sass:meta"; +$a: x; + +@mixin foo { + a: $a; +} + +$ref: meta.get-mixin("foo"); + +$a: y; + +a { + @include meta.apply($ref); +} + +<===> scope/doesnt-capture-global/output.css +a { + a: y; +} + +<===> +================================================================================ +<===> scope/doesnt-capture-local/input.scss +@use "sass:meta"; + +a { + $a: x; + + @mixin foo { + a: $a; + } + + $ref: meta.get-mixin("foo"); + + $a: y; + @include meta.apply($ref); +} + +<===> scope/doesnt-capture-local/output.css +a { + a: y; +} + From fe8b73777236f9e68aeb37990157c93fa8f35c73 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 8 Sep 2023 06:51:04 +0000 Subject: [PATCH 03/32] add another content scope test --- .../core_functions/meta/get_mixin/content.hrx | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index b1ab40b0b4..f831cf2147 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -101,3 +101,41 @@ a { a: a; b: z; } + +<===> +================================================================================ +<===> scope/fall-through/input.scss +@use "sass:meta"; +$b: x; + +@mixin foo { + @content(x); + b: $b; +} + +@mixin bar { + $b: a; + @include meta.apply(meta.get-mixin(foo)) using ($a) { + @content($a); + } +} + +@mixin baz { + $b: b; + @include meta.apply(meta.get-mixin(bar)) using ($a) { + @content($a); + } +} + +a { + $b: c; + @include meta.apply(meta.get-mixin(baz)) using ($a) { + a: $a; + } +} + +<===> scope/redeclare/using/output.css +a { + a: x; + b: x; +} From 634d71ab4f17b80407b0d222f2db6596a132825b Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 8 Sep 2023 08:37:50 +0000 Subject: [PATCH 04/32] tidy, add tests --- spec/core_functions/meta/apply.hrx | 48 +++++++++- .../core_functions/meta/get_mixin/content.hrx | 40 ++++++-- .../meta/get_mixin/different_module.hrx | 6 +- spec/core_functions/meta/get_mixin/error.hrx | 92 +++++++++---------- .../meta/load_css/error/content.hrx | 13 +++ spec/core_functions/meta/module_mixins.hrx | 12 +-- 6 files changed, 145 insertions(+), 66 deletions(-) create mode 100644 spec/core_functions/meta/load_css/error/content.hrx diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 673b7f2b3f..8477b61044 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -7,7 +7,12 @@ $foo: meta.get-mixin("foo"); a {b: meta.apply($foo)} <===> use-as-function/error -// todo +Error: Undefined function. + , +6 | a {b: meta.apply($foo)} + | ^^^^^^^^^^^^^^^^ + ' + input.scss 6:7 root stylesheet <===> ================================================================================ @@ -17,7 +22,17 @@ a {b: meta.apply($foo)} a {@include meta.apply()} <===> no-args/error -// todo +Error: Missing argument $mixin. + ,--> input.scss +3 | a {@include meta.apply()} + | ^^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @mixin apply($mixin, $args...) { + | ======================= declaration + ' + input.scss 3:4 root stylesheet + <===> ================================================================================ <===> wrong-arg-type/input.scss @@ -26,7 +41,12 @@ a {@include meta.apply()} a {@include meta.apply(2px)} <===> wrong-arg-type/error -// todo +Error: $mixin: 2px is not a mixin reference. + , +3 | a {@include meta.apply(2px)} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 3:4 root stylesheet <===> ================================================================================ @@ -39,7 +59,16 @@ $foo: meta.get-mixin("foo"); a {@include meta.apply($foo, 2px)} <===> too-many-args/error -// todo +Error: Only 0 arguments allowed, but 1 was passed. + , +3 | @mixin foo {} + | === declaration +... | +6 | a {@include meta.apply($foo, 2px)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + input.scss 6:4 foo() + input.scss 6:4 root stylesheet <===> ================================================================================ @@ -52,7 +81,16 @@ $foo: meta.get-mixin("foo"); a {@include meta.apply($foo)} <===> missing-mixin-args/error -// todo +Error: Missing argument $a. + , +3 | @mixin foo($a) {} + | ======= declaration +... | +6 | a {@include meta.apply($foo)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + input.scss 6:4 foo() + input.scss 6:4 root stylesheet <===> ================================================================================ diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index f831cf2147..fc26bfac46 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -34,7 +34,7 @@ a { <===> passes-content/empty/output.css <===> ================================================================================ -<===> denies-content/input.scss +<===> denies-content/user-defined/input.scss @use "sass:meta"; @mixin foo {} @@ -42,11 +42,39 @@ a { @include meta.apply(meta.get-mixin("foo")) {} } -<===> denies-content/error -// todo +<===> denies-content/user-defined/error +Error: Mixin doesn't accept a content block. + , +2 | @mixin foo {} + | === declaration +... | +5 | @include meta.apply(meta.get-mixin("foo")) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + input.scss 5:5 root stylesheet + <===> ================================================================================ -<===> scope/redeclare/input.scss +<===> denies-content/builtin/input.scss +@use "sass:meta"; + +a { + @include meta.apply(meta.get-mixin(load-css, meta), "foo") { + a: b; + } +} + +<===> denies-content/builtin/error +Error: Mixin doesn't accept a content block. + , +4 | @include meta.apply(meta.get-mixin(load-css, meta), "foo") { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 4:5 root stylesheet + +<===> +================================================================================ +<===> scope/redeclare-vars/input.scss @use "sass:meta"; @mixin foo($a: a) { $b: b; @@ -69,7 +97,7 @@ a { d: $d; } -<===> scope/redeclare/output.css +<===> scope/redeclare-vars/output.css a { a: a; b: b; @@ -134,7 +162,7 @@ a { } } -<===> scope/redeclare/using/output.css +<===> scope/fall-through/output.css a { a: x; b: x; diff --git a/spec/core_functions/meta/get_mixin/different_module.hrx b/spec/core_functions/meta/get_mixin/different_module.hrx index 22fb6a18b1..e9ff40b422 100644 --- a/spec/core_functions/meta/get_mixin/different_module.hrx +++ b/spec/core_functions/meta/get_mixin/different_module.hrx @@ -3,9 +3,9 @@ <===> defined/input.scss @use "sass:meta"; @use "foo"; -a {@include meta.apply(meta.get-mixin("foo", $module: "color"), #abcdef)} +a {@include meta.apply(meta.get-mixin("foo", $module: "foo"), #abcdef)} -<===> chosen_prefix/foo.scss +<===> defined/foo.scss @mixin foo($color) { b: red($color) } @@ -124,7 +124,7 @@ a { <===> named/input.scss @use "sass:meta"; @use "foo"; -a {@include meta.apply(meta.get-mixin($name: "foo", $module: "color"), #abcdef)} +a {@include meta.apply(meta.get-mixin($name: "foo", $module: "foo"), #abcdef)} <===> named/foo.scss @mixin foo($color) { diff --git a/spec/core_functions/meta/get_mixin/error.hrx b/spec/core_functions/meta/get_mixin/error.hrx index dd64231067..377389a5cb 100644 --- a/spec/core_functions/meta/get_mixin/error.hrx +++ b/spec/core_functions/meta/get_mixin/error.hrx @@ -5,10 +5,10 @@ a {b: meta.get-mixin(2px)} <===> argument/type/name/error Error: $name: 2px is not a string. , -1 | a {b: meta.get-mixin(2px)} - | ^^^^^^^^^^^^^^^^^ +2 | a {b: meta.get-mixin(2px)} + | ^^^^^^^^^^^^^^^^^^^ ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> ================================================================================ @@ -19,10 +19,10 @@ 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)} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 | a {b: meta.get-mixin(c, $module: 1)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> ================================================================================ @@ -36,10 +36,10 @@ 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)} - | ^^^^^^^^^^^^^^^^^^^^^^ +5 | a {b: meta.get-mixin($foo-ref)} + | ^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 6:7 root stylesheet + input.scss 5:7 root stylesheet <===> ================================================================================ @@ -50,14 +50,14 @@ a {b: meta.get-mixin()} <===> argument/too_few/error Error: Missing argument $name. ,--> input.scss -1 | a {b: meta.get-mixin()} - | ^^^^^^^^^^^^^^ invocation +2 | a {b: meta.get-mixin()} + | ^^^^^^^^^^^^^^^^ invocation ' ,--> sass:meta 1 | @function get-mixin($name, $module: null) { - | ================================== declaration + | =============================== declaration ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> ================================================================================ @@ -66,16 +66,16 @@ Error: Missing argument $name. a {b: meta.get-mixin(c, true, d, e)} <===> argument/too_many/error -Error: Only 3 arguments allowed, but 4 were passed. +Error: Only 2 arguments allowed, but 4 were passed. ,--> input.scss -1 | a {b: meta.get-mixin(c, true, d, e)} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation +2 | a {b: meta.get-mixin(c, true, d, e)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation ' ,--> sass:meta 1 | @function get-mixin($name, $module: null) { - | ================================== declaration + | =============================== declaration ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> ================================================================================ @@ -86,10 +86,10 @@ 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)} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 | a {b: meta.get-mixin(does-not-exist)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> ================================================================================ @@ -109,10 +109,10 @@ a { <===> through_forward/show/error Error: Mixin not found: d , -3 | meta.apply(meta.get-mixin(d)); - | ^^^^^^^^^^^^^^^ +4 | @include meta.apply(meta.get-mixin(d)); + | ^^^^^^^^^^^^^^^^^ ' - input.scss 3:11 root stylesheet + input.scss 4:23 root stylesheet <===> ================================================================================ @@ -132,10 +132,10 @@ a { <===> through_forward/hide/error Error: Mixin not found: c , -3 | meta.apply(meta.get-mixin(c)); - | ^^^^^^^^^^^^^^^ +4 | @include meta.apply(meta.get-mixin(c)); + | ^^^^^^^^^^^^^^^^^ ' - input.scss 3:11 root stylesheet + input.scss 4:23 root stylesheet <===> ================================================================================ @@ -146,12 +146,12 @@ Error: Mixin not found: c a {b: meta.get-mixin(foo) / meta.get-mixin(bar)} <===> division/error -Error: meta.get-mixin("foo") isn't a valid CSS value. +Error: get-mixin("foo") isn't a valid CSS value. , -1 | a {b: meta.get-mixin(foo) / meta.get-mixin(bar)} +4 | a {b: meta.get-mixin(foo) / meta.get-mixin(bar)} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 1:7 root stylesheet + input.scss 4:7 root stylesheet <===> ================================================================================ @@ -168,12 +168,12 @@ $add-two-mixin: meta.get-mixin(add-two); } <===> mixin_exists/error -Error: $name: meta.get-mixin("add-two") is not a string. +Error: $name: get-mixin("add-two") is not a string. , -8 | error: meta.get-mixin($add-two-mixin); +9 | error: meta.get-mixin($add-two-mixin); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 8:10 root stylesheet + input.scss 9:10 root stylesheet <===> ================================================================================ @@ -193,15 +193,15 @@ a {b: meta.get-mixin(member)} <===> conflict/error Error: This mixin is available from multiple global modules. , -1 | @use "other1" as *; +2 | @use "other1" as *; | ================== includes mixin -2 | @use "other2" as *; +3 | @use "other2" as *; | ================== includes mixin ... | -4 | a {b: meta.get-mixin(member)} - | ^^^^^^^^^^^^^^^^^^^^ mixin use +5 | a {b: meta.get-mixin(member)} + | ^^^^^^^^^^^^^^^^^^^^^^ mixin use ' - input.scss 4:7 root stylesheet + input.scss 5:7 root stylesheet <===> ================================================================================ @@ -213,10 +213,10 @@ 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")} +3 | a {b: meta.get-mixin("c", $module: "color")} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 2:7 root stylesheet + input.scss 3:7 root stylesheet <===> ================================================================================ @@ -227,10 +227,10 @@ 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")} +2 | a {b: meta.get-mixin("c", $module: "d")} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> ================================================================================ @@ -241,10 +241,10 @@ 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")} +2 | a {b: meta.get-mixin("red", $module: "color")} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 1:7 root stylesheet + input.scss 2:7 root stylesheet <===> ================================================================================ @@ -256,7 +256,7 @@ 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")} +3 | c {d: meta.get-mixin("c", $module: "a_b")} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' - input.scss 2:7 root stylesheet + input.scss 3:7 root stylesheet diff --git a/spec/core_functions/meta/load_css/error/content.hrx b/spec/core_functions/meta/load_css/error/content.hrx new file mode 100644 index 0000000000..d8033e4cf6 --- /dev/null +++ b/spec/core_functions/meta/load_css/error/content.hrx @@ -0,0 +1,13 @@ +<===> input.scss +@use "sass:meta"; +@include meta.load-css("foo") {}; + +<===> foo.scss + +<===> error +Error: Mixin doesn't accept a content block. + , +2 | @include meta.load-css("foo") {}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 2:1 root stylesheet diff --git a/spec/core_functions/meta/module_mixins.hrx b/spec/core_functions/meta/module_mixins.hrx index 6000b56487..15bdecf431 100644 --- a/spec/core_functions/meta/module_mixins.hrx +++ b/spec/core_functions/meta/module_mixins.hrx @@ -66,8 +66,8 @@ a { <===> dash_sensitive/output.css a { - b-c-b-c value; - d-e-d_e value; + b-c-b-c: value; + d-e-d_e: value; } <===> @@ -276,8 +276,8 @@ Error: Missing argument $module. | ^^^^^^^^^^^^^^^^^^^^ invocation ' ,--> sass:meta -1 | @mixin module-mixins($module) { - | ========================= declaration +1 | @function module-mixins($module) { + | ====================== declaration ' input.scss 2:5 root stylesheet @@ -294,8 +294,8 @@ Error: Only 1 argument allowed, but 2 were passed. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation ' ,--> sass:meta -1 | @mixin module-mixins($module) { - | ========================= declaration +1 | @function module-mixins($module) { + | ====================== declaration ' input.scss 2:5 root stylesheet From 31685340330634c3bbbdaa943b2064b5e5af526f Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 8 Sep 2023 13:17:12 +0000 Subject: [PATCH 05/32] resolve lints --- spec/core_functions/meta/apply.hrx | 15 ++++++++++++--- spec/core_functions/meta/get_mixin/content.hrx | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 8477b61044..3cb4ce4550 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -94,7 +94,7 @@ Error: Missing argument $a. <===> ================================================================================ -<===> too-many-args/mixin-accepts-args/input.scss +<===> too-many-args-mixin-accepts-args/input.scss @use "sass:meta"; @mixin foo($a) {} @@ -102,5 +102,14 @@ $foo: meta.get-mixin("foo"); a {@include meta.apply($foo, 2px, 3px)} -<===> too-many-args/mixin-accepts-args/error -// todo +<===> too-many-args-mixin-accepts-args/error +Error: Only 1 argument allowed, but 2 were passed. + , +3 | @mixin foo($a) {} + | ======= declaration +... | +6 | a {@include meta.apply($foo, 2px, 3px)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + input.scss 6:4 foo() + input.scss 6:4 root stylesheet diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index fc26bfac46..f8407be4b2 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -20,7 +20,7 @@ a { <===> ================================================================================ -<===> passes-content/empty/input.scss +<===> passes-empty-content/input.scss @use "sass:meta"; @mixin foo { @@ -31,7 +31,7 @@ a { @include meta.apply(meta.get-mixin("foo")) {} } -<===> passes-content/empty/output.css +<===> passes-empty-content/output.css <===> ================================================================================ <===> denies-content/user-defined/input.scss From cb3b2d426f363901d21b67d48edf511b8586f5f4 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 8 Sep 2023 13:20:31 +0000 Subject: [PATCH 06/32] fix formatting --- spec/core_functions/meta/accepts_content.hrx | 4 ++++ spec/core_functions/meta/get_mixin/content.hrx | 3 +-- spec/core_functions/meta/get_mixin/different_module.hrx | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/core_functions/meta/accepts_content.hrx b/spec/core_functions/meta/accepts_content.hrx index 89b5b7b6d7..d371552319 100644 --- a/spec/core_functions/meta/accepts_content.hrx +++ b/spec/core_functions/meta/accepts_content.hrx @@ -12,6 +12,8 @@ a { b: true; } +<===> +================================================================================ <===> accepts/nested-child/input.scss @use "sass:meta"; @@ -28,6 +30,8 @@ a { b: true; } +<===> +================================================================================ <===> doesnt-accept/empty/input.scss @use "sass:meta"; @mixin foo() {} diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index f8407be4b2..294ecbab56 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -1,5 +1,3 @@ -<===> -================================================================================ <===> passes-content/input.scss @use "sass:meta"; @@ -32,6 +30,7 @@ a { } <===> passes-empty-content/output.css + <===> ================================================================================ <===> denies-content/user-defined/input.scss diff --git a/spec/core_functions/meta/get_mixin/different_module.hrx b/spec/core_functions/meta/get_mixin/different_module.hrx index e9ff40b422..3114ae1112 100644 --- a/spec/core_functions/meta/get_mixin/different_module.hrx +++ b/spec/core_functions/meta/get_mixin/different_module.hrx @@ -1,5 +1,3 @@ -<===> -================================================================================ <===> defined/input.scss @use "sass:meta"; @use "foo"; From 1dcde0f92da96f69992d3281d1ad4a216a298ca7 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 8 Sep 2023 14:45:47 +0000 Subject: [PATCH 07/32] ignore libsass --- spec/core_functions/meta/accepts_content.hrx | 5 +++++ spec/core_functions/meta/apply.hrx | 5 +++++ spec/core_functions/meta/get_mixin/options.yml | 3 +++ spec/core_functions/meta/type_of.hrx | 5 +++++ 4 files changed, 18 insertions(+) create mode 100644 spec/core_functions/meta/get_mixin/options.yml diff --git a/spec/core_functions/meta/accepts_content.hrx b/spec/core_functions/meta/accepts_content.hrx index d371552319..5ad4fcce07 100644 --- a/spec/core_functions/meta/accepts_content.hrx +++ b/spec/core_functions/meta/accepts_content.hrx @@ -1,3 +1,8 @@ +<===> options.yml +--- +:todo: +- sass/libsass#2807 + <===> accepts/direct-child/input.scss @use "sass:meta"; diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 3cb4ce4550..15fa23f2b5 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -1,3 +1,8 @@ +<===> options.yml +--- +:todo: +- sass/libsass#2807 + <===> use-as-function/input.scss @use "sass:meta"; diff --git a/spec/core_functions/meta/get_mixin/options.yml b/spec/core_functions/meta/get_mixin/options.yml new file mode 100644 index 0000000000..3f54c5effb --- /dev/null +++ b/spec/core_functions/meta/get_mixin/options.yml @@ -0,0 +1,3 @@ +--- +:todo: +- sass/libsass#2807 diff --git a/spec/core_functions/meta/type_of.hrx b/spec/core_functions/meta/type_of.hrx index 692ff64489..65a2fbc5cb 100644 --- a/spec/core_functions/meta/type_of.hrx +++ b/spec/core_functions/meta/type_of.hrx @@ -184,6 +184,11 @@ a { @mixin foo() {} a {b: type-of(meta.get-mixin(foo))} +<===> mixin/options.yml +--- +:todo: +- sass/libsass#2807 + <===> mixin/output.css a { b: mixin; From 70581694220be50f939a4219e0201bc7dd0dc397 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 8 Sep 2023 18:32:07 +0000 Subject: [PATCH 08/32] formatting --- spec/core_functions/meta/accepts_content.hrx | 2 ++ spec/core_functions/meta/apply.hrx | 2 ++ spec/core_functions/meta/type_of.hrx | 10 +++++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/core_functions/meta/accepts_content.hrx b/spec/core_functions/meta/accepts_content.hrx index 5ad4fcce07..fc129e2782 100644 --- a/spec/core_functions/meta/accepts_content.hrx +++ b/spec/core_functions/meta/accepts_content.hrx @@ -3,6 +3,8 @@ :todo: - sass/libsass#2807 +<===> +================================================================================ <===> accepts/direct-child/input.scss @use "sass:meta"; diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 15fa23f2b5..b3c608c379 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -3,6 +3,8 @@ :todo: - sass/libsass#2807 +<===> +================================================================================ <===> use-as-function/input.scss @use "sass:meta"; diff --git a/spec/core_functions/meta/type_of.hrx b/spec/core_functions/meta/type_of.hrx index 65a2fbc5cb..fb46fcda38 100644 --- a/spec/core_functions/meta/type_of.hrx +++ b/spec/core_functions/meta/type_of.hrx @@ -179,16 +179,16 @@ a { <===> ================================================================================ -<===> mixin/input.scss -@use "sass:meta"; -@mixin foo() {} -a {b: type-of(meta.get-mixin(foo))} - <===> mixin/options.yml --- :todo: - sass/libsass#2807 +<===> mixin/input.scss +@use "sass:meta"; +@mixin foo() {} +a {b: type-of(meta.get-mixin(foo))} + <===> mixin/output.css a { b: mixin; From 6dfcf9f7479e068f22c78a973d76179ffc096b2f Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Thu, 14 Sep 2023 18:01:36 +0000 Subject: [PATCH 09/32] add apply built test, update error spans --- spec/core_functions/meta/accepts_content.hrx | 26 +++++++++++++++++++ .../core_functions/meta/get_mixin/content.hrx | 8 ++++-- .../meta/load_css/error/content.hrx | 8 ++++-- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/spec/core_functions/meta/accepts_content.hrx b/spec/core_functions/meta/accepts_content.hrx index fc129e2782..7145d71e25 100644 --- a/spec/core_functions/meta/accepts_content.hrx +++ b/spec/core_functions/meta/accepts_content.hrx @@ -49,3 +49,29 @@ a {b: meta.accepts-content(meta.get-mixin("foo"))} a { b: false; } + +<===> +================================================================================ +<===> doesnt-accept/builtin/input.scss +@use "sass:meta"; +@mixin foo() {} + +a {b: meta.accepts-content(meta.get-mixin(load-css, meta))} + +<===> doesnt-accept/builtin/output.css +a { + b: false; +} + +<===> +================================================================================ +<===> accepts/builtin/input.scss +@use "sass:meta"; +@mixin foo() {} + +a {b: meta.accepts-content(meta.get-mixin(apply, meta))} + +<===> accepts/builtin/output.css +a { + b: true; +} diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index 294ecbab56..e1f07aaf18 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -65,9 +65,13 @@ a { <===> denies-content/builtin/error Error: Mixin doesn't accept a content block. - , + ,--> input.scss 4 | @include meta.apply(meta.get-mixin(load-css, meta), "foo") { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @mixin load-css($url, $with: null) { + | =========================== declaration ' input.scss 4:5 root stylesheet diff --git a/spec/core_functions/meta/load_css/error/content.hrx b/spec/core_functions/meta/load_css/error/content.hrx index d8033e4cf6..eefcbfacf2 100644 --- a/spec/core_functions/meta/load_css/error/content.hrx +++ b/spec/core_functions/meta/load_css/error/content.hrx @@ -6,8 +6,12 @@ <===> error Error: Mixin doesn't accept a content block. - , + ,--> input.scss 2 | @include meta.load-css("foo") {}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @mixin load-css($url, $with: null) { + | =========================== declaration ' input.scss 2:1 root stylesheet From ee795d956261ca9bc98744c2a30c700d7d3f7873 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Sat, 16 Sep 2023 19:58:28 +0000 Subject: [PATCH 10/32] change error message for issue_1079 this test _shouldn't_ have a different error message as a result of the mixin changes, but i am updating it now so that CI is green, before i get a chance to investigate why this change is occurring. i have verified that the change to this test is related to the changes to mixins --- spec/libsass-closed-issues/issue_1079.hrx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/libsass-closed-issues/issue_1079.hrx b/spec/libsass-closed-issues/issue_1079.hrx index 8946c1e177..3a6ba16ba3 100644 --- a/spec/libsass-closed-issues/issue_1079.hrx +++ b/spec/libsass-closed-issues/issue_1079.hrx @@ -2,9 +2,13 @@ #{hdr(2,5)} { color: #08c; } <===> error Error: expected selector. - , + ,--> input.scss 1 | #{hdr(2,5)} { color: #08c; } - | ^^^^^^^^ + | ^^^^^^^^ + ' + , +1 | hdr(2, 5) + | = error in interpolated output ' input.scss 1:3 root stylesheet From f1dc81d848e53fac7ee1e130d4d32a664ff7f9fa Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Mon, 18 Sep 2023 16:56:34 +0000 Subject: [PATCH 11/32] lint spec --- spec/core_functions/meta/accepts_content.hrx | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/core_functions/meta/accepts_content.hrx b/spec/core_functions/meta/accepts_content.hrx index 7145d71e25..9250f38daa 100644 --- a/spec/core_functions/meta/accepts_content.hrx +++ b/spec/core_functions/meta/accepts_content.hrx @@ -39,39 +39,39 @@ a { <===> ================================================================================ -<===> doesnt-accept/empty/input.scss +<===> accepts/builtin/input.scss @use "sass:meta"; @mixin foo() {} -a {b: meta.accepts-content(meta.get-mixin("foo"))} +a {b: meta.accepts-content(meta.get-mixin(apply, meta))} -<===> doesnt-accept/empty/output.css +<===> accepts/builtin/output.css a { - b: false; + b: true; } <===> ================================================================================ -<===> doesnt-accept/builtin/input.scss +<===> doesnt-accept/empty/input.scss @use "sass:meta"; @mixin foo() {} -a {b: meta.accepts-content(meta.get-mixin(load-css, meta))} +a {b: meta.accepts-content(meta.get-mixin("foo"))} -<===> doesnt-accept/builtin/output.css +<===> doesnt-accept/empty/output.css a { b: false; } <===> ================================================================================ -<===> accepts/builtin/input.scss +<===> doesnt-accept/builtin/input.scss @use "sass:meta"; @mixin foo() {} -a {b: meta.accepts-content(meta.get-mixin(apply, meta))} +a {b: meta.accepts-content(meta.get-mixin(load-css, meta))} -<===> accepts/builtin/output.css +<===> doesnt-accept/builtin/output.css a { - b: true; + b: false; } From a6874bf7028e470ec99303b7588c9a34d90157e9 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Thu, 21 Sep 2023 22:48:48 +0000 Subject: [PATCH 12/32] bump ci previous failure seems spurious? at least, it says the error lies with npm From a203dfcc245167637e5f162aea59deb3e19f5bbf Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 22 Sep 2023 18:04:52 +0000 Subject: [PATCH 13/32] pr review --- spec/core_functions/meta/accepts_content.hrx | 39 +++-- spec/core_functions/meta/apply.hrx | 82 +++++----- .../core_functions/meta/get_mixin/content.hrx | 148 +++++++++--------- .../meta/get_mixin/different_module.hrx | 24 +-- .../meta/get_mixin/equality.hrx | 7 +- spec/core_functions/meta/get_mixin/error.hrx | 24 +-- spec/core_functions/meta/get_mixin/meta.hrx | 10 +- spec/core_functions/meta/get_mixin/scope.hrx | 16 +- .../meta/load_css/error/content.hrx | 8 +- spec/core_functions/meta/module_mixins.hrx | 66 +++++--- spec/core_functions/meta/type_of.hrx | 4 +- 11 files changed, 228 insertions(+), 200 deletions(-) diff --git a/spec/core_functions/meta/accepts_content.hrx b/spec/core_functions/meta/accepts_content.hrx index 9250f38daa..95b9b530d4 100644 --- a/spec/core_functions/meta/accepts_content.hrx +++ b/spec/core_functions/meta/accepts_content.hrx @@ -5,34 +5,34 @@ <===> ================================================================================ -<===> accepts/direct-child/input.scss +<===> accepts/direct_child/input.scss @use "sass:meta"; -@mixin foo() { - @content; +@mixin a() { + @content; } -a {b: meta.accepts-content(meta.get-mixin("foo"))} +a {b: meta.accepts-content(meta.get-mixin("a"))} -<===> accepts/direct-child/output.css +<===> accepts/direct_child/output.css a { b: true; } <===> ================================================================================ -<===> accepts/nested-child/input.scss +<===> accepts/nested_child/input.scss @use "sass:meta"; -@mixin foo() { - @if false { - @content; - } +@mixin a() { + @if false { + @content; + } } -a {b: meta.accepts-content(meta.get-mixin("foo"))} +a {b: meta.accepts-content(meta.get-mixin("a"))} -<===> accepts/nested-child/output.css +<===> accepts/nested_child/output.css a { b: true; } @@ -41,7 +41,6 @@ a { ================================================================================ <===> accepts/builtin/input.scss @use "sass:meta"; -@mixin foo() {} a {b: meta.accepts-content(meta.get-mixin(apply, meta))} @@ -52,26 +51,26 @@ a { <===> ================================================================================ -<===> doesnt-accept/empty/input.scss +<===> doesnt_accept/empty/input.scss @use "sass:meta"; -@mixin foo() {} +@mixin a() {} -a {b: meta.accepts-content(meta.get-mixin("foo"))} +a {b: meta.accepts-content(meta.get-mixin("a"))} -<===> doesnt-accept/empty/output.css +<===> doesnt_accept/empty/output.css a { b: false; } <===> ================================================================================ -<===> doesnt-accept/builtin/input.scss +<===> doesnt_accept/builtin/input.scss @use "sass:meta"; -@mixin foo() {} +@mixin a() {} a {b: meta.accepts-content(meta.get-mixin(load-css, meta))} -<===> doesnt-accept/builtin/output.css +<===> doesnt_accept/builtin/output.css a { b: false; } diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index b3c608c379..07887691a4 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -5,30 +5,30 @@ <===> ================================================================================ -<===> use-as-function/input.scss +<===> use_as_function/input.scss @use "sass:meta"; -@mixin foo {} -$foo: meta.get-mixin("foo"); +@mixin a {} +$a: meta.get-mixin("a"); -a {b: meta.apply($foo)} +a {b: meta.apply($a)} -<===> use-as-function/error +<===> use_as_function/error Error: Undefined function. , -6 | a {b: meta.apply($foo)} - | ^^^^^^^^^^^^^^^^ +6 | a {b: meta.apply($a)} + | ^^^^^^^^^^^^^^ ' input.scss 6:7 root stylesheet <===> ================================================================================ -<===> no-args/input.scss +<===> no_args/input.scss @use "sass:meta"; a {@include meta.apply()} -<===> no-args/error +<===> no_args/error Error: Missing argument $mixin. ,--> input.scss 3 | a {@include meta.apply()} @@ -42,12 +42,12 @@ Error: Missing argument $mixin. <===> ================================================================================ -<===> wrong-arg-type/input.scss +<===> wrong_arg_type/input.scss @use "sass:meta"; a {@include meta.apply(2px)} -<===> wrong-arg-type/error +<===> wrong_arg_type/error Error: $mixin: 2px is not a mixin reference. , 3 | a {@include meta.apply(2px)} @@ -57,66 +57,66 @@ Error: $mixin: 2px is not a mixin reference. <===> ================================================================================ -<===> too-many-args/input.scss +<===> too_many_args/input.scss @use "sass:meta"; -@mixin foo {} -$foo: meta.get-mixin("foo"); +@mixin a {} +$a: meta.get-mixin("a"); -a {@include meta.apply($foo, 2px)} +a {@include meta.apply($a, 2px)} -<===> too-many-args/error +<===> too_many_args/error Error: Only 0 arguments allowed, but 1 was passed. , -3 | @mixin foo {} - | === declaration +3 | @mixin a {} + | = declaration ... | -6 | a {@include meta.apply($foo, 2px)} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation +6 | a {@include meta.apply($a, 2px)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation ' - input.scss 6:4 foo() + input.scss 6:4 a() input.scss 6:4 root stylesheet <===> ================================================================================ -<===> missing-mixin-args/input.scss +<===> missing_mixin_args/input.scss @use "sass:meta"; -@mixin foo($a) {} -$foo: meta.get-mixin("foo"); +@mixin a($a) {} +$a: meta.get-mixin("a"); -a {@include meta.apply($foo)} +a {@include meta.apply($a)} -<===> missing-mixin-args/error +<===> missing_mixin_args/error Error: Missing argument $a. , -3 | @mixin foo($a) {} - | ======= declaration +3 | @mixin a($a) {} + | ===== declaration ... | -6 | a {@include meta.apply($foo)} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ invocation +6 | a {@include meta.apply($a)} + | ^^^^^^^^^^^^^^^^^^^^^^^ invocation ' - input.scss 6:4 foo() + input.scss 6:4 a() input.scss 6:4 root stylesheet <===> ================================================================================ -<===> too-many-args-mixin-accepts-args/input.scss +<===> too_many_args_mixin_accepts_args/input.scss @use "sass:meta"; -@mixin foo($a) {} -$foo: meta.get-mixin("foo"); +@mixin a($a) {} +$a: meta.get-mixin("a"); -a {@include meta.apply($foo, 2px, 3px)} +a {@include meta.apply($a, 2px, 3px)} -<===> too-many-args-mixin-accepts-args/error +<===> too_many_args_mixin_accepts_args/error Error: Only 1 argument allowed, but 2 were passed. , -3 | @mixin foo($a) {} - | ======= declaration +3 | @mixin a($a) {} + | ===== declaration ... | -6 | a {@include meta.apply($foo, 2px, 3px)} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation +6 | a {@include meta.apply($a, 2px, 3px)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation ' - input.scss 6:4 foo() + input.scss 6:4 a() input.scss 6:4 root stylesheet diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index e1f07aaf18..9183ec30e9 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -1,106 +1,108 @@ -<===> passes-content/input.scss +<===> passes_content/input.scss @use "sass:meta"; -@mixin foo { +@mixin a { + b { @content; + } } a { - @include meta.apply(meta.get-mixin("foo")) { - b: red; - } + @include meta.apply(meta.get-mixin("a")) { + b: red; + } } -<===> passes-content/output.css -a { +<===> passes_content/output.css +a b { b: red; } <===> ================================================================================ -<===> passes-empty-content/input.scss +<===> passes_empty_content/input.scss @use "sass:meta"; -@mixin foo { - @content; +@mixin a { + @content; } a { - @include meta.apply(meta.get-mixin("foo")) {} + @include meta.apply(meta.get-mixin("a")) {} } -<===> passes-empty-content/output.css +<===> passes_empty_content/output.css <===> ================================================================================ -<===> denies-content/user-defined/input.scss +<===> denies_content/user_defined/input.scss @use "sass:meta"; -@mixin foo {} +@mixin a {} a { - @include meta.apply(meta.get-mixin("foo")) {} + @include meta.apply(meta.get-mixin("a")) {} } -<===> denies-content/user-defined/error +<===> denies_content/user_defined/error Error: Mixin doesn't accept a content block. , -2 | @mixin foo {} - | === declaration +2 | @mixin a {} + | = declaration ... | -5 | @include meta.apply(meta.get-mixin("foo")) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation +5 | @include meta.apply(meta.get-mixin("a")) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation ' - input.scss 5:5 root stylesheet + input.scss 5:3 root stylesheet <===> ================================================================================ -<===> denies-content/builtin/input.scss +<===> denies_content/builtin/input.scss @use "sass:meta"; a { - @include meta.apply(meta.get-mixin(load-css, meta), "foo") { - a: b; - } + @include meta.apply(meta.get-mixin(load-css, meta), "a") { + a: b; + } } -<===> denies-content/builtin/error +<===> denies_content/builtin/error Error: Mixin doesn't accept a content block. ,--> input.scss -4 | @include meta.apply(meta.get-mixin(load-css, meta), "foo") { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation +4 | @include meta.apply(meta.get-mixin(load-css, meta), "a") { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation ' ,--> sass:meta 1 | @mixin load-css($url, $with: null) { | =========================== declaration ' - input.scss 4:5 root stylesheet + input.scss 4:3 root stylesheet <===> ================================================================================ -<===> scope/redeclare-vars/input.scss +<===> scope/redeclare/vars/input.scss @use "sass:meta"; -@mixin foo($a: a) { - $b: b; - @content; - a: $a; - b: $b; +@mixin a($a: a) { + $b: b; + @content; + a: $a; + b: $b; } $c: c; a { - $d: d; - @include meta.apply(meta.get-mixin("foo")) { - $a: x; - $b: x; - $c: x; - $d: x; - } - c: $c; - d: $d; -} - -<===> scope/redeclare-vars/output.css + $d: d; + @include meta.apply(meta.get-mixin("a")) { + $a: x; + $b: x; + $c: x; + $d: x; + } + c: $c; + d: $d; +} + +<===> scope/redeclare/vars/output.css a { a: a; b: b; @@ -112,19 +114,19 @@ a { ================================================================================ <===> scope/redeclare/using/input.scss @use "sass:meta"; -@mixin foo($a: x) { - @content(a); +@mixin a($a: x) { + @content(a); } $a: y; a { - $a: z; - @include meta.apply(meta.get-mixin("foo")) using ($a) { - a: $a; - $a: a; - } - b: $a; + $a: z; + @include meta.apply(meta.get-mixin("a")) using ($a) { + a: $a; + $a: a; + } + b: $a; } <===> scope/redeclare/using/output.css @@ -135,37 +137,37 @@ a { <===> ================================================================================ -<===> scope/fall-through/input.scss +<===> scope/fall_through/input.scss @use "sass:meta"; $b: x; -@mixin foo { - @content(x); - b: $b; +@mixin a { + @content(x); + b: $b; } -@mixin bar { - $b: a; - @include meta.apply(meta.get-mixin(foo)) using ($a) { - @content($a); - } +@mixin b { + $b: a; + @include meta.apply(meta.get-mixin(a)) using ($a) { + @content($a); + } } @mixin baz { - $b: b; - @include meta.apply(meta.get-mixin(bar)) using ($a) { - @content($a); - } + $b: b; + @include meta.apply(meta.get-mixin(b)) using ($a) { + @content($a); + } } a { - $b: c; - @include meta.apply(meta.get-mixin(baz)) using ($a) { - a: $a; - } + $b: c; + @include meta.apply(meta.get-mixin(baz)) using ($a) { + a: $a; + } } -<===> scope/fall-through/output.css +<===> scope/fall_through/output.css a { a: x; b: x; diff --git a/spec/core_functions/meta/get_mixin/different_module.hrx b/spec/core_functions/meta/get_mixin/different_module.hrx index 3114ae1112..cdb89da46e 100644 --- a/spec/core_functions/meta/get_mixin/different_module.hrx +++ b/spec/core_functions/meta/get_mixin/different_module.hrx @@ -1,10 +1,10 @@ <===> defined/input.scss @use "sass:meta"; -@use "foo"; -a {@include meta.apply(meta.get-mixin("foo", $module: "foo"), #abcdef)} +@use "other"; +a {@include meta.apply(meta.get-mixin("a", $module: "other"), #abcdef)} -<===> defined/foo.scss -@mixin foo($color) { +<===> defined/_other.scss +@mixin a($color) { b: red($color) } @@ -17,11 +17,11 @@ a { ================================================================================ <===> chosen_prefix/input.scss @use "sass:meta"; -@use "foo" as a; -b {@include meta.apply(meta.get-mixin("foo", $module: "a"), #abcdef)} +@use "other" as a; +b {@include meta.apply(meta.get-mixin("a", $module: "a"), #abcdef)} -<===> chosen_prefix/foo.scss -@mixin foo($color) { +<===> chosen_prefix/_other.scss +@mixin a($color) { c: red($color) } @@ -121,11 +121,11 @@ a { ================================================================================ <===> named/input.scss @use "sass:meta"; -@use "foo"; -a {@include meta.apply(meta.get-mixin($name: "foo", $module: "foo"), #abcdef)} +@use "other"; +a {@include meta.apply(meta.get-mixin($name: "a", $module: "other"), #abcdef)} -<===> named/foo.scss -@mixin foo($color) { +<===> named/_other.scss +@mixin a($color) { b: red($color) } diff --git a/spec/core_functions/meta/get_mixin/equality.hrx b/spec/core_functions/meta/get_mixin/equality.hrx index 81df3a423f..6e0e0736dc 100644 --- a/spec/core_functions/meta/get_mixin/equality.hrx +++ b/spec/core_functions/meta/get_mixin/equality.hrx @@ -1,7 +1,7 @@ <===> same_value/input.scss @use "sass:meta"; -@mixin foo() {} -$a: meta.get-mixin(foo); +@mixin a() {} +$a: meta.get-mixin(a); a {b: $a == $a} <===> same_value/output.css @@ -24,8 +24,7 @@ a { ================================================================================ <===> built_in/different/input.scss @use "sass:meta"; -@mixin foo() {} -a {b: meta.get-mixin(load-css, meta) == meta.get-mixin(foo)} +a {b: meta.get-mixin(load-css, meta) == meta.get-mixin(apply, meta)} <===> built_in/different/output.css a { diff --git a/spec/core_functions/meta/get_mixin/error.hrx b/spec/core_functions/meta/get_mixin/error.hrx index 377389a5cb..d3ca1dea47 100644 --- a/spec/core_functions/meta/get_mixin/error.hrx +++ b/spec/core_functions/meta/get_mixin/error.hrx @@ -28,16 +28,16 @@ Error: $module: 1 is not a string. ================================================================================ <===> argument/mixin_ref/input.scss @use "sass:meta"; -@mixin foo() {} +@mixin a() {} -$foo-ref: meta.get-mixin(foo); -a {b: meta.get-mixin($foo-ref)} +$a-ref: meta.get-mixin(a); +a {b: meta.get-mixin($a-ref)} <===> argument/mixin_ref/error -Error: $name: get-mixin("foo") is not a string. +Error: $name: get-mixin("a") is not a string. , -5 | a {b: meta.get-mixin($foo-ref)} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +5 | a {b: meta.get-mixin($a-ref)} + | ^^^^^^^^^^^^^^^^^^^^^^ ' input.scss 5:7 root stylesheet @@ -141,15 +141,15 @@ Error: Mixin not found: c ================================================================================ <===> division/input.scss @use "sass:meta"; -@mixin foo() {} -@mixin bar() {} -a {b: meta.get-mixin(foo) / meta.get-mixin(bar)} +@mixin a() {} +@mixin b() {} +a {b: meta.get-mixin(a) / meta.get-mixin(b)} <===> division/error -Error: get-mixin("foo") isn't a valid CSS value. +Error: get-mixin("a") isn't a valid CSS value. , -4 | a {b: meta.get-mixin(foo) / meta.get-mixin(bar)} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4 | a {b: meta.get-mixin(a) / meta.get-mixin(b)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' input.scss 4:7 root stylesheet diff --git a/spec/core_functions/meta/get_mixin/meta.hrx b/spec/core_functions/meta/get_mixin/meta.hrx index dc99b316bf..e8afedce5f 100644 --- a/spec/core_functions/meta/get_mixin/meta.hrx +++ b/spec/core_functions/meta/get_mixin/meta.hrx @@ -1,19 +1,19 @@ <===> inspect/input.scss @use "sass:meta"; -@mixin foo() {} -a {b: inspect(meta.get-mixin(foo))}; +@mixin a() {} +a {b: inspect(meta.get-mixin(a))}; <===> inspect/output.css a { - b: get-mixin("foo"); + b: get-mixin("a"); } <===> ================================================================================ <===> type_of/input.scss @use "sass:meta"; -@mixin foo() {} -a {b: type-of(meta.get-mixin(foo))}; +@mixin a() {} +a {b: type-of(meta.get-mixin(a))}; <===> type_of/output.css a { diff --git a/spec/core_functions/meta/get_mixin/scope.hrx b/spec/core_functions/meta/get_mixin/scope.hrx index 1940d48bdf..c19afa9f49 100644 --- a/spec/core_functions/meta/get_mixin/scope.hrx +++ b/spec/core_functions/meta/get_mixin/scope.hrx @@ -48,15 +48,15 @@ a { <===> ================================================================================ -<===> scope/doesnt-capture-global/input.scss +<===> scope/doesnt_capture_global/input.scss @use "sass:meta"; $a: x; -@mixin foo { +@mixin a { a: $a; } -$ref: meta.get-mixin("foo"); +$ref: meta.get-mixin("a"); $a: y; @@ -64,30 +64,30 @@ a { @include meta.apply($ref); } -<===> scope/doesnt-capture-global/output.css +<===> scope/doesnt_capture_global/output.css a { a: y; } <===> ================================================================================ -<===> scope/doesnt-capture-local/input.scss +<===> scope/doesnt_capture_local/input.scss @use "sass:meta"; a { $a: x; - @mixin foo { + @mixin a { a: $a; } - $ref: meta.get-mixin("foo"); + $ref: meta.get-mixin("a"); $a: y; @include meta.apply($ref); } -<===> scope/doesnt-capture-local/output.css +<===> scope/doesnt_capture_local/output.css a { a: y; } diff --git a/spec/core_functions/meta/load_css/error/content.hrx b/spec/core_functions/meta/load_css/error/content.hrx index eefcbfacf2..49fda0c865 100644 --- a/spec/core_functions/meta/load_css/error/content.hrx +++ b/spec/core_functions/meta/load_css/error/content.hrx @@ -1,14 +1,14 @@ <===> input.scss @use "sass:meta"; -@include meta.load-css("foo") {}; +@include meta.load-css("other") {}; -<===> foo.scss +<===> _other.scss <===> error Error: Mixin doesn't accept a content block. ,--> input.scss -2 | @include meta.load-css("foo") {}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation +2 | @include meta.load-css("other") {}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation ' ,--> sass:meta 1 | @mixin load-css($url, $with: null) { diff --git a/spec/core_functions/meta/module_mixins.hrx b/spec/core_functions/meta/module_mixins.hrx index 15bdecf431..edcdac0ec3 100644 --- a/spec/core_functions/meta/module_mixins.hrx +++ b/spec/core_functions/meta/module_mixins.hrx @@ -3,7 +3,7 @@ :todo: - sass/libsass#2807 -<===> _util.scss +<===> _utils.scss @use "sass:meta"; @mixin print-mixin-map($mixins) { @@ -30,14 +30,42 @@ a { b: (); } +<===> +================================================================================ +<===> return_type/user_defined/input.scss +@use "sass:meta"; +@use "other"; + +a {b: meta.type-of(meta.module-mixins("other"))} + +<===> return_type/user_defined/_other.scss +// This module defines no mixins. + +<===> return_type/user_defined/output.css +a { + b: map; +} + +<===> +================================================================================ +<===> return_type/builtin/input.scss +@use "sass:meta"; + +a {b: meta.type-of(meta.module-mixins("meta"))} + +<===> return_type/builtin/output.css +a { + b: map; +} + <===> ================================================================================ <===> multiple/input.scss @use "sass:meta"; -@use "../util"; +@use "core_functions/meta/module_mixins/utils"; @use "other"; -@include util.print-mixin-map(meta.module-mixins("other")); +@include utils.print-mixin-map(meta.module-mixins("other")); <===> multiple/_other.scss @mixin b() {b: value} @@ -55,10 +83,10 @@ a { ================================================================================ <===> dash_sensitive/input.scss @use "sass:meta"; -@use "../util"; +@use "core_functions/meta/module_mixins/utils"; @use "other"; -@include util.print-mixin-map(meta.module-mixins("other")); +@include utils.print-mixin-map(meta.module-mixins("other")); <===> dash_sensitive/_other.scss @mixin b-c() {b-c: value} @@ -74,10 +102,10 @@ a { ================================================================================ <===> as/input.scss @use "sass:meta"; -@use "../util"; +@use "core_functions/meta/module_mixins/utils"; @use "other" as b; -@include util.print-mixin-map(meta.module-mixins("b")) +@include utils.print-mixin-map(meta.module-mixins("b")) <===> as/_other.scss @mixin c() {c: value} @@ -95,10 +123,10 @@ a { ================================================================================ <===> through_import/input.scss @use "sass:meta"; -@use "../util"; +@use "core_functions/meta/module_mixins/utils"; @use "used"; -@include util.print-mixin-map(meta.module-mixins("used")); +@include utils.print-mixin-map(meta.module-mixins("used")); <===> through_import/_used.scss @import "imported"; @@ -139,10 +167,10 @@ a { ================================================================================ <===> through_forward/bare/input.scss @use "sass:meta"; -@use "../../util"; +@use "../../utils"; @use "used"; -@include util.print-mixin-map(meta.module-mixins("used")); +@include utils.print-mixin-map(meta.module-mixins("used")); <===> through_forward/bare/_used.scss @forward "forwarded"; @@ -163,10 +191,10 @@ a { ================================================================================ <===> through_forward/as/input.scss @use "sass:meta"; -@use "../../util"; +@use "../../utils"; @use "used"; -@include util.print-mixin-map(meta.module-mixins("used")); +@include utils.print-mixin-map(meta.module-mixins("used")); <===> through_forward/as/_used.scss @forward "forwarded" as b-*; @@ -187,10 +215,10 @@ a { ================================================================================ <===> through_forward/show/input.scss @use "sass:meta"; -@use "../../util"; +@use "../../utils"; @use "used"; -@include util.print-mixin-map(meta.module-mixins("used")); +@include utils.print-mixin-map(meta.module-mixins("used")); <===> through_forward/show/_used.scss @forward "forwarded" show b, c; @@ -210,10 +238,10 @@ a { ================================================================================ <===> through_forward/hide/input.scss @use "sass:meta"; -@use "../../util"; +@use "../../utils"; @use "used"; -@include util.print-mixin-map(meta.module-mixins("used")); +@include utils.print-mixin-map(meta.module-mixins("used")); <===> through_forward/hide/_used.scss @forward "forwarded" hide b, c; @@ -232,10 +260,10 @@ a { ================================================================================ <===> named/input.scss @use "sass:meta"; -@use "../util"; +@use "core_functions/meta/module_mixins/utils"; @use "other"; -@include util.print-mixin-map(meta.module-mixins($module: "other")); +@include utils.print-mixin-map(meta.module-mixins($module: "other")); <===> named/_other.scss @mixin b() {b: value} diff --git a/spec/core_functions/meta/type_of.hrx b/spec/core_functions/meta/type_of.hrx index fb46fcda38..fa436879b2 100644 --- a/spec/core_functions/meta/type_of.hrx +++ b/spec/core_functions/meta/type_of.hrx @@ -186,8 +186,8 @@ a { <===> mixin/input.scss @use "sass:meta"; -@mixin foo() {} -a {b: type-of(meta.get-mixin(foo))} +@mixin a() {} +a {b: type-of(meta.get-mixin(a))} <===> mixin/output.css a { From 565122a60a592c696677751c538aadcd82bc3e72 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 22 Sep 2023 18:31:30 +0000 Subject: [PATCH 14/32] more pr review --- spec/core_functions/meta/accepts_content.hrx | 70 ++++++++++++++++- spec/core_functions/meta/apply.hrx | 24 +++--- .../core_functions/meta/get_mixin/content.hrx | 36 ++++----- spec/core_functions/meta/get_mixin/error.hrx | 46 +---------- spec/core_functions/meta/get_mixin/meta.hrx | 21 ----- spec/core_functions/meta/get_mixin/scope.hrx | 26 +++---- spec/core_functions/meta/inspect/mixin.hrx | 18 +++++ spec/core_functions/meta/type_of.hrx | 13 +++- spec/values/mixins.hrx | 77 +++++++++++++++++++ 9 files changed, 219 insertions(+), 112 deletions(-) delete mode 100644 spec/core_functions/meta/get_mixin/meta.hrx create mode 100644 spec/core_functions/meta/inspect/mixin.hrx create mode 100644 spec/values/mixins.hrx diff --git a/spec/core_functions/meta/accepts_content.hrx b/spec/core_functions/meta/accepts_content.hrx index 95b9b530d4..970dbd9f5a 100644 --- a/spec/core_functions/meta/accepts_content.hrx +++ b/spec/core_functions/meta/accepts_content.hrx @@ -8,9 +8,7 @@ <===> accepts/direct_child/input.scss @use "sass:meta"; -@mixin a() { - @content; -} +@mixin a() {@content;} a {b: meta.accepts-content(meta.get-mixin("a"))} @@ -74,3 +72,69 @@ a {b: meta.accepts-content(meta.get-mixin(load-css, meta))} a { b: false; } + +<===> +================================================================================ +<===> args/keyword/input.scss +@use "sass:meta"; + +a {b: meta.accepts-content($mixin: meta.get-mixin(apply, meta))} + +<===> args/keyword/output.css +a { + b: true; +} + +<===> +================================================================================ +<===> error/args/too_few/input.scss +@use "sass:meta"; + +a {b: meta.accepts-content()} + +<===> error/args/too_few/error +Error: Missing argument $mixin. + ,--> input.scss +3 | a {b: meta.accepts-content()} + | ^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @function accepts-content($mixin) { + | ======================= declaration + ' + input.scss 3:7 root stylesheet + +<===> +================================================================================ +<===> error/args/too_many/input.scss +@use "sass:meta"; +@mixin a() {} + +a {b: meta.accepts-content(a, a)} + +<===> error/args/too_many/error +Error: Only 1 argument allowed, but 2 were passed. + ,--> input.scss +4 | a {b: meta.accepts-content(a, a)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @function accepts-content($mixin) { + | ======================= declaration + ' + input.scss 4:7 root stylesheet + +<===> +================================================================================ +<===> error/args/wrong_type/input.scss +@use "sass:meta"; + +a {b: meta.accepts-content(meta.get-function("red"))} + +<===> error/args/wrong_type/error +Error: $mixin: get-function("red") is not a mixin reference. + , +3 | a {b: meta.accepts-content(meta.get-function("red"))} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 3:7 root stylesheet diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 07887691a4..09650aba98 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -5,7 +5,7 @@ <===> ================================================================================ -<===> use_as_function/input.scss +<===> error/use_as_function/input.scss @use "sass:meta"; @mixin a {} @@ -13,7 +13,7 @@ $a: meta.get-mixin("a"); a {b: meta.apply($a)} -<===> use_as_function/error +<===> error/use_as_function/error Error: Undefined function. , 6 | a {b: meta.apply($a)} @@ -23,12 +23,12 @@ Error: Undefined function. <===> ================================================================================ -<===> no_args/input.scss +<===> error/no_args/input.scss @use "sass:meta"; a {@include meta.apply()} -<===> no_args/error +<===> error/no_args/error Error: Missing argument $mixin. ,--> input.scss 3 | a {@include meta.apply()} @@ -42,12 +42,12 @@ Error: Missing argument $mixin. <===> ================================================================================ -<===> wrong_arg_type/input.scss +<===> error/wrong_arg_type/input.scss @use "sass:meta"; a {@include meta.apply(2px)} -<===> wrong_arg_type/error +<===> error/wrong_arg_type/error Error: $mixin: 2px is not a mixin reference. , 3 | a {@include meta.apply(2px)} @@ -57,7 +57,7 @@ Error: $mixin: 2px is not a mixin reference. <===> ================================================================================ -<===> too_many_args/input.scss +<===> error/too_many_args/input.scss @use "sass:meta"; @mixin a {} @@ -65,7 +65,7 @@ $a: meta.get-mixin("a"); a {@include meta.apply($a, 2px)} -<===> too_many_args/error +<===> error/too_many_args/error Error: Only 0 arguments allowed, but 1 was passed. , 3 | @mixin a {} @@ -79,7 +79,7 @@ Error: Only 0 arguments allowed, but 1 was passed. <===> ================================================================================ -<===> missing_mixin_args/input.scss +<===> error/missing_mixin_args/input.scss @use "sass:meta"; @mixin a($a) {} @@ -87,7 +87,7 @@ $a: meta.get-mixin("a"); a {@include meta.apply($a)} -<===> missing_mixin_args/error +<===> error/missing_mixin_args/error Error: Missing argument $a. , 3 | @mixin a($a) {} @@ -101,7 +101,7 @@ Error: Missing argument $a. <===> ================================================================================ -<===> too_many_args_mixin_accepts_args/input.scss +<===> error/too_many_args_mixin_accepts_args/input.scss @use "sass:meta"; @mixin a($a) {} @@ -109,7 +109,7 @@ $a: meta.get-mixin("a"); a {@include meta.apply($a, 2px, 3px)} -<===> too_many_args_mixin_accepts_args/error +<===> error/too_many_args_mixin_accepts_args/error Error: Only 1 argument allowed, but 2 were passed. , 3 | @mixin a($a) {} diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index 9183ec30e9..520c0e6ec9 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -23,9 +23,7 @@ a b { <===> passes_empty_content/input.scss @use "sass:meta"; -@mixin a { - @content; -} +@mixin a {@content;} a { @include meta.apply(meta.get-mixin("a")) {} @@ -81,33 +79,33 @@ Error: Mixin doesn't accept a content block. ================================================================================ <===> scope/redeclare/vars/input.scss @use "sass:meta"; -@mixin a($a: a) { - $b: b; +@mixin a($param: param) { + $in-mixin: in-mixin; @content; - a: $a; - b: $b; + param: $param; + in-mixin: $in-mixin; } -$c: c; +$global: global; a { - $d: d; + $in-style-rule: in-style-rule; @include meta.apply(meta.get-mixin("a")) { - $a: x; - $b: x; - $c: x; - $d: x; + $param: x; + $in-mixin: x; + $global: x; + $in-style-rule: x; } - c: $c; - d: $d; + global: $global; + in-style-rule: $in-style-rule; } <===> scope/redeclare/vars/output.css a { - a: a; - b: b; - c: c; - d: x; + param: param; + in-mixin: in-mixin; + global: global; + in-style-rule: x; } <===> diff --git a/spec/core_functions/meta/get_mixin/error.hrx b/spec/core_functions/meta/get_mixin/error.hrx index d3ca1dea47..765ed6f078 100644 --- a/spec/core_functions/meta/get_mixin/error.hrx +++ b/spec/core_functions/meta/get_mixin/error.hrx @@ -63,19 +63,19 @@ Error: Missing argument $name. ================================================================================ <===> argument/too_many/input.scss @use "sass:meta"; -a {b: meta.get-mixin(c, true, d, e)} +a {b: meta.inspect(meta.get-mixin(c, true, d, e))} <===> argument/too_many/error Error: Only 2 arguments allowed, but 4 were passed. ,--> input.scss -2 | a {b: meta.get-mixin(c, true, d, e)} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation +2 | a {b: meta.inspect(meta.get-mixin(c, true, d, e))} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation ' ,--> sass:meta 1 | @function get-mixin($name, $module: null) { | =============================== declaration ' - input.scss 2:7 root stylesheet + input.scss 2:20 root stylesheet <===> ================================================================================ @@ -137,44 +137,6 @@ Error: Mixin not found: c ' input.scss 4:23 root stylesheet -<===> -================================================================================ -<===> division/input.scss -@use "sass:meta"; -@mixin a() {} -@mixin b() {} -a {b: meta.get-mixin(a) / meta.get-mixin(b)} - -<===> division/error -Error: get-mixin("a") isn't a valid CSS value. - , -4 | a {b: meta.get-mixin(a) / meta.get-mixin(b)} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - ' - input.scss 4: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: get-mixin("add-two") is not a string. - , -9 | error: meta.get-mixin($add-two-mixin); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - ' - input.scss 9:10 root stylesheet - <===> ================================================================================ <===> conflict/input.scss diff --git a/spec/core_functions/meta/get_mixin/meta.hrx b/spec/core_functions/meta/get_mixin/meta.hrx deleted file mode 100644 index e8afedce5f..0000000000 --- a/spec/core_functions/meta/get_mixin/meta.hrx +++ /dev/null @@ -1,21 +0,0 @@ -<===> inspect/input.scss -@use "sass:meta"; -@mixin a() {} -a {b: inspect(meta.get-mixin(a))}; - -<===> inspect/output.css -a { - b: get-mixin("a"); -} - -<===> -================================================================================ -<===> type_of/input.scss -@use "sass:meta"; -@mixin a() {} -a {b: type-of(meta.get-mixin(a))}; - -<===> type_of/output.css -a { - b: mixin; -} diff --git a/spec/core_functions/meta/get_mixin/scope.hrx b/spec/core_functions/meta/get_mixin/scope.hrx index c19afa9f49..d9bc17eaee 100644 --- a/spec/core_functions/meta/get_mixin/scope.hrx +++ b/spec/core_functions/meta/get_mixin/scope.hrx @@ -48,12 +48,12 @@ a { <===> ================================================================================ -<===> scope/doesnt_capture_global/input.scss +<===> scope/mutated_global/input.scss @use "sass:meta"; $a: x; @mixin a { - a: $a; + a: $a; } $ref: meta.get-mixin("a"); @@ -61,33 +61,33 @@ $ref: meta.get-mixin("a"); $a: y; a { - @include meta.apply($ref); + @include meta.apply($ref); } -<===> scope/doesnt_capture_global/output.css +<===> scope/mutated_global/output.css a { a: y; } <===> ================================================================================ -<===> scope/doesnt_capture_local/input.scss +<===> scope/mutated_local/input.scss @use "sass:meta"; a { - $a: x; + $a: x; - @mixin a { - a: $a; - } + @mixin a { + a: $a; + } - $ref: meta.get-mixin("a"); + $ref: meta.get-mixin("a"); - $a: y; - @include meta.apply($ref); + $a: y; + @include meta.apply($ref); } -<===> scope/doesnt_capture_local/output.css +<===> scope/mutated_local/output.css a { a: y; } diff --git a/spec/core_functions/meta/inspect/mixin.hrx b/spec/core_functions/meta/inspect/mixin.hrx new file mode 100644 index 0000000000..a8a828a9d2 --- /dev/null +++ b/spec/core_functions/meta/inspect/mixin.hrx @@ -0,0 +1,18 @@ +<===> user_defined/input.scss +@use "sass:meta"; +@mixin a() {} +a {b: inspect(meta.get-mixin(a))}; + +<===> user_defined/output.css +a { + b: get-mixin("a"); +} + +<===> builtin/input.scss +@use "sass:meta"; +a {b: inspect(meta.get-mixin(load-css, meta))}; + +<===> builtin/output.css +a { + b: get-mixin("load-css"); +} diff --git a/spec/core_functions/meta/type_of.hrx b/spec/core_functions/meta/type_of.hrx index fa436879b2..56c1235ca1 100644 --- a/spec/core_functions/meta/type_of.hrx +++ b/spec/core_functions/meta/type_of.hrx @@ -184,12 +184,21 @@ a { :todo: - sass/libsass#2807 -<===> mixin/input.scss +<===> mixin/user_defined/input.scss @use "sass:meta"; @mixin a() {} a {b: type-of(meta.get-mixin(a))} -<===> mixin/output.css +<===> mixin/user_defined/output.css +a { + b: mixin; +} + +<===> mixin/builtin/input.scss +@use "sass:meta"; +a {b: type-of(meta.get-mixin(load-css, meta))} + +<===> mixin/builtin/output.css a { b: mixin; } diff --git a/spec/values/mixins.hrx b/spec/values/mixins.hrx new file mode 100644 index 0000000000..5e8376dd29 --- /dev/null +++ b/spec/values/mixins.hrx @@ -0,0 +1,77 @@ +<===> addition/input.scss +@use "sass:meta"; +@mixin a() {} +@mixin b() {} +a {b: meta.get-mixin(a) + meta.get-mixin(b)} + +<===> addition/error +Error: get-mixin("a") isn't a valid CSS value. + , +4 | a {b: meta.get-mixin(a) + meta.get-mixin(b)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 4:7 root stylesheet + +<===> +================================================================================ +<===> subtraction/input.scss +@use "sass:meta"; +@mixin a() {} +@mixin b() {} +a {b: meta.get-mixin(a) - meta.get-mixin(b)} + +<===> subtraction/error +Error: get-mixin("a") isn't a valid CSS value. + , +4 | a {b: meta.get-mixin(a) - meta.get-mixin(b)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 4:7 root stylesheet + +<===> +================================================================================ +<===> multiplication/input.scss +@use "sass:meta"; +@mixin a() {} +@mixin b() {} +a {b: meta.get-mixin(a) * meta.get-mixin(b)} + +<===> multiplication/error +Error: Undefined operation "get-mixin("a") * get-mixin("b")". + , +4 | a {b: meta.get-mixin(a) * meta.get-mixin(b)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 4:7 root stylesheet + +<===> +================================================================================ +<===> division/input.scss +@use "sass:meta"; +@mixin a() {} +@mixin b() {} +a {b: meta.get-mixin(a) / meta.get-mixin(b)} + +<===> division/error +Error: get-mixin("a") isn't a valid CSS value. + , +4 | a {b: meta.get-mixin(a) / meta.get-mixin(b)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 4:7 root stylesheet + +<===> +================================================================================ +<===> modulo/input.scss +@use "sass:meta"; +@mixin a() {} +@mixin b() {} +a {b: meta.get-mixin(a) % meta.get-mixin(b)} + +<===> modulo/error +Error: Undefined operation "get-mixin("a") % get-mixin("b")". + , +4 | a {b: meta.get-mixin(a) % meta.get-mixin(b)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ' + input.scss 4:7 root stylesheet From bdf1d4fd0dd219df5f09118b2ab6cb6d2c8b8b59 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 22 Sep 2023 18:44:27 +0000 Subject: [PATCH 15/32] fix lint --- spec/core_functions/meta/inspect/mixin.hrx | 2 ++ spec/core_functions/meta/type_of.hrx | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/spec/core_functions/meta/inspect/mixin.hrx b/spec/core_functions/meta/inspect/mixin.hrx index a8a828a9d2..8268807778 100644 --- a/spec/core_functions/meta/inspect/mixin.hrx +++ b/spec/core_functions/meta/inspect/mixin.hrx @@ -8,6 +8,8 @@ a { b: get-mixin("a"); } +<===> +================================================================================ <===> builtin/input.scss @use "sass:meta"; a {b: inspect(meta.get-mixin(load-css, meta))}; diff --git a/spec/core_functions/meta/type_of.hrx b/spec/core_functions/meta/type_of.hrx index 56c1235ca1..6355989e83 100644 --- a/spec/core_functions/meta/type_of.hrx +++ b/spec/core_functions/meta/type_of.hrx @@ -184,6 +184,8 @@ a { :todo: - sass/libsass#2807 +<===> +================================================================================ <===> mixin/user_defined/input.scss @use "sass:meta"; @mixin a() {} @@ -194,6 +196,8 @@ a { b: mixin; } +<===> +================================================================================ <===> mixin/builtin/input.scss @use "sass:meta"; a {b: type-of(meta.get-mixin(load-css, meta))} From ff5560f120facd1a4ac03faf16941ff7414a5a6d Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 22 Sep 2023 18:58:39 +0000 Subject: [PATCH 16/32] ignore libsass --- spec/core_functions/meta/inspect/mixin.hrx | 5 +++++ spec/values/mixins.hrx | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/spec/core_functions/meta/inspect/mixin.hrx b/spec/core_functions/meta/inspect/mixin.hrx index 8268807778..61acef404c 100644 --- a/spec/core_functions/meta/inspect/mixin.hrx +++ b/spec/core_functions/meta/inspect/mixin.hrx @@ -1,3 +1,8 @@ +<===> options.yml +--- +:todo: +- sass/libsass#2807 + <===> user_defined/input.scss @use "sass:meta"; @mixin a() {} diff --git a/spec/values/mixins.hrx b/spec/values/mixins.hrx index 5e8376dd29..4432f51b71 100644 --- a/spec/values/mixins.hrx +++ b/spec/values/mixins.hrx @@ -1,3 +1,8 @@ +<===> options.yml +--- +:todo: +- sass/libsass#2807 + <===> addition/input.scss @use "sass:meta"; @mixin a() {} From 2617471c975b83750d89bbe47219c35b94e5c3b5 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 22 Sep 2023 19:06:11 +0000 Subject: [PATCH 17/32] add apply tests --- spec/core_functions/meta/apply.hrx | 71 ++++++++++++++++++++++ spec/core_functions/meta/inspect/mixin.hrx | 2 + spec/values/mixins.hrx | 2 + 3 files changed, 75 insertions(+) diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 09650aba98..1e089c80d5 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -3,6 +3,77 @@ :todo: - sass/libsass#2807 +<===> +================================================================================ +<===> args/named/input.scss +@use "sass:meta"; + +@mixin a { + b: c; +} + +a {@include meta.apply($mixin: meta.get-mixin("a"))} + +<===> args/named/output.css +a { + b: c; +} + +<===> +================================================================================ +<===> args/passes_positional/input.scss +@use "sass:meta"; + +@mixin a($a) { + b: $a; +} + +a {@include meta.apply(meta.get-mixin("a"), c)} + +<===> args/passes_positional/output.css +a { + b: c; +} + +<===> +================================================================================ +<===> args/passes_named/input.scss +@use "sass:meta"; + +@mixin a($a) { + b: $a; +} + +a {@include meta.apply(meta.get-mixin("a"), $a: c)} + +<===> args/passes_named/output.css +a { + b: c; +} + +<===> +================================================================================ +<===> error/wrong_named_arg/input.scss +@use "sass:meta"; + +@mixin a($a) { + b: $a; +} + +a {@include meta.apply(meta.get-mixin("a"), $b: c)} + +<===> error/wrong_named_arg/error +Error: Missing argument $a. + , +3 | @mixin a($a) { + | ===== declaration +... | +7 | a {@include meta.apply(meta.get-mixin("a"), $b: c)} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + input.scss 7:4 a() + input.scss 7:4 root stylesheet + <===> ================================================================================ <===> error/use_as_function/input.scss diff --git a/spec/core_functions/meta/inspect/mixin.hrx b/spec/core_functions/meta/inspect/mixin.hrx index 61acef404c..2a891f049b 100644 --- a/spec/core_functions/meta/inspect/mixin.hrx +++ b/spec/core_functions/meta/inspect/mixin.hrx @@ -3,6 +3,8 @@ :todo: - sass/libsass#2807 +<===> +================================================================================ <===> user_defined/input.scss @use "sass:meta"; @mixin a() {} diff --git a/spec/values/mixins.hrx b/spec/values/mixins.hrx index 4432f51b71..55d9a19abc 100644 --- a/spec/values/mixins.hrx +++ b/spec/values/mixins.hrx @@ -3,6 +3,8 @@ :todo: - sass/libsass#2807 +<===> +================================================================================ <===> addition/input.scss @use "sass:meta"; @mixin a() {} From ad746a1f969f231307cb45f45d32305182822bca Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 22 Sep 2023 19:13:51 +0000 Subject: [PATCH 18/32] make more things be on a single line --- spec/core_functions/meta/apply.hrx | 12 +++--------- spec/core_functions/meta/get_mixin/content.hrx | 4 +--- .../meta/get_mixin/different_module.hrx | 12 +++--------- spec/core_functions/meta/get_mixin/scope.hrx | 8 ++------ 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 1e089c80d5..3b5250e6a9 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -24,9 +24,7 @@ a { <===> args/passes_positional/input.scss @use "sass:meta"; -@mixin a($a) { - b: $a; -} +@mixin a($a) {b: $a} a {@include meta.apply(meta.get-mixin("a"), c)} @@ -40,9 +38,7 @@ a { <===> args/passes_named/input.scss @use "sass:meta"; -@mixin a($a) { - b: $a; -} +@mixin a($a) {b: $a} a {@include meta.apply(meta.get-mixin("a"), $a: c)} @@ -56,9 +52,7 @@ a { <===> error/wrong_named_arg/input.scss @use "sass:meta"; -@mixin a($a) { - b: $a; -} +@mixin a($a) {b: $a} a {@include meta.apply(meta.get-mixin("a"), $b: c)} diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index 520c0e6ec9..cb0b672be7 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -112,9 +112,7 @@ a { ================================================================================ <===> scope/redeclare/using/input.scss @use "sass:meta"; -@mixin a($a: x) { - @content(a); -} +@mixin a($a: x) {@content(a);} $a: y; diff --git a/spec/core_functions/meta/get_mixin/different_module.hrx b/spec/core_functions/meta/get_mixin/different_module.hrx index cdb89da46e..a963879124 100644 --- a/spec/core_functions/meta/get_mixin/different_module.hrx +++ b/spec/core_functions/meta/get_mixin/different_module.hrx @@ -4,9 +4,7 @@ a {@include meta.apply(meta.get-mixin("a", $module: "other"), #abcdef)} <===> defined/_other.scss -@mixin a($color) { - b: red($color) -} +@mixin a($color) {b: red($color)} <===> defined/output.css a { @@ -21,9 +19,7 @@ a { b {@include meta.apply(meta.get-mixin("a", $module: "a"), #abcdef)} <===> chosen_prefix/_other.scss -@mixin a($color) { - c: red($color) -} +@mixin a($color) {c: red($color)} <===> chosen_prefix/output.css b { @@ -125,9 +121,7 @@ a { a {@include meta.apply(meta.get-mixin($name: "a", $module: "other"), #abcdef)} <===> named/_other.scss -@mixin a($color) { - b: red($color) -} +@mixin a($color) {b: red($color)} <===> named/output.css a { diff --git a/spec/core_functions/meta/get_mixin/scope.hrx b/spec/core_functions/meta/get_mixin/scope.hrx index d9bc17eaee..253148e845 100644 --- a/spec/core_functions/meta/get_mixin/scope.hrx +++ b/spec/core_functions/meta/get_mixin/scope.hrx @@ -52,17 +52,13 @@ a { @use "sass:meta"; $a: x; -@mixin a { - a: $a; -} +@mixin a {a: $a} $ref: meta.get-mixin("a"); $a: y; -a { - @include meta.apply($ref); -} +a {@include meta.apply($ref);} <===> scope/mutated_global/output.css a { From ca84c9cbb3b4e1b998c1e47a42e0969c19b24615 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Sat, 23 Sep 2023 05:12:26 +0000 Subject: [PATCH 19/32] pr review --- spec/core_functions/meta/accepts_content.hrx | 6 ++--- spec/core_functions/meta/apply.hrx | 8 +++---- .../core_functions/meta/get_mixin/content.hrx | 22 +++++++++---------- spec/values/mixins.hrx | 20 ++++++++--------- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/spec/core_functions/meta/accepts_content.hrx b/spec/core_functions/meta/accepts_content.hrx index 970dbd9f5a..b25a1b8624 100644 --- a/spec/core_functions/meta/accepts_content.hrx +++ b/spec/core_functions/meta/accepts_content.hrx @@ -8,7 +8,7 @@ <===> accepts/direct_child/input.scss @use "sass:meta"; -@mixin a() {@content;} +@mixin a() {@content} a {b: meta.accepts-content(meta.get-mixin("a"))} @@ -23,9 +23,7 @@ a { @use "sass:meta"; @mixin a() { - @if false { - @content; - } + @if false {@content} } a {b: meta.accepts-content(meta.get-mixin("a"))} diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 3b5250e6a9..90b85d9485 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -59,14 +59,14 @@ a {@include meta.apply(meta.get-mixin("a"), $b: c)} <===> error/wrong_named_arg/error Error: Missing argument $a. , -3 | @mixin a($a) { +3 | @mixin a($a) {b: $a} | ===== declaration ... | -7 | a {@include meta.apply(meta.get-mixin("a"), $b: c)} +5 | a {@include meta.apply(meta.get-mixin("a"), $b: c)} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation ' - input.scss 7:4 a() - input.scss 7:4 root stylesheet + input.scss 5:4 a() + input.scss 5:4 root stylesheet <===> ================================================================================ diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index cb0b672be7..fe13d957b3 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -2,9 +2,7 @@ @use "sass:meta"; @mixin a { - b { - @content; - } + b {@content} } a { @@ -33,7 +31,7 @@ a { <===> ================================================================================ -<===> denies_content/user_defined/input.scss +<===> error/denies_content/user_defined/input.scss @use "sass:meta"; @mixin a {} @@ -41,7 +39,7 @@ a { @include meta.apply(meta.get-mixin("a")) {} } -<===> denies_content/user_defined/error +<===> error/denies_content/user_defined/error Error: Mixin doesn't accept a content block. , 2 | @mixin a {} @@ -54,7 +52,7 @@ Error: Mixin doesn't accept a content block. <===> ================================================================================ -<===> denies_content/builtin/input.scss +<===> error/denies_content/builtin/input.scss @use "sass:meta"; a { @@ -63,7 +61,7 @@ a { } } -<===> denies_content/builtin/error +<===> error/denies_content/builtin/error Error: Mixin doesn't accept a content block. ,--> input.scss 4 | @include meta.apply(meta.get-mixin(load-css, meta), "a") { @@ -91,10 +89,10 @@ $global: global; a { $in-style-rule: in-style-rule; @include meta.apply(meta.get-mixin("a")) { - $param: x; - $in-mixin: x; - $global: x; - $in-style-rule: x; + $param: in-include; + $in-mixin: in-include; + $global: in-include; + $in-style-rule: in-include; } global: $global; in-style-rule: $in-style-rule; @@ -105,7 +103,7 @@ a { param: param; in-mixin: in-mixin; global: global; - in-style-rule: x; + in-style-rule: in-include; } <===> diff --git a/spec/values/mixins.hrx b/spec/values/mixins.hrx index 55d9a19abc..fdc6029d8e 100644 --- a/spec/values/mixins.hrx +++ b/spec/values/mixins.hrx @@ -5,13 +5,13 @@ <===> ================================================================================ -<===> addition/input.scss +<===> error/addition/input.scss @use "sass:meta"; @mixin a() {} @mixin b() {} a {b: meta.get-mixin(a) + meta.get-mixin(b)} -<===> addition/error +<===> error/addition/error Error: get-mixin("a") isn't a valid CSS value. , 4 | a {b: meta.get-mixin(a) + meta.get-mixin(b)} @@ -21,13 +21,13 @@ Error: get-mixin("a") isn't a valid CSS value. <===> ================================================================================ -<===> subtraction/input.scss +<===> error/subtraction/input.scss @use "sass:meta"; @mixin a() {} @mixin b() {} a {b: meta.get-mixin(a) - meta.get-mixin(b)} -<===> subtraction/error +<===> error/subtraction/error Error: get-mixin("a") isn't a valid CSS value. , 4 | a {b: meta.get-mixin(a) - meta.get-mixin(b)} @@ -37,13 +37,13 @@ Error: get-mixin("a") isn't a valid CSS value. <===> ================================================================================ -<===> multiplication/input.scss +<===> error/multiplication/input.scss @use "sass:meta"; @mixin a() {} @mixin b() {} a {b: meta.get-mixin(a) * meta.get-mixin(b)} -<===> multiplication/error +<===> error/multiplication/error Error: Undefined operation "get-mixin("a") * get-mixin("b")". , 4 | a {b: meta.get-mixin(a) * meta.get-mixin(b)} @@ -53,13 +53,13 @@ Error: Undefined operation "get-mixin("a") * get-mixin("b")". <===> ================================================================================ -<===> division/input.scss +<===> error/division/input.scss @use "sass:meta"; @mixin a() {} @mixin b() {} a {b: meta.get-mixin(a) / meta.get-mixin(b)} -<===> division/error +<===> error/division/error Error: get-mixin("a") isn't a valid CSS value. , 4 | a {b: meta.get-mixin(a) / meta.get-mixin(b)} @@ -69,13 +69,13 @@ Error: get-mixin("a") isn't a valid CSS value. <===> ================================================================================ -<===> modulo/input.scss +<===> error/modulo/input.scss @use "sass:meta"; @mixin a() {} @mixin b() {} a {b: meta.get-mixin(a) % meta.get-mixin(b)} -<===> modulo/error +<===> error/modulo/error Error: Undefined operation "get-mixin("a") % get-mixin("b")". , 4 | a {b: meta.get-mixin(a) % meta.get-mixin(b)} From a29020919f2e8d92c01f0d4ea08d01e0e256505f Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Sat, 23 Sep 2023 18:24:06 +0000 Subject: [PATCH 20/32] add rest argument tests --- spec/core_functions/meta/apply.hrx | 36 ++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 90b85d9485..9565fcf5ff 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -21,32 +21,60 @@ a { <===> ================================================================================ -<===> args/passes_positional/input.scss +<===> args/passes/positional/input.scss @use "sass:meta"; @mixin a($a) {b: $a} a {@include meta.apply(meta.get-mixin("a"), c)} -<===> args/passes_positional/output.css +<===> args/passes/positional/output.css a { b: c; } <===> ================================================================================ -<===> args/passes_named/input.scss +<===> args/passes/named/input.scss @use "sass:meta"; @mixin a($a) {b: $a} a {@include meta.apply(meta.get-mixin("a"), $a: c)} -<===> args/passes_named/output.css +<===> args/passes/named/output.css a { b: c; } +<===> +================================================================================ +<===> args/passes/rest/positional/input.scss +@use "sass:meta"; + +@mixin a($a...) {b: $a} + +a {@include meta.apply(meta.get-mixin("a"), a, b, c)} + +<===> args/passes/rest/positional/output.css +a { + b: a, b, c; +} + +<===> +================================================================================ +<===> args/passes/rest/named/input.scss +@use "sass:meta"; + +@mixin a($a...) {b: meta.inspect(meta.keywords($a))} + +a {@include meta.apply(meta.get-mixin("a"), $a: a, $b: b, $c: c)} + +<===> args/passes/rest/named/output.css +a { + b: (a: a, b: b, c: c); +} + <===> ================================================================================ <===> error/wrong_named_arg/input.scss From 84d29a12bf417c1c25b393b0759dda44986ca031 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Sat, 23 Sep 2023 18:30:53 +0000 Subject: [PATCH 21/32] use semantic placeholders in fallthrough tests --- .../core_functions/meta/get_mixin/content.hrx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index fe13d957b3..1a06c70e3b 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -133,36 +133,36 @@ a { ================================================================================ <===> scope/fall_through/input.scss @use "sass:meta"; -$b: x; +$global: global; @mixin a { - @content(x); - b: $b; + @content(content-rule-a); + global: $global; } @mixin b { - $b: a; - @include meta.apply(meta.get-mixin(a)) using ($a) { - @content($a); + $global: in-mixin-b; + @include meta.apply(meta.get-mixin(a)) using ($content-arg) { + @content($content-arg); } } -@mixin baz { - $b: b; - @include meta.apply(meta.get-mixin(b)) using ($a) { - @content($a); +@mixin c { + $global: in-mixin-c; + @include meta.apply(meta.get-mixin(b)) using ($content-arg) { + @content($content-arg); } } a { - $b: c; - @include meta.apply(meta.get-mixin(baz)) using ($a) { - a: $a; + $global: in-style-rule; + @include meta.apply(meta.get-mixin(c)) using ($content-arg) { + in-content-body: $content-arg; } } <===> scope/fall_through/output.css a { - a: x; - b: x; + in-content-body: content-rule-a; + global: global; } From 2318026703a4ea5cc90d506a1aaea9d3a1f21851 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Mon, 25 Sep 2023 16:19:31 +0000 Subject: [PATCH 22/32] use semantic placeholders in redeclare using test --- spec/core_functions/meta/get_mixin/content.hrx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index 1a06c70e3b..48a2ff4beb 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -110,23 +110,23 @@ a { ================================================================================ <===> scope/redeclare/using/input.scss @use "sass:meta"; -@mixin a($a: x) {@content(a);} +@mixin a($a: param) {@content(content-arg);} -$a: y; +$a: global; a { - $a: z; + $a: in-style-rule; @include meta.apply(meta.get-mixin("a")) using ($a) { - a: $a; - $a: a; + in-content-body: $a; + $a: in-content-body; } - b: $a; + in-style-rule: $a; } <===> scope/redeclare/using/output.css a { - a: a; - b: z; + in-content-body: content-arg; + in-style-rule: in-style-rule; } <===> From 6f0fc96b3c49ebbcdf1d1449fd9c4825bbe0b858 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Wed, 27 Sep 2023 23:37:41 +0000 Subject: [PATCH 23/32] add different rest tests, move error tests --- spec/core_functions/meta/apply.hrx | 60 +++++++++++++ .../core_functions/meta/get_mixin/content.hrx | 88 +++++++++---------- 2 files changed, 104 insertions(+), 44 deletions(-) diff --git a/spec/core_functions/meta/apply.hrx b/spec/core_functions/meta/apply.hrx index 9565fcf5ff..f7a5aaf40f 100644 --- a/spec/core_functions/meta/apply.hrx +++ b/spec/core_functions/meta/apply.hrx @@ -75,6 +75,66 @@ a { b: (a: a, b: b, c: c); } +<===> +================================================================================ +<===> rest/mixin-separate/positional/input.scss +@use "sass:meta"; + +@mixin a($a, $b) {b: $a, $b} + +$rest: 1 2; +a {@include meta.apply(meta.get-mixin("a"), $rest...)} + +<===> rest/mixin-separate/positional/output.css +a { + b: 1, 2; +} + +<===> +================================================================================ +<===> rest/mixin-separate/named/input.scss +@use "sass:meta"; + +@mixin a($a, $b) {b: $a, $b} + +$rest: (a: 1, b: 2); +a {@include meta.apply(meta.get-mixin("a"), $rest...)} + +<===> rest/mixin-separate/named/output.css +a { + b: 1, 2; +} + +<===> +================================================================================ +<===> rest/includes-mixin/positional/input.scss +@use "sass:meta"; + +@mixin a($a, $b) {b: $a, $b} + +$rest: meta.get-mixin("a") 1 2; +a {@include meta.apply($rest...)} + +<===> rest/includes-mixin/positional/output.css +a { + b: 1, 2; +} + +<===> +================================================================================ +<===> rest/includes-mixin/named/input.scss +@use "sass:meta"; + +@mixin a($a, $b) {b: $a, $b} + +$rest: (mixin: meta.get-mixin("a"), a: 1, b: 2); +a {@include meta.apply($rest...)} + +<===> rest/includes-mixin/named/output.css +a { + b: 1, 2; +} + <===> ================================================================================ <===> error/wrong_named_arg/input.scss diff --git a/spec/core_functions/meta/get_mixin/content.hrx b/spec/core_functions/meta/get_mixin/content.hrx index 48a2ff4beb..ee2afbea36 100644 --- a/spec/core_functions/meta/get_mixin/content.hrx +++ b/spec/core_functions/meta/get_mixin/content.hrx @@ -29,50 +29,6 @@ a { <===> passes_empty_content/output.css -<===> -================================================================================ -<===> error/denies_content/user_defined/input.scss -@use "sass:meta"; -@mixin a {} - -a { - @include meta.apply(meta.get-mixin("a")) {} -} - -<===> error/denies_content/user_defined/error -Error: Mixin doesn't accept a content block. - , -2 | @mixin a {} - | = declaration -... | -5 | @include meta.apply(meta.get-mixin("a")) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation - ' - input.scss 5:3 root stylesheet - -<===> -================================================================================ -<===> error/denies_content/builtin/input.scss -@use "sass:meta"; - -a { - @include meta.apply(meta.get-mixin(load-css, meta), "a") { - a: b; - } -} - -<===> error/denies_content/builtin/error -Error: Mixin doesn't accept a content block. - ,--> input.scss -4 | @include meta.apply(meta.get-mixin(load-css, meta), "a") { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation - ' - ,--> sass:meta -1 | @mixin load-css($url, $with: null) { - | =========================== declaration - ' - input.scss 4:3 root stylesheet - <===> ================================================================================ <===> scope/redeclare/vars/input.scss @@ -166,3 +122,47 @@ a { in-content-body: content-rule-a; global: global; } + +<===> +================================================================================ +<===> error/denies_content/user_defined/input.scss +@use "sass:meta"; +@mixin a {} + +a { + @include meta.apply(meta.get-mixin("a")) {} +} + +<===> error/denies_content/user_defined/error +Error: Mixin doesn't accept a content block. + , +2 | @mixin a {} + | = declaration +... | +5 | @include meta.apply(meta.get-mixin("a")) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + input.scss 5:3 root stylesheet + +<===> +================================================================================ +<===> error/denies_content/builtin/input.scss +@use "sass:meta"; + +a { + @include meta.apply(meta.get-mixin(load-css, meta), "a") { + a: b; + } +} + +<===> error/denies_content/builtin/error +Error: Mixin doesn't accept a content block. + ,--> input.scss +4 | @include meta.apply(meta.get-mixin(load-css, meta), "a") { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation + ' + ,--> sass:meta +1 | @mixin load-css($url, $with: null) { + | =========================== declaration + ' + input.scss 4:3 root stylesheet From f9188471e3be73de1bab4a8ea88d0bd211188ff4 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 29 Sep 2023 19:04:28 +0000 Subject: [PATCH 24/32] add js api mixin test --- js-api-spec/value/mixin.test.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 js-api-spec/value/mixin.test.ts diff --git a/js-api-spec/value/mixin.test.ts b/js-api-spec/value/mixin.test.ts new file mode 100644 index 0000000000..2930abf7ef --- /dev/null +++ b/js-api-spec/value/mixin.test.ts @@ -0,0 +1,32 @@ +// Copyright 2021 Google Inc. Use of this source code is governed by an +// MIT-style license that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +import {SassMixin, compileString} from 'sass'; + +import {spy} from '../utils'; + +it('can round-trip a mixin reference from Sass', () => { + const fn = spy(args => { + expect(args).toBeArrayOfSize(1); + expect(args[0]).toBeInstanceOf(SassMixin); + args[0].assertMixin(); + return args[0]; + }); + + expect( + compileString( + ` + @use 'sass:meta'; + + @mixin a() {} + a {b: meta.inspect(foo(meta.get-mixin('a')))} + `, + { + functions: {'foo($arg)': fn}, + } + ).css + ).toBe('a {\n b: get-mixin("a");\n}'); + + expect(fn).toHaveBeenCalled(); +}); From 36e7d78b9ba7c98cf30126109cd71e9ed372e803 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 29 Sep 2023 19:12:18 +0000 Subject: [PATCH 25/32] use apply in test --- js-api-spec/value/mixin.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js-api-spec/value/mixin.test.ts b/js-api-spec/value/mixin.test.ts index 2930abf7ef..d9901658ee 100644 --- a/js-api-spec/value/mixin.test.ts +++ b/js-api-spec/value/mixin.test.ts @@ -19,14 +19,19 @@ it('can round-trip a mixin reference from Sass', () => { ` @use 'sass:meta'; - @mixin a() {} - a {b: meta.inspect(foo(meta.get-mixin('a')))} + @mixin a() { + a { + b: c; + } + } + + @include meta.apply(foo(meta.get-mixin('a'))); `, { functions: {'foo($arg)': fn}, } ).css - ).toBe('a {\n b: get-mixin("a");\n}'); + ).toBe('a {\n b: c;\n}'); expect(fn).toHaveBeenCalled(); }); From 896ccf6caf4e83602b0c8354a7a391c318698c2f Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 29 Sep 2023 19:19:48 +0000 Subject: [PATCH 26/32] bump ci test ci with more prs linked in description From 7ecf824ecfa1a6016952e2a81513870962746e40 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 29 Sep 2023 19:40:00 +0000 Subject: [PATCH 27/32] add negative assertions for mixin --- js-api-spec/value/boolean.test.ts | 2 ++ js-api-spec/value/calculation.test.ts | 1 + js-api-spec/value/color.test.ts | 1 + js-api-spec/value/list.test.ts | 2 ++ js-api-spec/value/map.test.ts | 1 + js-api-spec/value/mixin.test.ts | 15 ++++++++++++--- js-api-spec/value/null.test.ts | 1 + js-api-spec/value/number.test.ts | 1 + js-api-spec/value/string.test.ts | 1 + 9 files changed, 22 insertions(+), 3 deletions(-) diff --git a/js-api-spec/value/boolean.test.ts b/js-api-spec/value/boolean.test.ts index c830e8f259..d5310fa311 100644 --- a/js-api-spec/value/boolean.test.ts +++ b/js-api-spec/value/boolean.test.ts @@ -32,6 +32,7 @@ describe('Sass boolean', () => { expect(value.tryMap()).toBe(null); expect(value.assertNumber).toThrow(); expect(value.assertString).toThrow(); + expect(value.assertMixin).toThrow(); }); }); @@ -62,6 +63,7 @@ describe('Sass boolean', () => { expect(value.tryMap()).toBe(null); expect(value.assertNumber).toThrow(); expect(value.assertString).toThrow(); + expect(value.assertMixin).toThrow(); }); }); }); diff --git a/js-api-spec/value/calculation.test.ts b/js-api-spec/value/calculation.test.ts index b738ed10de..70cc8d5748 100644 --- a/js-api-spec/value/calculation.test.ts +++ b/js-api-spec/value/calculation.test.ts @@ -50,6 +50,7 @@ describe('SassCalculation', () => { expect(calculation.tryMap()).toBe(null); expect(() => calculation.assertNumber()).toThrow(); expect(() => calculation.assertString()).toThrow(); + expect(() => calculation.assertMixin()).toThrow(); }); }); diff --git a/js-api-spec/value/color.test.ts b/js-api-spec/value/color.test.ts index 1a6c6bfa21..900ed75c3c 100644 --- a/js-api-spec/value/color.test.ts +++ b/js-api-spec/value/color.test.ts @@ -59,6 +59,7 @@ describe('SassColor', () => { expect(color.tryMap()).toBe(null); expect(() => color.assertNumber()).toThrow(); expect(() => color.assertString()).toThrow(); + expect(() => color.assertMixin()).toThrow(); }); }); diff --git a/js-api-spec/value/list.test.ts b/js-api-spec/value/list.test.ts index e7d784fcad..fb83e22d5b 100644 --- a/js-api-spec/value/list.test.ts +++ b/js-api-spec/value/list.test.ts @@ -32,6 +32,7 @@ describe('SassList', () => { expect(list.tryMap()).toBe(null); expect(() => list.assertNumber()).toThrow(); expect(() => list.assertString()).toThrow(); + expect(() => list.assertMixin()).toThrow(); }); it('returns its contents as a list', () => { @@ -360,6 +361,7 @@ describe('SassList', () => { expect(() => list.assertFunction()).toThrow(); expect(() => list.assertNumber()).toThrow(); expect(() => list.assertString()).toThrow(); + expect(() => list.assertMixin()).toThrow(); }); it('rejects invalid indices', () => { diff --git a/js-api-spec/value/map.test.ts b/js-api-spec/value/map.test.ts index 36a3716a31..da74443d19 100644 --- a/js-api-spec/value/map.test.ts +++ b/js-api-spec/value/map.test.ts @@ -34,6 +34,7 @@ describe('SassMap', () => { expect(() => map.assertFunction()).toThrow(); expect(() => map.assertNumber()).toThrow(); expect(() => map.assertString()).toThrow(); + expect(() => map.assertMixin()).toThrow(); }); it('returns its contents as a map', () => { diff --git a/js-api-spec/value/mixin.test.ts b/js-api-spec/value/mixin.test.ts index d9901658ee..b52c41dabc 100644 --- a/js-api-spec/value/mixin.test.ts +++ b/js-api-spec/value/mixin.test.ts @@ -9,9 +9,18 @@ import {spy} from '../utils'; it('can round-trip a mixin reference from Sass', () => { const fn = spy(args => { expect(args).toBeArrayOfSize(1); - expect(args[0]).toBeInstanceOf(SassMixin); - args[0].assertMixin(); - return args[0]; + const value = args[0]; + expect(value).toBeInstanceOf(SassMixin); + value.assertMixin(); + expect(value.assertCalculation).toThrow(); + expect(value.assertColor).toThrow(); + expect(value.assertFunction).toThrow(); + expect(value.assertMap).toThrow(); + expect(value.tryMap()).toBe(null); + expect(value.assertNumber).toThrow(); + expect(value.assertString).toThrow(); + + return value; }); expect( diff --git a/js-api-spec/value/null.test.ts b/js-api-spec/value/null.test.ts index 2ed3d37df9..32bd44e5b3 100644 --- a/js-api-spec/value/null.test.ts +++ b/js-api-spec/value/null.test.ts @@ -32,5 +32,6 @@ describe('Sass null', () => { expect(value.tryMap()).toBe(null); expect(value.assertNumber).toThrow(); expect(value.assertString).toThrow(); + expect(value.assertMixin).toThrow(); }); }); diff --git a/js-api-spec/value/number.test.ts b/js-api-spec/value/number.test.ts index f2493821be..4e58f0a110 100644 --- a/js-api-spec/value/number.test.ts +++ b/js-api-spec/value/number.test.ts @@ -43,6 +43,7 @@ describe('Sass number', () => { expect(() => number.assertMap()).toThrow(); expect(number.tryMap()).toBe(null); expect(() => number.assertString()).toThrow(); + expect(() => number.assertMixin()).toThrow(); }); }); diff --git a/js-api-spec/value/string.test.ts b/js-api-spec/value/string.test.ts index abe4fc2135..21038629ef 100644 --- a/js-api-spec/value/string.test.ts +++ b/js-api-spec/value/string.test.ts @@ -60,6 +60,7 @@ describe('Sass string', () => { expect(value.assertMap).toThrow(); expect(value.tryMap()).toBe(null); expect(value.assertNumber).toThrow(); + expect(value.assertMixin).toThrow(); }); }); From 2b017e3cd49bbbb4415d3046d3cba2eb51082a0b Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 29 Sep 2023 19:48:09 +0000 Subject: [PATCH 28/32] alphabetize --- js-api-spec/value/boolean.test.ts | 4 ++-- js-api-spec/value/calculation.test.ts | 2 +- js-api-spec/value/color.test.ts | 2 +- js-api-spec/value/list.test.ts | 4 ++-- js-api-spec/value/map.test.ts | 2 +- js-api-spec/value/mixin.test.ts | 2 +- js-api-spec/value/null.test.ts | 2 +- js-api-spec/value/number.test.ts | 2 +- js-api-spec/value/string.test.ts | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/js-api-spec/value/boolean.test.ts b/js-api-spec/value/boolean.test.ts index d5310fa311..2d2dd98c2e 100644 --- a/js-api-spec/value/boolean.test.ts +++ b/js-api-spec/value/boolean.test.ts @@ -30,9 +30,9 @@ describe('Sass boolean', () => { expect(value.assertFunction).toThrow(); expect(value.assertMap).toThrow(); expect(value.tryMap()).toBe(null); + expect(value.assertMixin).toThrow(); expect(value.assertNumber).toThrow(); expect(value.assertString).toThrow(); - expect(value.assertMixin).toThrow(); }); }); @@ -61,9 +61,9 @@ describe('Sass boolean', () => { expect(value.assertFunction).toThrow(); expect(value.assertMap).toThrow(); expect(value.tryMap()).toBe(null); + expect(value.assertMixin).toThrow(); expect(value.assertNumber).toThrow(); expect(value.assertString).toThrow(); - expect(value.assertMixin).toThrow(); }); }); }); diff --git a/js-api-spec/value/calculation.test.ts b/js-api-spec/value/calculation.test.ts index 70cc8d5748..2990b9c319 100644 --- a/js-api-spec/value/calculation.test.ts +++ b/js-api-spec/value/calculation.test.ts @@ -48,9 +48,9 @@ describe('SassCalculation', () => { expect(() => calculation.assertFunction()).toThrow(); expect(() => calculation.assertMap()).toThrow(); expect(calculation.tryMap()).toBe(null); + expect(() => calculation.assertMixin()).toThrow(); expect(() => calculation.assertNumber()).toThrow(); expect(() => calculation.assertString()).toThrow(); - expect(() => calculation.assertMixin()).toThrow(); }); }); diff --git a/js-api-spec/value/color.test.ts b/js-api-spec/value/color.test.ts index 900ed75c3c..c816c67c7c 100644 --- a/js-api-spec/value/color.test.ts +++ b/js-api-spec/value/color.test.ts @@ -57,9 +57,9 @@ describe('SassColor', () => { expect(() => color.assertFunction()).toThrow(); expect(() => color.assertMap()).toThrow(); expect(color.tryMap()).toBe(null); + expect(() => color.assertMixin()).toThrow(); expect(() => color.assertNumber()).toThrow(); expect(() => color.assertString()).toThrow(); - expect(() => color.assertMixin()).toThrow(); }); }); diff --git a/js-api-spec/value/list.test.ts b/js-api-spec/value/list.test.ts index fb83e22d5b..930ef01d9f 100644 --- a/js-api-spec/value/list.test.ts +++ b/js-api-spec/value/list.test.ts @@ -30,9 +30,9 @@ describe('SassList', () => { expect(() => list.assertFunction()).toThrow(); expect(() => list.assertMap()).toThrow(); expect(list.tryMap()).toBe(null); + expect(() => list.assertMixin()).toThrow(); expect(() => list.assertNumber()).toThrow(); expect(() => list.assertString()).toThrow(); - expect(() => list.assertMixin()).toThrow(); }); it('returns its contents as a list', () => { @@ -359,9 +359,9 @@ describe('SassList', () => { expect(() => list.assertCalculation()).toThrow(); expect(() => list.assertColor()).toThrow(); expect(() => list.assertFunction()).toThrow(); + expect(() => list.assertMixin()).toThrow(); expect(() => list.assertNumber()).toThrow(); expect(() => list.assertString()).toThrow(); - expect(() => list.assertMixin()).toThrow(); }); it('rejects invalid indices', () => { diff --git a/js-api-spec/value/map.test.ts b/js-api-spec/value/map.test.ts index da74443d19..c185b00d03 100644 --- a/js-api-spec/value/map.test.ts +++ b/js-api-spec/value/map.test.ts @@ -32,9 +32,9 @@ describe('SassMap', () => { expect(() => map.assertCalculation()).toThrow(); expect(() => map.assertColor()).toThrow(); expect(() => map.assertFunction()).toThrow(); + expect(() => map.assertMixin()).toThrow(); expect(() => map.assertNumber()).toThrow(); expect(() => map.assertString()).toThrow(); - expect(() => map.assertMixin()).toThrow(); }); it('returns its contents as a map', () => { diff --git a/js-api-spec/value/mixin.test.ts b/js-api-spec/value/mixin.test.ts index b52c41dabc..5757562654 100644 --- a/js-api-spec/value/mixin.test.ts +++ b/js-api-spec/value/mixin.test.ts @@ -11,12 +11,12 @@ it('can round-trip a mixin reference from Sass', () => { expect(args).toBeArrayOfSize(1); const value = args[0]; expect(value).toBeInstanceOf(SassMixin); - value.assertMixin(); expect(value.assertCalculation).toThrow(); expect(value.assertColor).toThrow(); expect(value.assertFunction).toThrow(); expect(value.assertMap).toThrow(); expect(value.tryMap()).toBe(null); + value.assertMixin(); expect(value.assertNumber).toThrow(); expect(value.assertString).toThrow(); diff --git a/js-api-spec/value/null.test.ts b/js-api-spec/value/null.test.ts index 32bd44e5b3..dcfbe13c52 100644 --- a/js-api-spec/value/null.test.ts +++ b/js-api-spec/value/null.test.ts @@ -30,8 +30,8 @@ describe('Sass null', () => { expect(value.assertFunction).toThrow(); expect(value.assertMap).toThrow(); expect(value.tryMap()).toBe(null); + expect(value.assertMixin).toThrow(); expect(value.assertNumber).toThrow(); expect(value.assertString).toThrow(); - expect(value.assertMixin).toThrow(); }); }); diff --git a/js-api-spec/value/number.test.ts b/js-api-spec/value/number.test.ts index 4e58f0a110..00656a375d 100644 --- a/js-api-spec/value/number.test.ts +++ b/js-api-spec/value/number.test.ts @@ -42,8 +42,8 @@ describe('Sass number', () => { expect(() => number.assertFunction()).toThrow(); expect(() => number.assertMap()).toThrow(); expect(number.tryMap()).toBe(null); - expect(() => number.assertString()).toThrow(); expect(() => number.assertMixin()).toThrow(); + expect(() => number.assertString()).toThrow(); }); }); diff --git a/js-api-spec/value/string.test.ts b/js-api-spec/value/string.test.ts index 21038629ef..061089529b 100644 --- a/js-api-spec/value/string.test.ts +++ b/js-api-spec/value/string.test.ts @@ -59,8 +59,8 @@ describe('Sass string', () => { expect(value.assertFunction).toThrow(); expect(value.assertMap).toThrow(); expect(value.tryMap()).toBe(null); - expect(value.assertNumber).toThrow(); expect(value.assertMixin).toThrow(); + expect(value.assertNumber).toThrow(); }); }); From 55fe148bc52489a67691114729b629831ef07c5c Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Wed, 4 Oct 2023 00:15:46 +0000 Subject: [PATCH 29/32] remove faulty assertion this is not true in browser environments, for some reason --- js-api-spec/value/mixin.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js-api-spec/value/mixin.test.ts b/js-api-spec/value/mixin.test.ts index 5757562654..172bceddc8 100644 --- a/js-api-spec/value/mixin.test.ts +++ b/js-api-spec/value/mixin.test.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {SassMixin, compileString} from 'sass'; +import {compileString} from 'sass'; import {spy} from '../utils'; @@ -10,7 +10,6 @@ it('can round-trip a mixin reference from Sass', () => { const fn = spy(args => { expect(args).toBeArrayOfSize(1); const value = args[0]; - expect(value).toBeInstanceOf(SassMixin); expect(value.assertCalculation).toThrow(); expect(value.assertColor).toThrow(); expect(value.assertFunction).toThrow(); From d940acbb73ef5349b41a35f2e8ead63a52a2522a Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Wed, 4 Oct 2023 00:47:03 +0000 Subject: [PATCH 30/32] add back instanceof assertion --- js-api-spec/value/mixin.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js-api-spec/value/mixin.test.ts b/js-api-spec/value/mixin.test.ts index 172bceddc8..5757562654 100644 --- a/js-api-spec/value/mixin.test.ts +++ b/js-api-spec/value/mixin.test.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {compileString} from 'sass'; +import {SassMixin, compileString} from 'sass'; import {spy} from '../utils'; @@ -10,6 +10,7 @@ it('can round-trip a mixin reference from Sass', () => { const fn = spy(args => { expect(args).toBeArrayOfSize(1); const value = args[0]; + expect(value).toBeInstanceOf(SassMixin); expect(value.assertCalculation).toThrow(); expect(value.assertColor).toThrow(); expect(value.assertFunction).toThrow(); From b3131b80968b5b32525057bba5cab41a202245dc Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Wed, 4 Oct 2023 20:44:38 +0000 Subject: [PATCH 31/32] use proper instanceof check --- js-api-spec/value/mixin.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-api-spec/value/mixin.test.ts b/js-api-spec/value/mixin.test.ts index 5757562654..989a0d2bd6 100644 --- a/js-api-spec/value/mixin.test.ts +++ b/js-api-spec/value/mixin.test.ts @@ -10,7 +10,7 @@ it('can round-trip a mixin reference from Sass', () => { const fn = spy(args => { expect(args).toBeArrayOfSize(1); const value = args[0]; - expect(value).toBeInstanceOf(SassMixin); + expect(value instanceof SassMixin).toBe(true); expect(value.assertCalculation).toThrow(); expect(value.assertColor).toThrow(); expect(value.assertFunction).toThrow(); From 7b989f03e3bdff293591abe0b1ed665004795d6f Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Thu, 5 Oct 2023 00:19:23 +0000 Subject: [PATCH 32/32] stricter assertMixin, use toBeInstanceOf --- js-api-spec/value/mixin.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js-api-spec/value/mixin.test.ts b/js-api-spec/value/mixin.test.ts index 989a0d2bd6..a1413bfa8f 100644 --- a/js-api-spec/value/mixin.test.ts +++ b/js-api-spec/value/mixin.test.ts @@ -10,13 +10,13 @@ it('can round-trip a mixin reference from Sass', () => { const fn = spy(args => { expect(args).toBeArrayOfSize(1); const value = args[0]; - expect(value instanceof SassMixin).toBe(true); + expect(value).toBeInstanceOf(SassMixin); expect(value.assertCalculation).toThrow(); expect(value.assertColor).toThrow(); expect(value.assertFunction).toThrow(); expect(value.assertMap).toThrow(); expect(value.tryMap()).toBe(null); - value.assertMixin(); + expect(value.assertMixin()).toBe(value); expect(value.assertNumber).toThrow(); expect(value.assertString).toThrow();