haml 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of haml might be problematic. Click here for more details.

Files changed (87) hide show
  1. data/VERSION +1 -1
  2. data/vendor/sass/Rakefile +22 -46
  3. data/vendor/sass/VERSION +1 -1
  4. data/vendor/sass/VERSION_NAME +1 -1
  5. data/vendor/sass/bin/scss +8 -0
  6. data/vendor/sass/doc-src/SASS_CHANGELOG.md +125 -9
  7. data/vendor/sass/doc-src/SASS_REFERENCE.md +84 -8
  8. data/vendor/sass/lib/sass.rb +0 -3
  9. data/vendor/sass/lib/sass/cache_stores.rb +1 -0
  10. data/vendor/sass/lib/sass/cache_stores/base.rb +2 -2
  11. data/vendor/sass/lib/sass/cache_stores/chain.rb +33 -0
  12. data/vendor/sass/lib/sass/cache_stores/filesystem.rb +6 -4
  13. data/vendor/sass/lib/sass/cache_stores/memory.rb +8 -12
  14. data/vendor/sass/lib/sass/engine.rb +65 -56
  15. data/vendor/sass/lib/sass/environment.rb +5 -2
  16. data/vendor/sass/lib/sass/exec.rb +52 -21
  17. data/vendor/sass/lib/sass/importers/filesystem.rb +32 -9
  18. data/vendor/sass/lib/sass/less.rb +1 -1
  19. data/vendor/sass/lib/sass/plugin.rb +11 -1
  20. data/vendor/sass/lib/sass/plugin/compiler.rb +21 -12
  21. data/vendor/sass/lib/sass/plugin/rails.rb +8 -82
  22. data/vendor/sass/lib/sass/plugin/staleness_checker.rb +10 -10
  23. data/vendor/sass/lib/sass/railtie.rb +3 -2
  24. data/vendor/sass/lib/sass/script.rb +2 -25
  25. data/vendor/sass/lib/sass/script/color.rb +4 -15
  26. data/vendor/sass/lib/sass/script/funcall.rb +63 -19
  27. data/vendor/sass/lib/sass/script/functions.rb +257 -19
  28. data/vendor/sass/lib/sass/script/lexer.rb +1 -4
  29. data/vendor/sass/lib/sass/script/list.rb +2 -2
  30. data/vendor/sass/lib/sass/script/node.rb +0 -27
  31. data/vendor/sass/lib/sass/script/number.rb +1 -1
  32. data/vendor/sass/lib/sass/script/operation.rb +0 -5
  33. data/vendor/sass/lib/sass/script/parser.rb +30 -12
  34. data/vendor/sass/lib/sass/script/string.rb +2 -17
  35. data/vendor/sass/lib/sass/script/string_interpolation.rb +1 -0
  36. data/vendor/sass/lib/sass/scss/parser.rb +58 -18
  37. data/vendor/sass/lib/sass/scss/rx.rb +2 -1
  38. data/vendor/sass/lib/sass/scss/script_lexer.rb +1 -1
  39. data/vendor/sass/lib/sass/selector/comma_sequence.rb +2 -3
  40. data/vendor/sass/lib/sass/selector/sequence.rb +3 -6
  41. data/vendor/sass/lib/sass/selector/simple_sequence.rb +2 -3
  42. data/vendor/sass/lib/sass/tree/charset_node.rb +0 -15
  43. data/vendor/sass/lib/sass/tree/comment_node.rb +20 -71
  44. data/vendor/sass/lib/sass/tree/debug_node.rb +4 -22
  45. data/vendor/sass/lib/sass/tree/directive_node.rb +0 -52
  46. data/vendor/sass/lib/sass/tree/each_node.rb +8 -38
  47. data/vendor/sass/lib/sass/tree/extend_node.rb +12 -48
  48. data/vendor/sass/lib/sass/tree/for_node.rb +20 -51
  49. data/vendor/sass/lib/sass/tree/function_node.rb +27 -0
  50. data/vendor/sass/lib/sass/tree/if_node.rb +22 -57
  51. data/vendor/sass/lib/sass/tree/import_node.rb +0 -56
  52. data/vendor/sass/lib/sass/tree/media_node.rb +0 -43
  53. data/vendor/sass/lib/sass/tree/mixin_def_node.rb +12 -45
  54. data/vendor/sass/lib/sass/tree/mixin_node.rb +13 -124
  55. data/vendor/sass/lib/sass/tree/node.rb +18 -304
  56. data/vendor/sass/lib/sass/tree/prop_node.rb +24 -92
  57. data/vendor/sass/lib/sass/tree/return_node.rb +18 -0
  58. data/vendor/sass/lib/sass/tree/root_node.rb +4 -133
  59. data/vendor/sass/lib/sass/tree/rule_node.rb +21 -164
  60. data/vendor/sass/lib/sass/tree/variable_node.rb +14 -23
  61. data/vendor/sass/lib/sass/tree/visitors/base.rb +75 -0
  62. data/vendor/sass/lib/sass/tree/visitors/check_nesting.rb +134 -0
  63. data/vendor/sass/lib/sass/tree/visitors/convert.rb +255 -0
  64. data/vendor/sass/lib/sass/tree/visitors/cssize.rb +175 -0
  65. data/vendor/sass/lib/sass/tree/visitors/perform.rb +301 -0
  66. data/vendor/sass/lib/sass/tree/visitors/to_css.rb +216 -0
  67. data/vendor/sass/lib/sass/tree/warn_node.rb +4 -28
  68. data/vendor/sass/lib/sass/tree/while_node.rb +5 -35
  69. data/vendor/sass/lib/sass/util.rb +0 -50
  70. data/vendor/sass/sass.gemspec +1 -1
  71. data/vendor/sass/test/sass/conversion_test.rb +53 -102
  72. data/vendor/sass/test/sass/engine_test.rb +416 -540
  73. data/vendor/sass/test/sass/functions_test.rb +306 -4
  74. data/vendor/sass/test/sass/importer_test.rb +0 -22
  75. data/vendor/sass/test/sass/plugin_test.rb +51 -21
  76. data/vendor/sass/test/sass/results/if.css +3 -0
  77. data/vendor/sass/test/sass/script_conversion_test.rb +0 -38
  78. data/vendor/sass/test/sass/script_test.rb +19 -4
  79. data/vendor/sass/test/sass/scss/scss_test.rb +32 -11
  80. data/vendor/sass/test/sass/templates/if.sass +11 -0
  81. data/vendor/sass/test/sass/templates/nested_import.sass +2 -0
  82. data/vendor/sass/test/sass/util_test.rb +0 -21
  83. data/vendor/sass/test/test_helper.rb +0 -3
  84. metadata +268 -258
  85. data/vendor/sass/bin/css2sass +0 -13
  86. data/vendor/sass/lib/sass/cache_stores/active_support.rb +0 -28
  87. data/vendor/sass/lib/sass/importers/rails.rb +0 -75
