Skip to content

Commit

Permalink
add test for error/warn/debug
Browse files Browse the repository at this point in the history
  • Loading branch information
braver committed Feb 17, 2024
1 parent 22f06a9 commit 21cb964
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Syntaxes/SCSS.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,24 @@ contexts:
- meta_scope: meta.at-rule.scss
- include: terminator-pop
- include: values
- match: '(@)(warn|error){{break}}'
- match: '(@)(error){{break}}'
captures:
0: keyword.control.at-rule.error.scss
1: punctuation.definition.keyword.scss
push:
- meta_scope: meta.at-rule.scss
- include: terminator-pop
- include: scss-expression
- include: quoted-strings
- match: '(@)(warn){{break}}'
captures:
0: keyword.control.at-rule.warn.scss
1: punctuation.definition.keyword.scss
push:
- meta_scope: meta.at-rule.scss
- include: terminator-pop
- include: scss-expression
- include: quoted-strings
- match: '(@)(debug){{break}}'
captures:
0: keyword.control.at-rule.debugger.scss
Expand Down
63 changes: 63 additions & 0 deletions Tests/syntax_test_scss.scss
Original file line number Diff line number Diff line change
Expand Up @@ -979,3 +979,66 @@ $accent: #e1d7d2;

}
}

//=============================================================================
// Error
// https://sass-lang.com/documentation/at-rules/error/
//=============================================================================
@mixin reflexive-position($property, $value) {
@if $property != left and $property != right {
@error "Property #{$property} must be either left or right.";
// ^^^^^^^^^^^^^^^^^ meta.at-rule.scss
// ^^^^^^ meta.at-rule.scss
// ^^^^^^ keyword.control.at-rule.error.scss
// ^ punctuation.definition.keyword.scss
// ^^^^^^^^^^ string.quoted
// ^^^^^^^^^^ meta.interpolation
// ^^^^^^ string.quoted

}

$left-value: if($property == right, initial, $value);
$right-value: if($property == right, $value, initial);

left: $left-value;
right: $right-value;
[dir=rtl] & {
left: $right-value;
right: $left-value;
}
}

//=============================================================================
// Warn
// https://sass-lang.com/documentation/at-rules/warn/
//=============================================================================
@mixin prefix($property, $value, $prefixes) {
@each $prefix in $prefixes {
@if not index($known-prefixes, $prefix) {
@warn "Unknown prefix #{$prefix}.";
// ^^^^^ meta.at-rule.scss keyword.control.at-rule.warn.scss
// ^ punctuation.definition.keyword.scss
// ^^^^^^^^^^ string.quoted
// ^^^^ meta.interpolation
}

-#{$prefix}-#{$property}: $value;
}
#{$property}: $value;
}

//=============================================================================
// Debug
// https://sass-lang.com/documentation/at-rules/debug/
//=============================================================================
@mixin inset-divider-offset($offset, $padding) {
$divider-offset: (2 * $padding) + $offset;
@debug "divider offset: #{$divider-offset}";
//^^^^^^ meta.at-rule.scss keyword.control.at-rule.debugger.scss
//^ punctuation.definition.keyword.scss
// ^^^^^^^^^^ string.quoted
// ^^ meta.interpolation

margin-left: $divider-offset;
width: calc(100% - #{$divider-offset});
}

0 comments on commit 21cb964

Please sign in to comment.