sass 3.1.0.alpha.221 → 3.1.0.alpha.246

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,8 +59,20 @@ class Sass::Tree::Visitors::ToCss < Sass::Tree::Visitors::Base
59
59
  return if node.invisible?
60
60
  spaces = (' ' * [@tabs - node.value[/^ */].size, 0].max)
61
61
 
62
- content = node.value.gsub(/^/, spaces)
63
- content.gsub!(/\n +(\* *(?!\/))?/, ' ') if node.style == :compact
62
+ content = node.value.gsub(/^/, spaces).gsub(%r{^(\s*)//(.*)$}) do |md|
63
+ "#{$1}/*#{$2} */"
64
+ end
65
+ if content =~ /[^\\]\#\{.*\}/
66
+ Sass::Util.sass_warn <<MESSAGE
67
+ WARNING:
68
+ On line #{node.line}#{" of '#{node.filename}'" if node.filename}
69
+ Comments will evaluate the contents of interpolations (\#{ ... }) in Sass 3.2.
70
+ Please escape the interpolation by adding a backslash before the hash sign.
71
+ MESSAGE
72
+ elsif content =~ /\\\#\{.*\}/
73
+ content.gsub!(/\\(\#\{.*\})/, '\1')
74
+ end
75
+ content.gsub!(/\n +(\* *(?!\/))?/, ' ') if (node.style == :compact || node.style == :compressed) && !node.loud
64
76
  content
65
77
  end
66
78
 
@@ -110,9 +122,9 @@ class Sass::Tree::Visitors::ToCss < Sass::Tree::Visitors::Base
110
122
  def visit_prop(node)
111
123
  tab_str = ' ' * (@tabs + node.tabs)
112
124
  if node.style == :compressed
113
- "#{tab_str}#{node.resolved_name}:#{node.resolved_value}"
125
+ "#{tab_str}#{node.resolved_name}:#{node.resolved_value}#{'!important' if node.important}"
114
126
  else
115
- "#{tab_str}#{node.resolved_name}: #{node.resolved_value};"
127
+ "#{tab_str}#{node.resolved_name}: #{node.resolved_value}#{' !important' if node.important};"
116
128
  end
117
129
  end
118
130
 
@@ -192,7 +204,7 @@ class Sass::Tree::Visitors::ToCss < Sass::Tree::Visitors::Base
192
204
  [Sass::Selector::Element.new(k.to_s.gsub(/[^\w-]/, "\\\\\\0"), nil)])
193
205
  ])
194
206
  ])
195
- prop = Sass::Tree::PropNode.new([""], "", :new)
207
+ prop = Sass::Tree::PropNode.new([""], "", false, :new)
196
208
  prop.resolved_name = "font-family"
197
209
  prop.resolved_value = Sass::SCSS::RX.escape_ident(v.to_s)
198
210
  rule << prop
@@ -165,14 +165,6 @@ SASS
165
165
  foo bar {
166
166
  baz: 12 $bang "bip"; }
167
167
  SCSS
168
-
169
- assert_sass_to_scss <<SCSS, <<SASS
170
- foo bar {
171
- baz: 12 $bang bip; }
172
- SCSS
173
- foo bar
174
- baz= 12 $bang "bip"
175
- SASS
176
168
  end
177
169
 
178
170
  def test_dynamic_properties_with_old
@@ -183,14 +175,6 @@ SASS
183
175
  foo bar {
184
176
  baz: 12 $bang "bip"; }
185
177
  SCSS
186
-
187
- assert_sass_to_scss <<SCSS, <<SASS, :old => true
188
- foo bar {
189
- baz: 12 $bang bip; }
190
- SCSS
191
- foo bar
192
- :baz= 12 $bang "bip"
193
- SASS
194
178
  end
195
179
 
196
180
  def test_multiline_properties
@@ -842,22 +826,12 @@ SASS
842
826
  a: $baz $bang; } }
843
827
  SCSS
844
828
 