@@ -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'
@@ -39,11 +39,11 @@ MSG
39
39
  "a\n b: c;" => 'Invalid CSS after "c": expected expression (e.g. 1px, bold), was ";"',
40
40
  ".foo ^bar\n a: b" => ['Invalid CSS after ".foo ": expected selector, was "^bar"', 1],
41
41
  "a\n @extend .foo ^bar" => 'Invalid CSS after ".foo ": expected selector, was "^bar"',
42
- "a: b" => 'Properties aren\'t allowed at the root of a document.',
43
- ":a b" => 'Properties aren\'t allowed at the root of a document.',
44
- "!" => 'Invalid variable: "!".',
42
+ "a: b" => 'Properties are only allowed within rules, directives, or other properties.',
43
+ ":a b" => 'Properties are only allowed within rules, directives, or other properties.',
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'.",
@@ -64,9 +64,11 @@ File to import not found or unreadable: foo.sass.
64
64
  Load path: .
65
65
  MSG
66
66
  "@import templates/basic\n foo" => "Illegal nesting: Nothing may be nested beneath import directives.",
67
- "foo\n @import templates/basic" => "Import directives may only be used at the root of a document.",
68
- "foo\n @import #{File.dirname(__FILE__)}/templates/basic" => "Import directives may only be used at the root of a document.",
67
+ "foo\n @import foo.css" => "CSS import directives may only be used at the root of a document.",
68
+ "@if true\n @import foo" => "Import directives may not be used within control directives or mixins.",
69
+ "@mixin foo\n @import foo" => "Import directives may not be used within control directives or mixins.",
69
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 "$"},
70
72
  "=foo\n :color red\n.bar\n +bang" => "Undefined mixin 'bang'.",
71
73
  "=foo\n :color red\n.bar\n +bang_bop" => "Undefined mixin 'bang_bop'.",
72
74
  "=foo\n :color red\n.bar\n +bang-bop" => "Undefined mixin 'bang-bop'.",
@@ -87,16 +89,31 @@ MSG
87
89
  "=a(,)" => 'Invalid CSS after "(": expected variable (e.g. $foo), was ",)"',
88
90
  "=a($)" => 'Invalid CSS after "(": expected variable (e.g. $foo), was "$)"',
89
91
  "=a($foo bar)" => 'Invalid CSS after "($foo ": expected ")", was "bar)"',
90
- "=foo\n bar: baz\n+foo" => ["Properties aren't allowed at the root of a document.", 2],
92
+ "=foo\n bar: baz\n+foo" => ["Properties are only allowed within rules, directives, or other properties.", 2],
91
93
  "a-\#{$b\n c: d" => ['Invalid CSS after "a-#{$b": expected "}", was ""', 1],
92
- "=a($b = 1, $c)" => "Required argument $c must come before any optional arguments.",
93
- "=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.",
94
96
  "=a($b: 1)\n a: $b\ndiv\n +a(1,$c: 3)" => "Mixin a doesn't have an argument named $c",
95
97
  "=a($b)\n a: $b\ndiv\n +a" => "Mixin a is missing parameter $b.",
98
+ "@function foo()\n 1 + 2" => "Functions can only contain variable declarations and control directives.",
99
+ "@function foo()\n foo: bar" => "Functions can only contain variable declarations and control directives.",
100
+ "@function foo()\n foo: bar\n @return 3" => ["Functions can only contain variable declarations and control directives.", 2],
101
+ "@function foo\n @return 1" => ['Invalid CSS after "": expected "(", was ""', 1],
102
+ "@function foo(\n @return 1" => ['Invalid CSS after "(": expected variable (e.g. $foo), was ""', 1],
103
+ "@function foo(b)\n @return 1" => ['Invalid CSS after "(": expected variable (e.g. $foo), was "b)"', 1],
104
+ "@function foo(,)\n @return 1" => ['Invalid CSS after "(": expected variable (e.g. $foo), was ",)"', 1],
105
+ "@function foo($)\n @return 1" => ['Invalid CSS after "(": expected variable (e.g. $foo), was "$)"', 1],
106
+ "@function foo()\n @return" => 'Invalid @return: expected expression.',
107
+ "@function foo()\n @return 1\n $var: val" => 'Illegal nesting: Nothing may be nested beneath return directives.',
108
+ "foo\n @function bar()\n @return 1" => ['Functions may only be defined at the root of a document.', 2],
109
+ "@function foo($a)\n @return 1\na\n b: foo()" => 'Function foo is missing parameter $a.',
110
+ "@function foo()\n @return 1\na\n b: foo(2)" => 'Wrong number of arguments (1 for 0) for `foo\'',
111
+ "@return 1" => '@return may only be used within a function.',
112
+ "@if true\n @return 1" => '@return may only be used within a function.',
113
+ "@mixin foo\n @return 1\n@include foo" => ['@return may only be used within a function.', 2],
96
114
  "@else\n a\n b: c" => ["@else must come after @if.", 1],
