1- #!/usr/bin/env ruby
21# -*- coding: utf-8 -*-
32require File . dirname ( __FILE__ ) + '/test_helper'
43
@@ -1015,53 +1014,55 @@ def test_function_args
10151014 end
10161015
10171016 def test_disallowed_function_names
1018- assert_warning ( <<WARNING ) { render ( <<SCSS ) }
1017+ Sass ::Deprecation . allow_double_warnings do
1018+ assert_warning ( <<WARNING ) { render ( <<SCSS ) }
10191019DEPRECATION WARNING on line 1 of test_disallowed_function_names_inline.scss:
10201020Naming a function "calc" is disallowed and will be an error in future versions of Sass.
10211021This name conflicts with an existing CSS function with special parse rules.
10221022WARNING
10231023@function calc() {}
10241024SCSS
10251025
1026- assert_warning ( <<WARNING ) { render ( <<SCSS ) }
1026+ assert_warning ( <<WARNING ) { render ( <<SCSS ) }
10271027DEPRECATION WARNING on line 1 of test_disallowed_function_names_inline.scss:
10281028Naming a function "-my-calc" is disallowed and will be an error in future versions of Sass.
10291029This name conflicts with an existing CSS function with special parse rules.
10301030WARNING
10311031@function -my-calc() {}
10321032SCSS
10331033
1034- assert_warning ( <<WARNING ) { render ( <<SCSS ) }
1034+ assert_warning ( <<WARNING ) { render ( <<SCSS ) }
10351035DEPRECATION WARNING on line 1 of test_disallowed_function_names_inline.scss:
10361036Naming a function "element" is disallowed and will be an error in future versions of Sass.
10371037This name conflicts with an existing CSS function with special parse rules.
10381038WARNING
10391039@function element() {}
10401040SCSS
10411041
1042- assert_warning ( <<WARNING ) { render ( <<SCSS ) }
1042+ assert_warning ( <<WARNING ) { render ( <<SCSS ) }
10431043DEPRECATION WARNING on line 1 of test_disallowed_function_names_inline.scss:
10441044Naming a function "-my-element" is disallowed and will be an error in future versions of Sass.
10451045This name conflicts with an existing CSS function with special parse rules.
10461046WARNING
10471047@function -my-element() {}
10481048SCSS
10491049
1050- assert_warning ( <<WARNING ) { render ( <<SCSS ) }
1050+ assert_warning ( <<WARNING ) { render ( <<SCSS ) }
10511051DEPRECATION WARNING on line 1 of test_disallowed_function_names_inline.scss:
10521052Naming a function "expression" is disallowed and will be an error in future versions of Sass.
10531053This name conflicts with an existing CSS function with special parse rules.
10541054WARNING
10551055@function expression() {}
10561056SCSS
10571057
1058- assert_warning ( <<WARNING ) { render ( <<SCSS ) }
1058+ assert_warning ( <<WARNING ) { render ( <<SCSS ) }
10591059DEPRECATION WARNING on line 1 of test_disallowed_function_names_inline.scss:
10601060Naming a function "url" is disallowed and will be an error in future versions of Sass.
10611061This name conflicts with an existing CSS function with special parse rules.
10621062WARNING
10631063@function url() {}
10641064SCSS
1065+ end
10651066 end
10661067
10671068 def test_allowed_function_names
@@ -2172,7 +2173,7 @@ def test_selector_interpolation_at_dashes
21722173 end
21732174
21742175 def test_selector_interpolation_in_reference_combinator
2175- assert_equal <<CSS , render ( <<SCSS )
2176+ silence_warnings { assert_equal <<CSS , render ( <<SCSS ) }
21762177.foo /a/ .bar /b|c/ .baz {
21772178 a: b; }
21782179CSS
@@ -2286,16 +2287,16 @@ def test_media_interpolation_with_reparse
22862287
22872288 def test_moz_document_interpolation
22882289 assert_equal <<CSS , render ( <<SCSS )
2289- @-moz-document url(http ://sass-lang.com/),
2290- url-prefix(http ://sass-lang.com/docs),
2290+ @-moz-document url(https ://sass-lang.com/),
2291+ url-prefix(https ://sass-lang.com/docs),
22912292 domain(sass-lang.com),
22922293 domain("sass-lang.com") {
22932294 .foo {
22942295 a: b; } }
22952296CSS
22962297$domain: "sass-lang.com";
2297- @-moz-document url(http ://\# {$domain}/),
2298- url-prefix(http ://\# {$domain}/docs),
2298+ @-moz-document url(https ://\# {$domain}/),
2299+ url-prefix(https ://\# {$domain}/docs),
22992300 domain(\# {$domain}),
23002301 \# {domain($domain)} {
23012302 .foo {a: b}
@@ -2340,15 +2341,15 @@ def test_supports_bubbling
23402341
23412342 def test_random_directive_interpolation
23422343 assert_equal <<CSS , render ( <<SCSS )
2343- @foo url(http ://sass-lang.com/),
2344+ @foo url(https ://sass-lang.com/),
23442345 domain("sass-lang.com"),
23452346 "foobarbaz",
23462347 foobarbaz {
23472348 .foo {
23482349 a: b; } }
23492350CSS
23502351$domain: "sass-lang.com";
2351- @foo url(http ://\# {$domain}/),
2352+ @foo url(https ://\# {$domain}/),
23522353 \# {domain($domain)},
23532354 "foo\# {'ba' + 'r'}baz",
23542355 foo\# {'ba' + 'r'}baz {
@@ -3387,22 +3388,22 @@ def test_rules_beneath_properties
33873388 def test_uses_property_exception_with_star_hack
33883389 render <<SCSS
33893390foo {
3390- *bar:baz [ fail] ; }
3391+ *bar:baz < fail> ; }
33913392SCSS
33923393 assert ( false , "Expected syntax error" )
33933394 rescue Sass ::SyntaxError => e
3394- assert_equal 'Invalid CSS after " *bar:baz ": expected ";", was "[fail] ; }"' , e . message
3395+ assert_equal 'Invalid CSS after " *bar:baz <fail> ": expected expression (e.g. 1px, bold), was "; }"' , e . message
33953396 assert_equal 2 , e . sass_line
33963397 end
33973398
33983399 def test_uses_property_exception_with_colon_hack
33993400 render <<SCSS
34003401foo {
3401- :bar:baz [ fail] ; }
3402+ :bar:baz < fail> ; }
34023403SCSS
34033404 assert ( false , "Expected syntax error" )
34043405 rescue Sass ::SyntaxError => e
3405- assert_equal 'Invalid CSS after " :bar:baz ": expected ";", was "[fail] ; }"' , e . message
3406+ assert_equal 'Invalid CSS after " :bar:baz <fail> ": expected expression (e.g. 1px, bold), was "; }"' , e . message
34063407 assert_equal 2 , e . sass_line
34073408 end
34083409
@@ -3420,22 +3421,22 @@ def test_uses_rule_exception_with_dot_hack
34203421 def test_uses_property_exception_with_space_after_name
34213422 render <<SCSS
34223423foo {
3423- bar: baz [ fail] ; }
3424+ bar: baz < fail> ; }
34243425SCSS
34253426 assert ( false , "Expected syntax error" )
34263427 rescue Sass ::SyntaxError => e
3427- assert_equal 'Invalid CSS after " bar: baz ": expected ";", was "[fail] ; }"' , e . message
3428+ assert_equal 'Invalid CSS after " bar: baz <fail> ": expected expression (e.g. 1px, bold), was "; }"' , e . message
34283429 assert_equal 2 , e . sass_line
34293430 end
34303431
34313432 def test_uses_property_exception_with_non_identifier_after_name
34323433 render <<SCSS
34333434foo {
3434- bar:1px [ fail] ; }
3435+ bar:1px < fail> ; }
34353436SCSS
34363437 assert ( false , "Expected syntax error" )
34373438 rescue Sass ::SyntaxError => e
3438- assert_equal 'Invalid CSS after " bar:1px ": expected ";", was "[fail] ; }"' , e . message
3439+ assert_equal 'Invalid CSS after " bar:1px <fail> ": expected expression (e.g. 1px, bold), was "; }"' , e . message
34393440 assert_equal 2 , e . sass_line
34403441 end
34413442
@@ -3649,6 +3650,40 @@ def test_raw_newline_warning
36493650
36503651 # Regression
36513652
3653+ # Regression test for #2031.
3654+ def test_no_interpolation_warning_in_nested_selector
3655+ assert_no_warning { assert_equal ( <<CSS , render ( <<SCSS ) ) }
3656+ z a:b(n+1) {
3657+ x: y; }
3658+ CSS
3659+ z {
3660+ a:b(n+\# {1}) {
3661+ x: y;
3662+ }
3663+ }
3664+ SCSS
3665+ end
3666+
3667+ # Ensures that the fix for #2031 doesn't hide legitimate warnings.
3668+ def test_interpolation_warning_in_selector_like_property
3669+ assert_warning ( <<WARNING ) { assert_equal ( <<CSS , render ( <<SCSS ) ) }
3670+ DEPRECATION WARNING on line 2 of #{ filename_for_test :scss } :
3671+ \# {} interpolation near operators will be simplified in a future version of Sass.
3672+ To preserve the current behavior, use quotes:
3673+
3674+ unquote("n+1")
3675+
3676+ You can use the sass-convert command to automatically fix most cases.
3677+ WARNING
3678+ z {
3679+ a: b(n+1); }
3680+ CSS
3681+ z {
3682+ a:b(n+\# {1});
3683+ }
3684+ SCSS
3685+ end
3686+
36523687 def test_escape_in_selector
36533688 assert_equal ( <<CSS , render ( ".\\ !foo {a: b}" ) )
36543689.\\ !foo {
@@ -3791,7 +3826,7 @@ def test_loud_comment_in_compressed_mode
37913826 def test_parsing_decimals_followed_by_comments_doesnt_take_forever
37923827 assert_equal ( <<CSS , render ( <<SCSS ) )
37933828.foo {
3794- padding: 4.21053 % 4.21053 % 5.63158 %; }
3829+ padding: 4.2105263158 % 4.2105263158 % 5.6315789474 %; }
37953830CSS
37963831.foo {
37973832 padding: 4.21052631578947% 4.21052631578947% 5.631578947368421% /**/
@@ -3824,7 +3859,19 @@ def test_import_comments_in_imports
38243859 end
38253860
38263861 def test_reference_combinator_with_parent_ref
3827- assert_equal <<CSS , render ( <<SCSS )
3862+ silence_warnings { assert_equal <<CSS , render ( <<SCSS ) }
3863+ a /foo/ b {
3864+ c: d; }
3865+ CSS
3866+ a {& /foo/ b {c: d}}
3867+ SCSS
3868+ end
3869+
3870+ def test_reference_combinator_warning
3871+ assert_warning ( <<WARNING ) { assert_equal <<CSS , render ( <<SCSS ) }
3872+ DEPRECATION WARNING on line 1, column 8 of test_reference_combinator_warning_inline.scss:
3873+ The reference combinator /foo/ is deprecated and will be removed in a future release.
3874+ WARNING
38283875a /foo/ b {
38293876 c: d; }
38303877CSS
@@ -3894,12 +3941,13 @@ def test_interpolation_with_bracket_on_next_line
38943941SCSS
38953942 end
38963943
3897- def test_extra_comma_in_mixin_arglist_error
3898- assert_raise_message ( Sass ::SyntaxError , <<MESSAGE . rstrip ) { render <<SCSS }
3899- Invalid CSS after "...clude foo(bar, ": expected mixin argument, was ");"
3900- MESSAGE
3901- @mixin foo($a1, $a2) {
3902- baz: $a1 $a2;
3944+ def test_extra_comma_in_mixin_arglist
3945+ assert_equal <<CSS , render ( <<SCSS )
3946+ .bar {
3947+ baz: bar; }
3948+ CSS
3949+ @mixin foo($a1,) {
3950+ baz: $a1;
39033951}
39043952
39053953.bar {
@@ -3908,6 +3956,39 @@ def test_extra_comma_in_mixin_arglist_error
39083956SCSS
39093957 end
39103958
3959+
3960+ def test_extra_comma_between_parameters_in_mixin_arglist
3961+ assert_raise_message ( Sass ::SyntaxError , "Invalid CSS after \" ...nclude foo(bar,\" : expected \" )\" , was \" , baz );\" " ) { render <<SCSS }
3962+ @mixin foo($a1, $a2) {
3963+ baz: $a1;
3964+ bef: $a2;
3965+ }
3966+
3967+ .bar {
3968+ @include foo(bar,, baz );
3969+ }
3970+ SCSS
3971+ end
3972+
3973+
3974+ def test_extra_comma_in_mixin_arglist_ending_needs_have_parentheses_after
3975+ assert_raise_message ( Sass ::SyntaxError , "Invalid CSS after \" bri,\" : expected \" )\" , was \" };\" " ) { render <<SCSS }
3976+ @mixin foo($a1, $a2) {
3977+ baz: $a1;
3978+ bal: $a2;
3979+ }
3980+
3981+ .bar {
3982+ @include foo(
3983+ bar,
3984+ bri,
3985+ };
3986+ }
3987+ SCSS
3988+ end
3989+
3990+
3991+
39113992 def test_interpolation
39123993 assert_equal <<CSS , render ( <<SCSS )
39133994ul li#foo a span.label {
@@ -4144,4 +4225,14 @@ def test_import_with_supports_clause
41444225SASS
41454226 end
41464227
4228+ def test_crlf
4229+ # Attempt to reproduce https://github.com/sass/sass/issues/1985
4230+ assert_equal ( <<CSS , render ( <<SCSS ) )
4231+ p {
4232+ margin: 0; }
4233+ CSS
4234+ p {\r \n margin: 0;\r \n }
4235+ SCSS
4236+ end
4237+
41474238end
0 commit comments