845
- assert_scss_to_sass <<SASS, <<SCSS
846
- =foo-bar($baz, $bang: foo)
847
- baz
848
- a: $baz $bang
849
- SASS
850
- @mixin foo-bar($baz, $bang = "foo") {
851
- baz {
852
- a: $baz $bang; } }
853
- SCSS
854
-
855
829
  assert_sass_to_scss <<SCSS, <<SASS
856
830
  @mixin foo-bar($baz, $bang: foo) {
857
831
  baz {
858
832
  a: $baz $bang; } }
859
833
  SCSS
860
- =foo-bar($baz, $bang = "foo")
834
+ =foo-bar($baz, $bang: foo)
861
835
  baz
862
836
  a: $baz $bang
863
837
  SASS
@@ -951,8 +925,6 @@ foo {
951
925
  $var2: flaz(#abcdef);
952
926
  val: $var1 $var2; }
953
927
  SCSS
954
-
955
- assert_sass_to_scss '$var: 12px $bar baz;', '$var = 12px $bar "baz"'
956
928
  end
957
929
 
958
930
  def test_guarded_variable_definition
@@ -969,8 +941,6 @@ foo {
969
941
  $var2: flaz(#abcdef) !default;
970
942
  val: $var1 $var2; }
971
943
  SCSS
972
-
973
- assert_sass_to_scss '$var: 12px $bar baz !default;', '$var ||= 12px $bar "baz"'
974
944
  end
975
945
 
976
946
  def test_multiple_variable_definitions
@@ -1114,62 +1084,6 @@ SCSS
1114
1084
  end
1115
1085
  end
1116
1086
 
1117
- # Sass 3 Deprecation conversions
1118
-
1119
- def test_simple_quoted_strings_unquoted_with_equals
1120
- assert_sass_to_scss '$var: 1px foo + bar baz;', '!var = 1px "foo" + "bar" baz'
1121
- assert_sass_to_scss '$var: -foo-bar;', '!var = "-foo-bar"'
1122
- end
1123
-
1124
- def test_complex_quoted_strings_explicitly_unquoted_with_equals
1125
- assert_sass_to_scss '$var: 1px unquote("foo + bar") baz;', '!var = 1px "foo + bar" baz'
1126
- assert_sass_to_scss "$var: unquote('foo\"bar');", '!var = "foo\"bar"'
1127
- end
1128
-
1129
- def test_division_asserted_with_equals
1130
- assert_sass_to_scss <<SCSS, <<SASS
1131
- foo {
1132
- a: (1px / 2px); }
1133
- SCSS
1134
- foo
1135
- a = 1px / 2px
1136
- SASS
1137
- end
1138
-
1139
- def test_division_not_asserted_with_equals_when_unnecessary
1140
- assert_sass_to_scss <<SCSS, <<SASS
1141
- $var: 1px / 2px;
1142
-
1143
- foo {
1144
- a: $var; }
1145
- SCSS
1146
- !var = 1px / 2px
1147
-
1148
- foo
1149
- a = !var
1150
- SASS
1151
-
1152
- assert_sass_to_scss <<SCSS, <<SASS
1153
- $var: 1px;
1154
-
1155
- foo {
1156
- a: $var / 2px; }
1157
- SCSS
1158
- !var = 1px
1159
-
1160
- foo
1161
- a = !var / 2px
1162
- SASS
1163
-
1164
- assert_sass_to_scss <<SCSS, <<SASS
1165
- foo {
1166
- a: 1 + 1px / 2px; }
1167
- SCSS
1168
- foo
1169
- a = 1 + 1px / 2px
1170
- SASS
1171
- end
1172
-
1173
1087
  def test_nested_properties
1174
1088
  assert_renders <<SASS, <<SCSS
1175
1089
  div
@@ -1217,24 +1131,25 @@ div
1217
1131
  SASS
1218
1132
  end
1219
1133
 
1220
- def test_sass2_var_in_property_interpolation
1221
- assert_sass_to_scss <<SCSS, <<SASS
1222
- foo {
1223
- a: b \#{$c} d; }
1224
- SCSS
1225
- foo
1226
- a: b \#{!c} d
1134
+ def test_loud_comment_conversion
1135
+ assert_renders(<<SASS, <<SCSS)
1136
+ /*! \#{"interpolated"}
1137
+ /*!
1138
+ * \#{"also interpolated"}
1227
1139
  SASS
1228
- end
1229
-
1230
- def test_sass2_var_in_selector_interpolation
1231
- assert_sass_to_scss <<SCSS, <<SASS
1232
- foo-\#{$c} {
1233
- a: b; }
1140
+ /*! \#{"interpolated"} */
1141
+ /*!
1142
+ * \#{"also interpolated"} */
1234
1143
  SCSS
1235
- foo-\#{!c}
1236
- a: b
1144
+ assert_renders(<<SASS, <<SCSS)
1145
+ //! \#{"interpolated"}
1146
+ //!
1147
+ //! \#{"also interpolated"}
1237
1148
  SASS
1149
+ //! \#{"interpolated"}
1150
+ //!
1151
+ //! \#{"also interpolated"}
1152
+ SCSS
1238
1153
  end
1239
1154
 
1240
1155
  private
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
- require File.dirname(__FILE__) + '/../test_helper'
4
- require File.dirname(__FILE__) + '/test_helper'
3
+ require 'test_helper'
4
+ require 'sass/test_helper'
5
5
  require 'sass/engine'
6
6
  require 'stringio'
7
7
  require 'mock_importer'
@@ -41,9 +41,9 @@ MSG
41
41
  "a\n @extend .foo ^bar" => 'Invalid CSS after ".foo ": expected selector, was "^bar"',
42
42
  "a: b" => 'Properties are only allowed within rules, directives, or other properties.',
43
43
  ":a b" => 'Properties are only allowed within rules, directives, or other properties.',
44
- "!" => 'Invalid variable: "!".',
44
+ "$" => 'Invalid variable: "$".',
45
45
  "$a" => 'Invalid variable: "$a".',
46
- "! a" => 'Invalid variable: "! a".',
46
+ "$ a" => 'Invalid variable: "$ a".',
47
47
  "$a b" => 'Invalid variable: "$a b".',
48
48
  "$a: 1b + 2c" => "Incompatible units: 'c' and 'b'.",
49
49
  "$a: 1b < 2c" => "Incompatible units: 'c' and 'b'.",
@@ -68,6 +68,7 @@ MSG
68
68
  "@if true\n @import foo" => "Import directives may not be used within control directives or mixins.",
69
69
  "@mixin foo\n @import foo" => "Import directives may not be used within control directives or mixins.",
70
70
  '$foo: "bar" "baz" !' => %Q{Invalid CSS after ""bar" "baz" ": expected expression (e.g. 1px, bold), was "!"},
71
+ '$foo: "bar" "baz" $' => %Q{Invalid CSS after ""bar" "baz" ": expected expression (e.g. 1px, bold), was "$"},
71
72
  "=foo\n :color red\n.bar\n +bang" => "Undefined mixin 'bang'.",
72
73
  "=foo\n :color red\n.bar\n +bang_bop" => "Undefined mixin 'bang_bop'.",
73
74
  "=foo\n :color red\n.bar\n +bang-bop" => "Undefined mixin 'bang-bop'.",
@@ -90,8 +91,8 @@ MSG
90
91
  "=a($foo bar)" => 'Invalid CSS after "($foo ": expected ")", was "bar)"',
91
92
  "=foo\n bar: baz\n+foo" => ["Properties are only allowed within rules, directives, or other properties.", 2],
92
93
  "a-\#{$b\n c: d" => ['Invalid CSS after "a-#{$b": expected "}", was ""', 1],
93
- "=a($b = 1, $c)" => "Required argument $c must come before any optional arguments.",
94
- "=a($b = 1)\n a: $b\ndiv\n +a(1,2)" => "Mixin a takes 1 argument but 2 were passed.",
94
+ "=a($b: 1, $c)" => "Required argument $c must come before any optional arguments.",
95
+ "=a($b: 1)\n a: $b\ndiv\n +a(1,2)" => "Mixin a takes 1 argument but 2 were passed.",
95
96
  "=a($b: 1)\n a: $b\ndiv\n +a(1,$c: 3)" => "Mixin a doesn't have an argument named $c",
96
97
  "=a($b)\n a: $b\ndiv\n +a" => "Mixin a is missing parameter $b.",
97
98
  "@function foo()\n 1 + 2" => "Functions can only contain variable declarations and control directives.",
@@ -113,7 +114,6 @@ MSG
113
114
  "@else\n a\n b: c" => ["@else must come after @if.", 1],
114
115
  "@if false\n@else foo" => "Invalid else directive '@else foo': expected 'if <expr>'.",
115
116
  "@if false\n@else if " => "Invalid else directive '@else if': expected 'if <expr>'.",
116
- "a\n !b: 12\nc\n d: !b" => 'Undefined variable: "$b".',
117
117
  "a\n $b: 12\nc\n d: $b" => 'Undefined variable: "$b".',
118
118
  "=foo\n $b: 12\nc\n +foo\n d: $b" => 'Undefined variable: "$b".',
119
119
  "c\n d: $b-foo" => 'Undefined variable: "$b-foo".',
@@ -968,77 +968,6 @@ foo
968
968
  SASS
969
969
  end
970
970
 
971
- def test_equals_warning_for_properties
972
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
973
- DEPRECATION WARNING:
974
- On line 3, character 3 of 'test_equals_warning_for_properties_inline.sass'
975
- Setting properties with = has been deprecated and will be removed in version 3.2.
976
- Use "a: $var" instead.
977
-
978
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
979
- WARN
980
- foo {
981
- a: 2px 3px; }
982
- CSS
983
- $var: 2px 3px
984
- foo
985
- a = $var
986
- SASS
987
- end
988
-
989
- def test_equals_warning_for_dynamic_properties
990
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
991
- DEPRECATION WARNING:
992
- On line 4, character 3 of 'test_equals_warning_for_dynamic_properties_inline.sass'
993
- Setting properties with = has been deprecated and will be removed in version 3.2.
994
- Use "a-\#{$i}: $var" instead.
995
-
996
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
997
- WARN
998
- foo {
999
- a-12: 2px 3px; }
1000
- CSS
1001
- $var: 2px 3px
1002
- $i: 12
1003
- foo
1004
- a-\#{$i} = $var
1005
- SASS
1006
- end
1007
-
1008
- def test_equals_warning_for_property_with_string
1009
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1010
- DEPRECATION WARNING:
1011
- On line 2, character 3 of 'test_equals_warning_for_property_with_string_inline.sass'
1012
- Setting properties with = has been deprecated and will be removed in version 3.2.
1013
- Use "a: foo" instead.
1014
-
1015
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1016
- WARN
1017
- foo {
1018
- a: foo; }
1019
- CSS
1020
- foo
1021
- a = "foo"
1022
- SASS
1023
- end
1024
-
1025
- def test_equals_warning_for_property_with_division
1026
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1027
- DEPRECATION WARNING:
1028
- On line 2, character 3 of 'test_equals_warning_for_property_with_division_inline.sass'
1029
- Setting properties with = has been deprecated and will be removed in version 3.2.
1030
- Use "a: (1px / 2px)" instead.
1031
-
1032
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1033
- WARN
1034
- foo {
1035
- a: 0.5; }
1036
- CSS
1037
- foo
1038
- a = 1px/2px
1039
- SASS
1040
- end
1041
-
1042
971
  def test_guarded_assign
1043
972
  assert_equal("foo {\n a: b; }\n", render(%Q{$foo: b\n$foo: c !default\nfoo\n a: $foo}))
1044
973
  assert_equal("foo {\n a: b; }\n", render(%Q{$foo: b !default\nfoo\n a: $foo}))
@@ -1148,26 +1077,6 @@ a
1148
1077
  SASS
1149
1078
  end
1150
1079
 
1151
- def test_equals_warning_for_mixin_args
1152
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1153
- DEPRECATION WARNING:
1154
- On line 1, character 10 of 'test_equals_warning_for_mixin_args_inline.sass'
1155
- Setting mixin argument defaults with = has been deprecated and will be removed in version 3.2.
1156
- Use "$arg: 1px" instead.
1157
-
1158
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1159
- WARN
1160
- bar {
1161
- a: 1px; }
1162
- CSS
1163
- =foo($arg = 1px)
1164
- a: $arg
1165
-
1166
- bar
1167
- +foo
1168
- SASS
1169
- end
1170
-
1171
1080
  def test_css_identifier_mixin
1172
1081
  assert_equal(<<CSS, render(<<SASS))
1173
1082
  a {
@@ -1336,30 +1245,6 @@ $a: 3
1336
1245
  SASS
1337
1246
  end
1338
1247
 
1339
- def test_for_with_bang_var
1340
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1341
- DEPRECATION WARNING:
1342
- On line 1, character 6 of 'test_for_with_bang_var_inline.sass'
1343
- Variables with ! have been deprecated and will be removed in version 3.2.
1344
- Use "$bar" instead.
1345
-
1346
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1347
- WARN
1348
- a-0 {
1349
- b: c; }
1350
-
1351
- a-1 {
1352
- b: c; }
1353
-
1354
- a-2 {
1355
- b: c; }
1356
- CSS
1357
- @for !bar from 0 to 3
1358
- a-\#{$bar}
1359
- b: c
1360
- SASS
1361
- end
1362
-
1363
1248
  def test_while
1364
1249
  assert_equal(<<CSS, render(<<SASS))
1365
1250
  a-5 {
@@ -1462,78 +1347,6 @@ a
1462
1347
  SASS
1463
1348
  end
1464
1349
 
1465
- def test_bang_variables
1466
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1467
- DEPRECATION WARNING:
1468
- On line 1, character 1 of 'test_bang_variables_inline.sass'
1469
- Variables with ! have been deprecated and will be removed in version 3.2.
1470
- Use "$bang-var" instead.
1471
-
1472
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1473
- WARN
1474
- foo {
1475
- a: 1px; }
1476
- CSS
1477
- !bang-var: 1px
1478
- foo
1479
- a: $bang-var
1480
- SASS
1481
-
1482
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1483
- DEPRECATION WARNING:
1484
- On line 3, character 6 of 'test_bang_variables_inline.sass'
1485
- Variables with ! have been deprecated and will be removed in version 3.2.
1486
- Use "$dollar-var" instead.
1487
-
1488
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1489
- WARN
1490
- foo {
1491
- a: 1px; }
1492
- CSS
1493
- $dollar-var: 1px
1494
- foo
1495
- a: !dollar-var
1496
- SASS
1497
- end
1498
-
1499
- def test_equals_warning_for_variables
1500
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1501
- DEPRECATION WARNING:
1502
- On line 2, character 1 of 'test_equals_warning_for_variables_inline.sass'
1503
- Setting variables with = has been deprecated and will be removed in version 3.2.
1504
- Use "$equals-var: 2px 3px" instead.
1505
-
1506
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1507
- WARN
1508
- foo {
1509
- a: 2px 3px; }
1510
- CSS
1511
-
1512
- $equals-var = 2px 3px
1513
- foo
1514
- a: $equals-var
1515
- SASS
1516
- end
1517
-
1518
- def test_equals_warning_for_guarded_variables
1519
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1520
- DEPRECATION WARNING:
1521
- On line 2, character 1 of 'test_equals_warning_for_guarded_variables_inline.sass'
1522
- Setting variable defaults with ||= has been deprecated and will be removed in version 3.2.
1523
- Use "$equals-var: 2px 3px !default" instead.
1524
-
1525
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1526
- WARN
1527
- foo {
1528
- a: 2px 3px; }
1529
- CSS
1530
-
1531
- $equals-var ||= 2px 3px
1532
- foo
1533
- a: $equals-var
1534
- SASS
1535
- end
1536
-
1537
1350
  def test_variable_scope
1538
1351
  assert_equal(<<CSS, render(<<SASS))
1539
1352
  a {
@@ -1715,6 +1528,47 @@ foo
1715
1528
  SASS
1716
1529
  end
1717
1530
 
1531
+ def test_loud_comment_in_compressed_mode
1532
+ assert_equal <<CSS, render(<<SASS, :style => :compressed)
1533
+ foo{color:blue;/* foo
1534
+ * bar
1535
+ */}
1536
+ CSS
1537
+ foo
1538
+ color: blue
1539
+ /*! foo
1540
+ * bar
1541
+ */
1542
+ SASS
1543
+ end
1544
+ def test_loud_comment_in_silent_comment
1545
+ assert_equal <<CSS, render(<<SASS, :style => :compressed)
1546
+ foo{color:blue;/* foo */
1547
+ /* bar */
1548
+ /* */
1549
+ /* bip */
1550
+ /* baz */}
1551
+ CSS
1552
+ foo
1553
+ color: blue
1554
+ //! foo
1555
+ //! bar
1556
+ //!
1557
+ bip
1558
+ baz
1559
+ SASS
1560
+ end
1561
+
1562
+ def test_loud_comment_is_evaluated
1563
+ assert_equal <<CSS, render(<<SASS)
1564
+ /*
1565
+ * Hue: 327.216deg */
1566
+ CSS
1567
+ /*!
1568
+ Hue: \#{hue(#f836a0)}
1569
+ SASS
1570
+ end
1571
+
1718
1572
  def test_attribute_selector_with_spaces
1719
1573
  assert_equal(<<CSS, render(<<SASS))
1720
1574
  a b[foo=bar] {
@@ -1919,182 +1773,6 @@ CSS
1919
1773
  SASS
1920
1774
  end
1921
1775
 
1922
- # Deprecated equals behavior
1923
-
1924
- def test_equals_properties_unquote_strings
1925
- silence_warnings do
1926
- assert_equal(<<CSS, render(<<SASS))
1927
- foo {
1928
- a: foo;
1929
- b: bar;
1930
- c: foo bar;
1931
- d: foo, bar baz;
1932
- e: foo bar, bar; }
1933
- CSS
1934
- foo
1935
- a= "foo"
1936
- b= bar
1937
- c= "foo" bar
1938
- d= foo, "bar baz"
1939
- e= "foo bar", bar
1940
- SASS
1941
- end
1942
- end
1943
-
1944
- def test_equals_properties_unquote_value
1945
- silence_warnings do
1946
- assert_equal(<<CSS, render(<<SASS))
1947
- foo {
1948
- a: foo; }
1949
- CSS
1950
- $var: "foo"
1951
-
1952
- foo
1953
- a= $var
1954
- SASS
1955
- end
1956
- end
1957
-
1958
- def test_equals_properties_deep_unquote_vars
1959
- silence_warnings do
1960
- assert_equal(<<CSS, render(<<SASS))
1961
- foo {
1962
- a: foo bar;
1963
- b: bar foo; }
1964
- CSS
1965
- $var: "foo"
1966
-
1967
- foo
1968
- a= $var "bar"
1969
- b= "bar" $var
1970
- SASS
1971
- end
1972
- end
1973
-
1974
- def test_equals_vars_unquote_strings
1975
- silence_warnings do
1976
- assert_equal(<<CSS, render(<<SASS))
1977
- foo {
1978
- a: foo;
1979
- b: bar;
1980
- c: foo bar;
1981
- d: foo, bar; }
1982
- CSS
1983
- $a = "foo"
1984
- $b = bar
1985
- $c = "foo" bar
1986
- $d = foo, "bar"
1987
-
1988
- foo
1989
- a: $a
1990
- b: $b
1991
- c: $c
1992
- d: $d
1993
- SASS
1994
- end
1995
- end
1996
-
1997
- def test_equals_vars_unquote_value
1998
- silence_warnings do
1999
- assert_equal(<<CSS, render(<<SASS))
2000
- foo {
2001
- a: foo; }
2002
- CSS
2003
- $var1: "foo"
2004
- $var2 = $var1
2005
-
2006
- foo
2007
- a: $var2
2008
- SASS
2009
- end
2010
- end
2011
-
2012
- def test_equals_vars_deep_unquote_vars
2013
- silence_warnings do
2014
- assert_equal(<<CSS, render(<<SASS))
2015
- foo {
2016
- a: foo bar;
2017
- b: bar foo; }
2018
- CSS
2019
- $var: "foo"
2020
- $a = $var "bar"
2021
- $b = "bar" $var
2022
-
2023
- foo
2024
- a: $a
2025
- b: $b
2026
- SASS
2027
- end
2028
- end
2029
-
2030
- def test_equals_args_unquote_strings
2031
- silence_warnings do
2032
- assert_equal(<<CSS, render(<<SASS))
2033
- foo {
2034
- a: foo;
2035
- b: bar;
2036
- c: foo bar;
2037
- d: foo, bar; }
2038
- CSS
2039
- =foo($a = "foo", $b = bar, $c = "foo" bar, $d = (foo, "bar"))
2040
- foo
2041
- a: $a
2042
- b: $b
2043
- c: $c
2044
- d: $d
2045
-
2046
- +foo
2047
- SASS
2048
- end
2049
- end
2050
-
2051
- def test_equals_args_unquote_value
2052
- silence_warnings do
2053
- assert_equal(<<CSS, render(<<SASS))
2054
- foo {
2055
- a: foo; }
2056
- CSS
2057
- $var1: "foo"
2058
-
2059
- =foo($var2 = $var1)
2060
- foo
2061
- a: $var2
2062
-
2063
- +foo
2064
- SASS
2065
- end
2066
- end
2067
-
2068
- def test_equals_args_deep_unquote_vars
2069
- silence_warnings do
2070
- assert_equal(<<CSS, render(<<SASS))
2071
- foo {
2072
- a: foo bar;
2073
- b: bar foo; }
2074
- CSS
2075
- $var: "foo"
2076
- =foo($a = $var "bar", $b = "bar" $var)
2077
- foo
2078
- a: $a
2079
- b: $b
2080
-
2081
- +foo
2082
- SASS
2083
- end
2084
- end
2085
-
2086
- def test_equals_properties_force_division
2087
- silence_warnings do
2088
- assert_equal(<<CSS, render(<<SASS))
2089
- foo {
2090
- a: 0.5; }
2091
- CSS
2092
- foo
2093
- a = 1px/2px
2094
- SASS
2095
- end
2096
- end
2097
-
2098
1776
  def test_warn_directive
2099
1777
  expected_warning = <<EXPECTATION
2100
1778
  WARNING: this is a warning
@@ -2569,6 +2247,28 @@ CSS
2569
2247
  SASS
2570
2248
  end
2571
2249
 
2250
+ def test_comment_interpolation_warning
2251
+ assert_warning(<<END) {render("/* \#{foo}")}
2252
+ WARNING:
2253
+ On line 1 of 'test_comment_interpolation_warning_inline.sass'
2254
+ Comments will evaluate the contents of interpolations (\#{ ... }) in Sass 3.2.
2255
+ Please escape the interpolation by adding a backslash before the hash sign.
2256
+ END
2257
+ end
2258
+
2259
+ def test_loud_comment_interpolations_can_be_escaped
2260
+ assert_equal <<CSS, render(<<SASS)
2261
+ /* \#{foo} */
2262
+ CSS
2263
+ /* \\\#{foo}
2264
+ SASS
2265
+ assert_equal <<CSS, render(<<SASS)
2266
+ /* \#{foo} */
2267
+ CSS
2268
+ /*! \\\#{foo}
2269
+ SASS
2270
+ end
2271
+
2572
2272
  # Encodings
2573
2273
 
2574
2274
  unless Sass::Util.ruby1_8?