97
115
  "@if false\n@else foo" => "Invalid else directive '@else foo': expected 'if <expr>'.",
98
116
  "@if false\n@else if " => "Invalid else directive '@else if': expected 'if <expr>'.",
99
- "a\n !b: 12\nc\n d: !b" => 'Undefined variable: "$b".',
100
117
  "a\n $b: 12\nc\n d: $b" => 'Undefined variable: "$b".',
101
118
  "=foo\n $b: 12\nc\n +foo\n d: $b" => 'Undefined variable: "$b".',
102
119
  "c\n d: $b-foo" => 'Undefined variable: "$b-foo".',
@@ -123,6 +140,10 @@ MSG
123
140
  "a\n b: foo($var: a, $var: b)" => 'Keyword argument "$var" passed more than once',
124
141
  "a\n b: foo($var-var: a, $var_var: b)" => 'Keyword argument "$var-var" passed more than once',
125
142
  "a\n b: foo($var_var: a, $var-var: b)" => 'Keyword argument "$var_var" passed more than once',
143
+ "@if foo\n @extend .bar" => ["Extend directives may only be used within rules.", 2],
144
+ "$var: true\n@while $var\n @extend .bar\n $var: false" => ["Extend directives may only be used within rules.", 3],
145
+ "@for $i from 0 to 1\n @extend .bar" => ["Extend directives may only be used within rules.", 2],
146
+ "@mixin foo\n @extend .bar\n@include foo" => ["Extend directives may only be used within rules.", 2],
126
147
 
127
148
  # Regression tests
128
149
  "a\n b:\n c\n d" => ["Illegal nesting: Only properties may be nested beneath properties.", 3],
@@ -507,7 +528,7 @@ SASS
507
528
  rescue Sass::SyntaxError => e
508
529
  assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e, opts).split("\n")[0..11].join("\n"))
