Skip to content

Commit

Permalink
Update specs to keep trailing comments on the previous line
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Oct 16, 2019
1 parent 0f6a1e4 commit 9d64bf7
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 8 deletions.
24 changes: 21 additions & 3 deletions lib/sass_spec/test.rb
Expand Up @@ -499,22 +499,40 @@ def delete_test!
def migrate_impl!
if @status == 0
if @test_case.expected != @normalized_output || @test_case.should_fail?
@test_case.write("output.css", @output, impl: true)
_write_for_impl("output.css", @output)
end

if extract_error_message(@test_case.expected_warning) != extract_error_message(@error)
@test_case.write("warning", @error, impl: true)
_write_for_impl("warning", @error)
end
else
actual_error = @test_case.expected_error && extract_error_message(@test_case.expected_error)
if actual_error != extract_error_message(@error)
@test_case.write("error", @error, impl: true)
_write_for_impl("error", @error)
end
end

change_options(remove_warning_todo: [@test_case.impl], remove_todo: [@test_case.impl])
end

# Writes `contents` to the implementation-specific version of `file`.
#
# If the current implementation is Dart Sass, this instead migrates the
# existing file to a LibSass-specific file and overwrites the default file
# with the Dart Sass expectation.
def _write_for_impl(file, contents)
if @test_case.impl != "dart-sass"
@test_case.write(file, contents, impl: true)
return
end

libsass_test_case = SassSpec::TestCase.new(@test_case.dir, "libsass")
libsass_test_case.write(file, libsass_test_case.read(file, impl: :auto), impl: true)

@test_case.delete(file, if_exists: true, impl: true)
@test_case.write(file, contents, impl: false)
end

## Other utilities

# Returns whether the current test case is marked as TODO, but is still being
Expand Down
47 changes: 47 additions & 0 deletions spec/basic/06_nesting_and_comments.hrx
Expand Up @@ -65,6 +65,53 @@ div span {
/* yet another comment that should be preserved */
display: inline-block;
}
div span a {
text-decoration: none; /* where will this comment go? */
color: green;
/* what about this comment? */
border: 1px bloo blee red;
}
div empty not_empty {
blah: blah;
bloo: bloo;
}
div p {
padding: 10px 8%;
-webkit-box-sizing: hux;
}
div h1 {
color: "a 'red' and \"blue\" value";
}

/* last comment, top level again --
compare the indentation! */
div {
f: g;
}
div empty span {
a: b;
}
div empty_with_comment {
/* hey now */
}
div empty_with_comment span {
c: d;
}

<===> output-libsass.css
/* top level comment -- should be preserved */
div {
/* another comment that should be preserved */
color: red;
background: blue;
/* the next selector should be indented two spaces */
margin: 10px 5px;
}
div span {
font-weight: bold;
/* yet another comment that should be preserved */
display: inline-block;
}
div span a {
text-decoration: none;
/* where will this comment go? */
Expand Down
4 changes: 4 additions & 0 deletions spec/css/keyframes.hrx
Expand Up @@ -5,6 +5,10 @@ a {
}

<===> bubble/empty/output.css
@keyframes { /**/
}

<===> bubble/empty/output-libsass.css
@keyframes {
/**/
}
17 changes: 17 additions & 0 deletions spec/directives/use/css/order.hrx
Expand Up @@ -451,6 +451,23 @@ a {file: midstream}

<===> import_order/comments_and_imports/output.css
/* upstream comment before import */
@import "upstream.css"; /* midstream comment before use */
/* midstream comment before first import */
@import "midstream1.css";
/* midstream comment before second import */
@import "midstream2.css"; /* input comment before use */
/* input comment before import */
@import "input.css";
/* upstream comment after import */
/* midstream comment after imports */
a {
file: midstream;
}

/* input comment after import */

<===> import_order/comments_and_imports/output-libsass.css
/* upstream comment before import */

@import "upstream.css";

Expand Down
9 changes: 9 additions & 0 deletions spec/libsass-closed-issues/issue_1007.hrx
Expand Up @@ -4,6 +4,15 @@
} /* end */
<===> output.css
/* start */
foo baz {
/* before */
margin: 0; /* after */
}

/* end */

<===> output-libsass.css
/* start */
foo baz {
/* before */
margin: 0;
Expand Down
8 changes: 8 additions & 0 deletions spec/libsass-closed-issues/issue_1294.hrx
Expand Up @@ -11,6 +11,14 @@ foo {
/*------------------------------------*\
#BUTTONS
\*------------------------------------*/
foo {
display: inline-block; /* [1] */
}

<===> output-libsass.css
/*------------------------------------*\
#BUTTONS
\*------------------------------------*/
foo {
display: inline-block;
/* [1] */
Expand Down
8 changes: 8 additions & 0 deletions spec/libsass-closed-issues/issue_1567.hrx
Expand Up @@ -7,6 +7,14 @@

<===> output.css
/* any */
@media screen, not print { /* whatever */
body {
line-height: 1.2;
}
}

<===> output-libsass.css
/* any */
@media screen, not print {
/* whatever */
body {
Expand Down
9 changes: 4 additions & 5 deletions spec/libsass-closed-issues/issue_894.hrx
Expand Up @@ -2,19 +2,18 @@
a {/**/}
b {content: 'something so I have a non-empty expected output'}
<===> output.css
a {
/**/
a { /**/
}

b {
content: 'something so I have a non-empty expected output';
content: "something so I have a non-empty expected output";
}

<===> output-dart-sass.css
<===> output-libsass.css
a {
/**/
}

b {
content: "something so I have a non-empty expected output";
content: 'something so I have a non-empty expected output';
}
6 changes: 6 additions & 0 deletions spec/libsass-closed-issues/issue_941.hrx
Expand Up @@ -6,6 +6,12 @@

<===> output.css
.one,
.two { /* 3 */
color: #F00; /* 4 */
}

<===> output-libsass.css
.one,
.two {
/* 3 */
color: #F00;
Expand Down

0 comments on commit 9d64bf7

Please sign in to comment.