From e57a189c7781822e54f643aecd49520049a8ed7a Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 3 Feb 2020 07:27:57 -0500 Subject: [PATCH] Handle quotes in feature-exists --- src/builtin/meta.rs | 2 +- tests/meta.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/builtin/meta.rs b/src/builtin/meta.rs index 7a9eec9..0ab0ab7 100644 --- a/src/builtin/meta.rs +++ b/src/builtin/meta.rs @@ -16,7 +16,7 @@ pub(crate) fn register(f: &mut BTreeMap) { }); decl!(f "feature-exists", |args| { let feature: &Value = arg!(args, 0, "feature"); - match feature.to_string().as_str() { + match feature.clone().unquote().to_string().as_str() { // A local variable will shadow a global variable unless // `!global` is used. "global-variable-shadowing" => Some(Value::False), diff --git a/tests/meta.rs b/tests/meta.rs index 331c99b..8383ebd 100644 --- a/tests/meta.rs +++ b/tests/meta.rs @@ -18,3 +18,23 @@ test!( "a {\n color: if(false, 1, 2);\n}\n", "a {\n color: 2;\n}\n" ); +test!( + feature_exists_at_error_dbl_quoted, + "a {\n color: feature-exists(\"at-error\")\n}\n", + "a {\n color: true;\n}\n" +); +test!( + feature_exists_at_error_sgl_quoted, + "a {\n color: feature-exists('at-error')\n}\n", + "a {\n color: true;\n}\n" +); +test!( + feature_exists_at_error_no_quotes, + "a {\n color: feature-exists(at-error)\n}\n", + "a {\n color: true;\n}\n" +); +test!( + feature_exists_at_error_named_arg, + "a {\n color: feature-exists($feature: at-error)\n}\n", + "a {\n color: true;\n}\n" +);