509
530
  /*
510
- Syntax error: Properties aren't allowed at the root of a document.
531
+ Syntax error: Properties are only allowed within rules, directives, or other properties.
511
532
  on line 4 of test_cssize_exception_css_inline.sass
512
533
 
513
534
  1: .filler
@@ -531,6 +552,13 @@ CSS
531
552
  render("@import \"http://fonts.googleapis.com/css?family=Droid+Sans\""))
532
553
  end
533
554
 
555
+ def test_http_import_with_interpolation
556
+ assert_equal("@import url(http://fonts.googleapis.com/css?family=Droid+Sans);\n",
557
+ render("$family: unquote(\"Droid+Sans\")\n@import \"http://fonts.googleapis.com/css?family=\#{$family}\"\n"))
558
+ assert_equal("@import url(\"http://fonts.googleapis.com/css?family=Droid+Sans\");\n",
559
+ render("$family: unquote(\"Droid+Sans\")\n@import url(\"http://fonts.googleapis.com/css?family=\#{$family}\")\n"))
560
+ end
561
+
534
562
  def test_url_import
535
563
  assert_equal("@import url(fonts.sass);\n", render("@import url(fonts.sass)"))
536
564
  end
@@ -569,6 +597,43 @@ ERR
569
597
  assert !File.exists?(sassc_path("importee"))
570
598
  end
571
599
 
600
+ def test_import_in_rule
601
+ assert_equal(<<CSS, render(<<SASS, :load_paths => [File.dirname(__FILE__) + '/templates/']))
602
+ .foo #foo {
603
+ background-color: #bbaaff; }
604
+
605
+ .bar {
606
+ a: b; }
607
+ .bar #foo {
608
+ background-color: #bbaaff; }
609
+ CSS
610
+ .foo
611
+ @import partial
612
+
613
+ .bar
614
+ a: b
615
+ @import partial
616
+ SASS
617
+ end
618
+
619
+ def test_nested_import_with_toplevel_constructs
620
+ Sass::Engine.new(".foo\n @import importee", :load_paths => [File.dirname(__FILE__) + '/templates/']).render
621
+ rescue Sass::SyntaxError => err
622
+ assert_equal(3, err.sass_line)
623
+ assert_match(/(\/|^)importee\.sass$/, err.sass_filename)
624
+
625
+ assert_hash_has(err.sass_backtrace.first,
626
+ :filename => err.sass_filename, :line => err.sass_line)
627
+
628
+ assert_nil(err.sass_backtrace[1][:filename])
629
+ assert_equal(2, err.sass_backtrace[1][:line])
630
+
631
+ assert_match(/(\/|^)importee\.sass:3$/, err.backtrace.first)
632
+ assert_equal("(sass):2", err.backtrace[1])
633
+ else
634
+ assert(false, "Exception not raised for importing mixins nested")
635
+ end
636
+
572
637
  def test_units
573
638
  renders_correctly "units"
574
639
  end
@@ -910,77 +975,6 @@ foo
910
975
  SASS
911
976
  end
912
977
 
913
- def test_equals_warning_for_properties
914
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
915
- DEPRECATION WARNING:
916
- On line 3, character 3 of 'test_equals_warning_for_properties_inline.sass'
917
- Setting properties with = has been deprecated and will be removed in version 3.2.
918
- Use "a: $var" instead.
919
-
920
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
921
- WARN
922
- foo {
923
- a: 2px 3px; }
924
- CSS
925
- $var: 2px 3px
926
- foo
927
- a = $var
928
- SASS
929
- end
930
-
931
- def test_equals_warning_for_dynamic_properties
932
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
933
- DEPRECATION WARNING:
934
- On line 4, character 3 of 'test_equals_warning_for_dynamic_properties_inline.sass'
935
- Setting properties with = has been deprecated and will be removed in version 3.2.
936
- Use "a-\#{$i}: $var" instead.
937
-
938
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
939
- WARN
940
- foo {
941
- a-12: 2px 3px; }
942
- CSS
943
- $var: 2px 3px
944
- $i: 12
945
- foo
946
- a-\#{$i} = $var
947
- SASS
948
- end
949
-
950
- def test_equals_warning_for_property_with_string
951
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
952
- DEPRECATION WARNING:
953
- On line 2, character 3 of 'test_equals_warning_for_property_with_string_inline.sass'
954
- Setting properties with = has been deprecated and will be removed in version 3.2.
955
- Use "a: foo" instead.
956
-
957
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
958
- WARN
959
- foo {
960
- a: foo; }
961
- CSS
962
- foo
963
- a = "foo"
964
- SASS
965
- end
966
-
967
- def test_equals_warning_for_property_with_division
968
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
969
- DEPRECATION WARNING:
970
- On line 2, character 3 of 'test_equals_warning_for_property_with_division_inline.sass'
971
- Setting properties with = has been deprecated and will be removed in version 3.2.
972
- Use "a: (1px / 2px)" instead.
973
-
974
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
975
- WARN
976
- foo {
977
- a: 0.5; }
978
- CSS
979
- foo
980
- a = 1px/2px
981
- SASS
982
- end
983
-
984
978
  def test_guarded_assign
985
979
  assert_equal("foo {\n a: b; }\n", render(%Q{$foo: b\n$foo: c !default\nfoo\n a: $foo}))
986
980
  assert_equal("foo {\n a: b; }\n", render(%Q{$foo: b !default\nfoo\n a: $foo}))
@@ -1090,36 +1084,100 @@ a
1090
1084
  SASS
1091
1085
  end
1092
1086
 
1093
- def test_equals_warning_for_mixin_args
1094
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1095
- DEPRECATION WARNING:
1096
- On line 1, character 10 of 'test_equals_warning_for_mixin_args_inline.sass'
1097
- Setting mixin argument defaults with = has been deprecated and will be removed in version 3.2.
1098
- Use "$arg: 1px" instead.
1087
+ def test_css_identifier_mixin
1088
+ assert_equal(<<CSS, render(<<SASS))
1089
+ a {
1090
+ foo: 12; }
1091
+ CSS
1092
+ =\\{foo\\(12\\)($a)
1093
+ foo: $a
1099
1094
 
1100
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1101
- WARN
1095
+ a
1096
+ +\\{foo\\(12\\)(12)
1097
+ SASS
1098
+ end
1099
+
1100
+ def test_basic_function
1101
+ assert_equal(<<CSS, render(<<SASS))
1102
1102
  bar {
1103
- a: 1px; }
1103
+ a: 3; }
1104
1104
  CSS
1105
- =foo($arg = 1px)
1106
- a: $arg
1105
+ @function foo()
1106
+ @return 1 + 2
1107
1107
 
1108
1108
  bar
1109
- +foo
1109
+ a: foo()
1110
1110
  SASS
1111
1111
  end
1112
1112
 
1113
- def test_css_identifier_mixin
1113
+ def test_function_args
1114
1114
  assert_equal(<<CSS, render(<<SASS))
1115
- a {
1116
- foo: 12; }
1115
+ bar {
1116
+ a: 3; }
1117
1117
  CSS
1118
- =\\{foo\\(12\\)($a)
1119
- foo: $a
1118
+ @function plus($var1, $var2)
1119
+ @return $var1 + $var2
1120
1120
 
1121
- a
1122
- +\\{foo\\(12\\)(12)
1121
+ bar
1122
+ a: plus(1, 2)
1123
+ SASS
1124
+ end
1125
+
1126
+ def test_function_arg_default
1127
+ assert_equal(<<CSS, render(<<SASS))
1128
+ bar {
1129
+ a: 3; }
1130
+ CSS
1131
+ @function plus($var1, $var2: 2)
1132
+ @return $var1 + $var2
1133
+
1134
+ bar
1135
+ a: plus(1)
1136
+ SASS
1137
+ end
1138
+
1139
+ def test_function_arg_keyword
1140
+ assert_equal(<<CSS, render(<<SASS))
1141
+ bar {
1142
+ a: 1bar; }
1143
+ CSS
1144
+ @function plus($var1: 1, $var2: 2)
1145
+ @return $var1 + $var2
1146
+
1147
+ bar
1148
+ a: plus($var2: bar)
1149
+ SASS
1150
+ end
1151
+
1152
+ def test_function_with_if
1153
+ assert_equal(<<CSS, render(<<SASS))
1154
+ bar {
1155
+ a: foo;
1156
+ b: bar; }
1157
+ CSS
1158
+ @function my-if($cond, $val1, $val2)
1159
+ @if $cond
1160
+ @return $val1
1161
+ @else
1162
+ @return $val2
1163
+
1164
+ bar
1165
+ a: my-if(true, foo, bar)
1166
+ b: my-if(false, foo, bar)
1167
+ SASS
1168
+ end
1169
+
1170
+ def test_function_with_var
1171
+ assert_equal(<<CSS, render(<<SASS))
1172
+ bar {
1173
+ a: 1; }
1174
+ CSS
1175
+ @function foo($val1, $val2)
1176
+ $intermediate: $val1 + $val2
1177
+ @return $intermediate/3
1178
+
1179
+ bar
1180
+ a: foo(1, 2)
1123
1181
  SASS
1124
1182
  end
1125
1183
 
@@ -1194,30 +1252,6 @@ $a: 3
1194
1252
  SASS
1195
1253
  end
1196
1254
 
1197
- def test_for_with_bang_var
1198
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1199
- DEPRECATION WARNING:
1200
- On line 1, character 6 of 'test_for_with_bang_var_inline.sass'
1201
- Variables with ! have been deprecated and will be removed in version 3.2.
1202
- Use "$bar" instead.
1203
-
1204
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1205
- WARN
1206
- a-0 {
1207
- b: c; }
1208
-
1209
- a-1 {
1210
- b: c; }
1211
-
1212
- a-2 {
1213
- b: c; }
1214
- CSS
1215
- @for !bar from 0 to 3
1216
- a-\#{$bar}
1217
- b: c
1218
- SASS
1219
- end
1220
-
1221
1255
  def test_while
1222
1256
  assert_equal(<<CSS, render(<<SASS))
1223
1257
  a-5 {
@@ -1320,78 +1354,6 @@ a
1320
1354
  SASS
1321
1355
  end
1322
1356
 
1323
- def test_bang_variables
1324
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1325
- DEPRECATION WARNING:
1326
- On line 1, character 1 of 'test_bang_variables_inline.sass'
1327
- Variables with ! have been deprecated and will be removed in version 3.2.
1328
- Use "$bang-var" instead.
1329
-
1330
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1331
- WARN
1332
- foo {
1333
- a: 1px; }
1334
- CSS
1335
- !bang-var: 1px
1336
- foo
1337
- a: $bang-var
1338
- SASS
1339
-
1340
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1341
- DEPRECATION WARNING:
1342
- On line 3, character 6 of 'test_bang_variables_inline.sass'
1343
- Variables with ! have been deprecated and will be removed in version 3.2.
1344
- Use "$dollar-var" instead.
1345
-
1346
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1347
- WARN
1348
- foo {
1349
- a: 1px; }
1350
- CSS
1351
- $dollar-var: 1px
1352
- foo
1353
- a: !dollar-var
1354
- SASS
1355
- end
1356
-
1357
- def test_equals_warning_for_variables
1358
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1359
- DEPRECATION WARNING:
1360
- On line 2, character 1 of 'test_equals_warning_for_variables_inline.sass'
1361
- Setting variables with = has been deprecated and will be removed in version 3.2.
1362
- Use "$equals-var: 2px 3px" instead.
1363
-
1364
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1365
- WARN
1366
- foo {
1367
- a: 2px 3px; }
1368
- CSS
1369
-
1370
- $equals-var = 2px 3px
1371
- foo
1372
- a: $equals-var
1373
- SASS
1374
- end
1375
-
1376
- def test_equals_warning_for_guarded_variables
1377
- assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
1378
- DEPRECATION WARNING:
1379
- On line 2, character 1 of 'test_equals_warning_for_guarded_variables_inline.sass'
1380
- Setting variable defaults with ||= has been deprecated and will be removed in version 3.2.
1381
- Use "$equals-var: 2px 3px !default" instead.
1382
-
1383
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
1384
- WARN
1385
- foo {
1386
- a: 2px 3px; }
1387
- CSS
1388
-
1389
- $equals-var ||= 2px 3px
1390
- foo
1391
- a: $equals-var
1392
- SASS
1393
- end
1394
-
1395
1357
  def test_variable_scope
1396
1358
  assert_equal(<<CSS, render(<<SASS))
1397
1359
  a {
@@ -1573,6 +1535,47 @@ foo
1573
1535
  SASS
1574
1536
  end
1575
1537
 
1538
+ def test_loud_comment_in_compressed_mode
1539
+ assert_equal <<CSS, render(<<SASS, :style => :compressed)
1540
+ foo{color:blue;/* foo
1541
+ * bar
1542
+ */}
1543
+ CSS
1544
+ foo
1545
+ color: blue
1546
+ /*! foo
1547
+ * bar
1548
+ */
1549
+ SASS
1550
+ end
1551
+ def test_loud_comment_in_silent_comment
1552
+ assert_equal <<CSS, render(<<SASS, :style => :compressed)
1553
+ foo{color:blue;/* foo */
1554
+ /* bar */
1555
+ /* */
1556
+ /* bip */
1557
+ /* baz */}
1558
+ CSS
1559
+ foo
1560
+ color: blue
1561
+ //! foo
1562
+ //! bar
1563
+ //!
1564
+ bip
1565
+ baz
1566
+ SASS
1567
+ end
1568
+
1569
+ def test_loud_comment_is_evaluated
1570
+ assert_equal <<CSS, render(<<SASS)
1571
+ /*
1572
+ * Hue: 327.216deg */
1573
+ CSS
1574
+ /*!
1575
+ Hue: \#{hue(#f836a0)}
1576
+ SASS
1577
+ end
1578
+
1576
1579
  def test_attribute_selector_with_spaces
1577
1580
  assert_equal(<<CSS, render(<<SASS))
1578
1581
  a b[foo=bar] {
@@ -1777,232 +1780,230 @@ CSS
1777
1780
  SASS
1778
1781
  end
1779
1782
 
1780
- # Deprecated equals behavior
1781
-
1782
- def test_equals_properties_unquote_strings
1783
- silence_warnings do
1784
- assert_equal(<<CSS, render(<<SASS))
1785
- foo {
1786
- a: foo;
1787
- b: bar;
1788
- c: foo bar;
1789
- d: foo, bar baz;
1790
- e: foo bar, bar; }
1791
- CSS
1792
- foo
1793
- a= "foo"
1794
- b= bar
1795
- c= "foo" bar
1796
- d= foo, "bar baz"
1797
- e= "foo bar", bar
1798
- SASS
1799
- end
1800
- end
1783
+ def test_warn_directive
1784
+ expected_warning = <<EXPECTATION
1785
+ WARNING: this is a warning
1786
+ on line 4 of test_warn_directive_inline.sass
1801
1787
 
1802
- def test_equals_properties_unquote_value
1803
- silence_warnings do
1804
- assert_equal(<<CSS, render(<<SASS))
1805
- foo {
1806
- a: foo; }
1788
+ WARNING: this is a mixin warning
1789
+ on line 2 of test_warn_directive_inline.sass, in `foo'
1790
+ from line 7 of test_warn_directive_inline.sass
1791
+ EXPECTATION
1792
+ assert_warning expected_warning do
1793
+ assert_equal <<CSS, render(<<SASS)
1794
+ bar {
1795
+ c: d; }
1807
1796
  CSS
1808
- $var: "foo"
1797
+ =foo
1798
+ @warn "this is a mixin warning"
1809
1799
 
1810
- foo
1811
- a= $var
1800
+ @warn "this is a warning"
1801
+ bar
1802
+ c: d
1803
+ +foo
1812
1804
  SASS
1813
1805
  end
1814
1806
  end
1815
1807
 
1816
- def test_equals_properties_deep_unquote_vars
1817
- silence_warnings do
1818
- assert_equal(<<CSS, render(<<SASS))
1819
- foo {
1820
- a: foo bar;
1821
- b: bar foo; }
1808
+ def test_warn_directive_when_quiet
1809
+ assert_warning "" do
1810
+ assert_equal <<CSS, render(<<SASS, :quiet => true)
1822
1811
  CSS
1823
- $var: "foo"
1824
-
1825
- foo
1826
- a= $var "bar"
1827
- b= "bar" $var
1812
+ @warn "this is a warning"
1828
1813
  SASS
1829
1814
  end
1830
1815
  end
1831
1816
 
1832
- def test_equals_vars_unquote_strings
1833
- silence_warnings do
1834
- assert_equal(<<CSS, render(<<SASS))
1835
- foo {
1836
- a: foo;
1837
- b: bar;
1838
- c: foo bar;
1839
- d: foo, bar; }
1840
- CSS
1841
- $a = "foo"
1842
- $b = bar
1843
- $c = "foo" bar
1844
- $d = foo, "bar"
1845
-
1846
- foo
1847
- a: $a
1848
- b: $b
1849
- c: $c
1850
- d: $d
1851
- SASS
1852
- end
1853
- end
1817
+ def test_warn_with_imports
1818
+ expected_warning = <<WARN
1819
+ WARNING: In the main file
1820
+ on line 1 of #{File.dirname(__FILE__)}/templates/warn.sass
1854
1821
 
1855
- def test_equals_vars_unquote_value
1856
- silence_warnings do
1857
- assert_equal(<<CSS, render(<<SASS))
1858
- foo {
1859
- a: foo; }
1860
- CSS
1861
- $var1: "foo"
1862
- $var2 = $var1
1822
+ WARNING: Imported
1823
+ on line 1 of #{File.dirname(__FILE__)}/templates/warn_imported.sass
1824
+ from line 2 of #{File.dirname(__FILE__)}/templates/warn.sass
1863
1825
 
1864
- foo
1865
- a: $var2
1866
- SASS
1826
+ WARNING: In an imported mixin
1827
+ on line 4 of #{File.dirname(__FILE__)}/templates/warn_imported.sass, in `emits-a-warning'
1828
+ from line 3 of #{File.dirname(__FILE__)}/templates/warn.sass
1829
+ WARN
1830
+ assert_warning expected_warning do
1831
+ renders_correctly "warn", :style => :compact, :load_paths => [File.dirname(__FILE__) + "/templates"]
1867
1832
  end
1868
1833
  end
1869
1834
 
1870
- def test_equals_vars_deep_unquote_vars
1871
- silence_warnings do
1872
- assert_equal(<<CSS, render(<<SASS))
1873
- foo {
1874
- a: foo bar;
1875
- b: bar foo; }
1876
- CSS
1877
- $var: "foo"
1878
- $a = $var "bar"
1879
- $b = "bar" $var
1835
+ def test_media_bubbling
1836
+ assert_equal <<CSS, render(<<SASS)
1837
+ .foo {
1838
+ a: b; }
1839
+ @media bar {
1840
+ .foo {
1841
+ c: d; } }
1842
+ .foo .baz {
1843
+ e: f; }
1844
+ @media bip {
1845
+ .foo .baz {
1846
+ g: h; } }
1880
1847
 
1881
- foo
1882
- a: $a
1883
- b: $b
1848
+ .other {
1849
+ i: j; }
1850
+ CSS
1851
+ .foo
1852
+ a: b
1853
+ @media bar
1854
+ c: d
1855
+ .baz
1856
+ e: f
1857
+ @media bip
1858
+ g: h
1859
+
1860
+ .other
1861
+ i: j
1884
1862
  SASS
1885
- end
1886
- end
1887
1863
 
1888
- def test_equals_args_unquote_strings
1889
- silence_warnings do
1890
- assert_equal(<<CSS, render(<<SASS))
1891
- foo {
1892
- a: foo;
1893
- b: bar;
1894
- c: foo bar;
1895
- d: foo, bar; }
1864
+ assert_equal <<CSS, render(<<SASS, :style => :compact)
1865
+ .foo { a: b; }
1866
+ @media bar { .foo { c: d; } }
1867
+ .foo .baz { e: f; }
1868
+ @media bip { .foo .baz { g: h; } }
1869
+
1870
+ .other { i: j; }
1896
1871
  CSS
1897
- =foo($a = "foo", $b = bar, $c = "foo" bar, $d = (foo, "bar"))
1898
- foo
1899
- a: $a
1900
- b: $b
1901
- c: $c
1902
- d: $d
1872
+ .foo
1873
+ a: b
1874
+ @media bar
1875
+ c: d
1876
+ .baz
1877
+ e: f
1878
+ @media bip
1879
+ g: h
1903
1880
 
1904
- +foo
1881
+ .other
1882
+ i: j
1905
1883
  SASS
1906
- end
1907
- end
1908
1884
 
1909
- def test_equals_args_unquote_value
1910
- silence_warnings do
1911
- assert_equal(<<CSS, render(<<SASS))
1912
- foo {
1913
- a: foo; }
1914
- CSS
1915
- $var1: "foo"
1885
+ assert_equal <<CSS, render(<<SASS, :style => :expanded)
1886
+ .foo {
1887
+ a: b;
1888
+ }
1889
+ @media bar {
1890
+ .foo {
1891
+ c: d;
1892
+ }
1893
+ }
1894
+ .foo .baz {
1895
+ e: f;
1896
+ }
1897
+ @media bip {
1898
+ .foo .baz {
1899
+ g: h;
1900
+ }
1901
+ }
1916
1902
 
1917
- =foo($var2 = $var1)
1918
- foo
1919
- a: $var2
1903
+ .other {
1904
+ i: j;
1905
+ }
1906
+ CSS
1907
+ .foo
1908
+ a: b
1909
+ @media bar
1910
+ c: d
1911
+ .baz
1912
+ e: f
1913
+ @media bip
1914
+ g: h
1920
1915
 
1921
- +foo
1916
+ .other
1917
+ i: j
1922
1918
  SASS
1923
- end
1924
1919
  end
1925
1920
 
1926
- def test_equals_args_deep_unquote_vars
1927
- silence_warnings do
1928
- assert_equal(<<CSS, render(<<SASS))
1929
- foo {
1930
- a: foo bar;
1931
- b: bar foo; }
1921
+ def test_double_media_bubbling
1922
+ assert_equal <<CSS, render(<<SASS)
1923
+ @media bar and baz {
1924
+ .foo {
1925
+ c: d; } }
1932
1926
  CSS
1933
- $var: "foo"
1934
- =foo($a = $var "bar", $b = "bar" $var)
1935
- foo
1936
- a: $a
1937
- b: $b
1938
-
1939
- +foo
1927
+ @media bar
1928
+ @media baz
1929
+ .foo
1930
+ c: d
1940
1931
  SASS
1941
- end
1942
- end
1943
1932
 
1944
- def test_equals_properties_force_division
1945
- silence_warnings do
1946
- assert_equal(<<CSS, render(<<SASS))
1947
- foo {
1948
- a: 0.5; }
1933
+ assert_equal <<CSS, render(<<SASS)
1934
+ @media bar {
1935
+ .foo {
1936
+ a: b; } }
1937
+ @media bar and baz {
1938
+ .foo {
1939
+ c: d; } }
1949
1940
  CSS
1950
- foo
1951
- a = 1px/2px
1941
+ .foo
1942
+ @media bar
1943
+ a: b
1944
+ @media baz
1945
+ c: d
1952
1946
  SASS
1953
- end
1954
1947
  end
1955
1948
 
1956
- def test_warn_directive
1957
- expected_warning = <<EXPECTATION
1958
- WARNING: this is a warning
1959
- on line 4 of test_warn_directive_inline.sass
1960
-
1961
- WARNING: this is a mixin warning
1962
- on line 2 of test_warn_directive_inline.sass, in `foo'
1963
- from line 7 of test_warn_directive_inline.sass
1964
- EXPECTATION
1965
- assert_warning expected_warning do
1966
- assert_equal <<CSS, render(<<SASS)
1967
- bar {
1968
- c: d; }
1949
+ def test_rule_media_rule_bubbling
1950
+ assert_equal <<CSS, render(<<SASS)
1951
+ @media bar {
1952
+ .foo {
1953
+ a: b;
1954
+ e: f; }
1955
+ .foo .baz {
1956
+ c: d; } }
1969
1957
  CSS
1970
- =foo
1971
- @warn "this is a mixin warning"
1972
-
1973
- @warn "this is a warning"
1974
- bar
1975
- c: d
1976
- +foo
1958
+ .foo
1959
+ @media bar
1960
+ a: b
1961
+ .baz
1962
+ c: d
1963
+ e: f
1977
1964
  SASS
1978
- end
1979
1965
  end
1980
1966
 
1981
- def test_warn_directive_when_quiet
1982
- assert_warning "" do
1983
- assert_equal <<CSS, render(<<SASS, :quiet => true)
1967
+ def test_nested_media_around_properties
1968
+ assert_equal <<CSS, render(<<SASS)
1969
+ .outside {
1970
+ color: red;
1971
+ background: blue; }
1972
+ @media print {
1973
+ .outside {
1974
+ color: black; } }
1975
+ @media print and nested {
1976
+ .outside .inside {
1977
+ border: 1px solid black; } }
1978
+ .outside .middle {
1979
+ display: block; }
1984
1980
  CSS
1985
- @warn "this is a warning"
1981
+ .outside
1982
+ color: red
1983
+ @media print
1984
+ color: black
1985
+ .inside
1986
+ @media nested
1987
+ border: 1px solid black
1988
+ background: blue
1989
+ .middle
1990
+ display: block
1986
1991
  SASS
1987
- end
1988
1992
  end
1989
1993
 
1990
- def test_warn_with_imports
1991
- expected_warning = <<WARN
1992
- WARNING: In the main file
1993
- on line 1 of #{File.dirname(__FILE__)}/templates/warn.sass
1994
-
1995
- WARNING: Imported
1996
- on line 1 of #{File.dirname(__FILE__)}/templates/warn_imported.sass
1997
- from line 2 of #{File.dirname(__FILE__)}/templates/warn.sass
1998
-
1999
- WARNING: In an imported mixin
2000
- on line 4 of #{File.dirname(__FILE__)}/templates/warn_imported.sass, in `emits-a-warning'
2001
- from line 3 of #{File.dirname(__FILE__)}/templates/warn.sass
2002
- WARN
2003
- assert_warning expected_warning do
2004
- renders_correctly "warn", :style => :compact, :load_paths => [File.dirname(__FILE__) + "/templates"]
2005
- end
1994
+ def test_media_with_parent_references
1995
+ sass_str = <<SASS
1996
+ .outside
1997
+ @media print
1998
+ &.inside
1999
+ border: 1px solid black
2000
+ SASS
2001
+ css_str = <<CSS
2002
+ @media print {
2003
+ .outside.inside {
2004
+ border: 1px solid black; } }
2005
+ CSS
2006
+ assert_equal css_str, render(sass_str)
2006
2007
  end
2007
2008
 
2008
2009
  # Regression tests
@@ -2163,6 +2164,23 @@ CSS
2163
2164
  SASS
2164
2165
  end
2165
2166
 
2167
+ def test_mixin_with_keyword_arg_variable_value
2168
+ assert_equal <<CSS, render(<<SASS)
2169
+ .mixed {
2170
+ required: foo;
2171
+ arg1: default-val1;
2172
+ arg2: a-value; }
2173
+ CSS
2174
+ =a-mixin($required, $arg1: default-val1, $arg2: default-val2)
2175
+ required: $required
2176
+ arg1: $arg1
2177
+ arg2: $arg2
2178
+ .mixed
2179
+ $a-value: a-value
2180
+ +a-mixin(foo, $arg2: $a-value)
2181
+ SASS
2182
+ end
2183
+
2166
2184
  def test_mixin_keyword_args_handle_variable_underscore_dash_equivalence
2167
2185
  assert_equal <<CSS, render(<<SASS)
2168
2186
  .mixed {
@@ -2243,180 +2261,38 @@ foo
2243
2261
  SASS
2244
2262
  end
2245
2263
 
2246
- def test_media_bubbling
2264
+ def test_unknown_directive
2247
2265
  assert_equal <<CSS, render(<<SASS)
2248
- .foo {
2249
- a: b; }
2250
- @media bar {
2251
- .foo {
2252
- c: d; } }
2253
- .foo .baz {
2254
- e: f; }
2255
- @media bip {
2256
- .foo .baz {
2257
- g: h; } }
2258
-
2259
- .other {
2260
- i: j; }
2261
- CSS
2262
- .foo
2263
- a: b
2264
- @media bar
2265
- c: d
2266
- .baz
2267
- e: f
2268
- @media bip
2269
- g: h
2270
-
2271
- .other
2272
- i: j
2273
- SASS
2274
-
2275
- assert_equal <<CSS, render(<<SASS, :style => :compact)
2276
- .foo { a: b; }
2277
- @media bar { .foo { c: d; } }
2278
- .foo .baz { e: f; }
2279
- @media bip { .foo .baz { g: h; } }
2280
-
2281
- .other { i: j; }
2282
- CSS
2283
- .foo
2284
- a: b
2285
- @media bar
2286
- c: d
2287
- .baz
2288
- e: f
2289
- @media bip
2290
- g: h
2291
-
2292
- .other
2293
- i: j
2294
- SASS
2295
-
2296
- assert_equal <<CSS, render(<<SASS, :style => :expanded)
2297
- .foo {
2298
- a: b;
2299
- }
2300
- @media bar {
2301
- .foo {
2302
- c: d;
2303
- }
2304
- }
2305
- .foo .baz {
2306
- e: f;
2307
- }
2308
- @media bip {
2309
- .foo .baz {
2310
- g: h;
2311
- }
2312
- }
2313
-
2314
- .other {
2315
- i: j;
2316
- }
2266
+ @baz {
2267
+ c: d; }
2317
2268
  CSS
2318
- .foo
2319
- a: b
2320
- @media bar
2321
- c: d
2322
- .baz
2323
- e: f
2324
- @media bip
2325
- g: h
2326
-
2327
- .other
2328
- i: j
2269
+ @baz
2270
+ c: d
2329
2271
  SASS
2330
2272
  end
2331
2273
 
2332
- def test_double_media_bubbling
2333
- assert_equal <<CSS, render(<<SASS)
2334
- @media bar and baz {
2335
- .foo {
2336
- c: d; } }
2337
- CSS
2338
- @media bar
2339
- @media baz
2340
- .foo
2341
- c: d
2342
- SASS
2343
-
2344
- assert_equal <<CSS, render(<<SASS)
2345
- @media bar {
2346
- .foo {
2347
- a: b; } }
2348
- @media bar and baz {
2349
- .foo {
2350
- c: d; } }
2351
- CSS
2352
- .foo
2353
- @media bar
2354
- a: b
2355
- @media baz
2356
- c: d
2357
- SASS
2274
+ def test_comment_interpolation_warning
2275
+ assert_warning(<<END) {render("/* \#{foo}")}
2276
+ WARNING:
2277
+ On line 1 of 'test_comment_interpolation_warning_inline.sass'
2278
+ Comments will evaluate the contents of interpolations (\#{ ... }) in Sass 3.2.
2279
+ Please escape the interpolation by adding a backslash before the hash sign.
2280
+ END
2358
2281
  end
2359
2282
 
2360
- def test_rule_media_rule_bubbling
2283
+ def test_loud_comment_interpolations_can_be_escaped
2361
2284
  assert_equal <<CSS, render(<<SASS)
2362
- @media bar {
2363
- .foo {
2364
- a: b;
2365
- e: f; }
2366
- .foo .baz {
2367
- c: d; } }
2285
+ /* \#{foo} */
2368
2286
  CSS
2369
- .foo
2370
- @media bar
2371
- a: b
2372
- .baz
2373
- c: d
2374
- e: f
2287
+ /* \\\#{foo}
2375
2288
  SASS
2376
- end
2377
-
2378
- def test_nested_media_around_properties
2379
2289
  assert_equal <<CSS, render(<<SASS)
2380
- .outside {
2381
- color: red;
2382
- background: blue; }
2383
- @media print {
2384
- .outside {
2385
- color: black; } }
2386
- @media print and nested {
2387
- .outside .inside {
2388
- border: 1px solid black; } }
2389
- .outside .middle {
2390
- display: block; }
2290
+ /* \#{foo} */
2391
2291
  CSS
2392
- .outside
2393
- color: red
2394
- @media print
2395
- color: black
2396
- .inside
2397
- @media nested
2398
- border: 1px solid black
2399
- background: blue
2400
- .middle
2401
- display: block
2292
+ /*! \\\#{foo}
2402
2293
  SASS
2403
2294
  end
2404
2295
 
2405
- def test_media_with_parent_references
2406
- sass_str = <<SASS
2407
- .outside
2408
- @media print
2409
- &.inside
2410
- border: 1px solid black
2411
- SASS
2412
- css_str = <<CSS
2413
- @media print {
2414
- .outside.inside {
2415
- border: 1px solid black; } }
2416
- CSS
2417
- assert_equal css_str, render(sass_str)
2418
- end
2419
-
2420
2296
  # Encodings
2421
2297
 
2422
2298
  unless Sass::Util.ruby1_8?