haml 3.0.25 → 3.1.0.alpha.2

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 (212) hide show
  1. data/.yardopts +1 -1
  2. data/CONTRIBUTING +0 -1
  3. data/EDGE_GEM_VERSION +1 -0
  4. data/MIT-LICENSE +1 -1
  5. data/README.md +10 -175
  6. data/Rakefile +56 -84
  7. data/VERSION +1 -1
  8. data/VERSION_NAME +1 -1
  9. data/init.rb +1 -1
  10. data/lib/haml.rb +14 -12
  11. data/lib/haml/engine.rb +1 -1
  12. data/lib/haml/exec.rb +19 -316
  13. data/lib/haml/helpers/action_view_extensions.rb +1 -1
  14. data/lib/haml/html.rb +69 -76
  15. data/lib/haml/precompiler.rb +34 -41
  16. data/lib/haml/railtie.rb +4 -6
  17. data/lib/haml/template/plugin.rb +6 -16
  18. data/lib/haml/util.rb +91 -107
  19. data/lib/haml/version.rb +7 -0
  20. data/test/benchmark.rb +2 -9
  21. data/test/haml/engine_test.rb +195 -92
  22. data/test/haml/html2haml/erb_tests.rb +0 -14
  23. data/test/haml/util_test.rb +32 -0
  24. data/test/test_helper.rb +0 -39
  25. metadata +96 -324
  26. data/bin/css2sass +0 -13
  27. data/bin/sass +0 -8
  28. data/bin/sass-convert +0 -7
  29. data/extra/haml-mode.el +0 -753
  30. data/extra/sass-mode.el +0 -207
  31. data/lib/haml/util/subset_map.rb +0 -101
  32. data/lib/sass.rb +0 -29
  33. data/lib/sass/callbacks.rb +0 -52
  34. data/lib/sass/css.rb +0 -294
  35. data/lib/sass/engine.rb +0 -720
  36. data/lib/sass/environment.rb +0 -143
  37. data/lib/sass/error.rb +0 -198
  38. data/lib/sass/files.rb +0 -160
  39. data/lib/sass/less.rb +0 -382
  40. data/lib/sass/plugin.rb +0 -279
  41. data/lib/sass/plugin/configuration.rb +0 -221
  42. data/lib/sass/plugin/generic.rb +0 -15
  43. data/lib/sass/plugin/merb.rb +0 -37
  44. data/lib/sass/plugin/rack.rb +0 -47
  45. data/lib/sass/plugin/rails.rb +0 -32
  46. data/lib/sass/plugin/staleness_checker.rb +0 -123
  47. data/lib/sass/repl.rb +0 -58
  48. data/lib/sass/script.rb +0 -63
  49. data/lib/sass/script/bool.rb +0 -18
  50. data/lib/sass/script/color.rb +0 -491
  51. data/lib/sass/script/css_lexer.rb +0 -29
  52. data/lib/sass/script/css_parser.rb +0 -31
  53. data/lib/sass/script/funcall.rb +0 -77
  54. data/lib/sass/script/functions.rb +0 -861
  55. data/lib/sass/script/interpolation.rb +0 -70
  56. data/lib/sass/script/lexer.rb +0 -337
  57. data/lib/sass/script/literal.rb +0 -236
  58. data/lib/sass/script/node.rb +0 -112
  59. data/lib/sass/script/number.rb +0 -423
  60. data/lib/sass/script/operation.rb +0 -95
  61. data/lib/sass/script/parser.rb +0 -401
  62. data/lib/sass/script/string.rb +0 -67
  63. data/lib/sass/script/string_interpolation.rb +0 -93
  64. data/lib/sass/script/unary_operation.rb +0 -57
  65. data/lib/sass/script/variable.rb +0 -48
  66. data/lib/sass/scss.rb +0 -17
  67. data/lib/sass/scss/css_parser.rb +0 -46
  68. data/lib/sass/scss/parser.rb +0 -855
  69. data/lib/sass/scss/rx.rb +0 -126
  70. data/lib/sass/scss/sass_parser.rb +0 -11
  71. data/lib/sass/scss/script_lexer.rb +0 -15
  72. data/lib/sass/scss/script_parser.rb +0 -25
  73. data/lib/sass/scss/static_parser.rb +0 -40
  74. data/lib/sass/selector.rb +0 -361
  75. data/lib/sass/selector/abstract_sequence.rb +0 -62
  76. data/lib/sass/selector/comma_sequence.rb +0 -82
  77. data/lib/sass/selector/sequence.rb +0 -237
  78. data/lib/sass/selector/simple.rb +0 -113
  79. data/lib/sass/selector/simple_sequence.rb +0 -136
  80. data/lib/sass/tree/charset_node.rb +0 -37
  81. data/lib/sass/tree/comment_node.rb +0 -128
  82. data/lib/sass/tree/debug_node.rb +0 -36
  83. data/lib/sass/tree/directive_node.rb +0 -75
  84. data/lib/sass/tree/extend_node.rb +0 -65
  85. data/lib/sass/tree/for_node.rb +0 -55
  86. data/lib/sass/tree/if_node.rb +0 -69
  87. data/lib/sass/tree/import_node.rb +0 -102
  88. data/lib/sass/tree/mixin_def_node.rb +0 -48
  89. data/lib/sass/tree/mixin_node.rb +0 -111
  90. data/lib/sass/tree/node.rb +0 -464
  91. data/lib/sass/tree/prop_node.rb +0 -220
  92. data/lib/sass/tree/root_node.rb +0 -163
  93. data/lib/sass/tree/rule_node.rb +0 -261
  94. data/lib/sass/tree/variable_node.rb +0 -39
  95. data/lib/sass/tree/warn_node.rb +0 -42
  96. data/lib/sass/tree/while_node.rb +0 -36
  97. data/test/haml/util/subset_map_test.rb +0 -91
  98. data/test/sass/callbacks_test.rb +0 -61
  99. data/test/sass/conversion_test.rb +0 -1218
  100. data/test/sass/css2sass_test.rb +0 -364
  101. data/test/sass/data/hsl-rgb.txt +0 -319
  102. data/test/sass/engine_test.rb +0 -2267
  103. data/test/sass/extend_test.rb +0 -1348
  104. data/test/sass/functions_test.rb +0 -556
  105. data/test/sass/less_conversion_test.rb +0 -653
  106. data/test/sass/more_results/more1.css +0 -9
  107. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  108. data/test/sass/more_results/more_import.css +0 -29
  109. data/test/sass/more_templates/_more_partial.sass +0 -2
  110. data/test/sass/more_templates/more1.sass +0 -23
  111. data/test/sass/more_templates/more_import.sass +0 -11
  112. data/test/sass/plugin_test.rb +0 -433
  113. data/test/sass/results/alt.css +0 -4
  114. data/test/sass/results/basic.css +0 -9
  115. data/test/sass/results/compact.css +0 -5
  116. data/test/sass/results/complex.css +0 -86
  117. data/test/sass/results/compressed.css +0 -1
  118. data/test/sass/results/expanded.css +0 -19
  119. data/test/sass/results/import.css +0 -31
  120. data/test/sass/results/import_charset.css +0 -4
  121. data/test/sass/results/import_charset_1_8.css +0 -4
  122. data/test/sass/results/import_charset_ibm866.css +0 -4
  123. data/test/sass/results/line_numbers.css +0 -49
  124. data/test/sass/results/mixins.css +0 -95
  125. data/test/sass/results/multiline.css +0 -24
  126. data/test/sass/results/nested.css +0 -22
  127. data/test/sass/results/options.css +0 -1
  128. data/test/sass/results/parent_ref.css +0 -13
  129. data/test/sass/results/script.css +0 -16
  130. data/test/sass/results/scss_import.css +0 -31
  131. data/test/sass/results/scss_importee.css +0 -2
  132. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  133. data/test/sass/results/subdir/subdir.css +0 -3
  134. data/test/sass/results/units.css +0 -11
  135. data/test/sass/results/warn.css +0 -0
  136. data/test/sass/results/warn_imported.css +0 -0
  137. data/test/sass/script_conversion_test.rb +0 -314
  138. data/test/sass/script_test.rb +0 -470
  139. data/test/sass/scss/css_test.rb +0 -916
  140. data/test/sass/scss/rx_test.rb +0 -156
  141. data/test/sass/scss/scss_test.rb +0 -1122
  142. data/test/sass/scss/test_helper.rb +0 -37
  143. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  144. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  145. data/test/sass/templates/_partial.sass +0 -2
  146. data/test/sass/templates/alt.sass +0 -16
  147. data/test/sass/templates/basic.sass +0 -23
  148. data/test/sass/templates/bork1.sass +0 -2
  149. data/test/sass/templates/bork2.sass +0 -2
  150. data/test/sass/templates/bork3.sass +0 -2
  151. data/test/sass/templates/bork4.sass +0 -2
  152. data/test/sass/templates/compact.sass +0 -17
  153. data/test/sass/templates/complex.sass +0 -305
  154. data/test/sass/templates/compressed.sass +0 -15
  155. data/test/sass/templates/expanded.sass +0 -17
  156. data/test/sass/templates/import.sass +0 -12
  157. data/test/sass/templates/import_charset.sass +0 -7
  158. data/test/sass/templates/import_charset_1_8.sass +0 -4
  159. data/test/sass/templates/import_charset_ibm866.sass +0 -9
  160. data/test/sass/templates/importee.less +0 -2
  161. data/test/sass/templates/importee.sass +0 -19
  162. data/test/sass/templates/line_numbers.sass +0 -13
  163. data/test/sass/templates/mixin_bork.sass +0 -5
  164. data/test/sass/templates/mixins.sass +0 -76
  165. data/test/sass/templates/multiline.sass +0 -20
  166. data/test/sass/templates/nested.sass +0 -25
  167. data/test/sass/templates/nested_bork1.sass +0 -2
  168. data/test/sass/templates/nested_bork2.sass +0 -2
  169. data/test/sass/templates/nested_bork3.sass +0 -2
  170. data/test/sass/templates/nested_bork4.sass +0 -2
  171. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  172. data/test/sass/templates/options.sass +0 -2
  173. data/test/sass/templates/parent_ref.sass +0 -25
  174. data/test/sass/templates/script.sass +0 -101
  175. data/test/sass/templates/scss_import.scss +0 -11
  176. data/test/sass/templates/scss_importee.scss +0 -1
  177. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  178. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  179. data/test/sass/templates/subdir/subdir.sass +0 -6
  180. data/test/sass/templates/units.sass +0 -11
  181. data/test/sass/templates/warn.sass +0 -3
  182. data/test/sass/templates/warn_imported.sass +0 -4
  183. data/vendor/fssm/LICENSE +0 -20
  184. data/vendor/fssm/README.markdown +0 -55
  185. data/vendor/fssm/Rakefile +0 -59
  186. data/vendor/fssm/VERSION.yml +0 -5
  187. data/vendor/fssm/example.rb +0 -9
  188. data/vendor/fssm/fssm.gemspec +0 -77
  189. data/vendor/fssm/lib/fssm.rb +0 -33
  190. data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
  191. data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
  192. data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
  193. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
  194. data/vendor/fssm/lib/fssm/monitor.rb +0 -26
  195. data/vendor/fssm/lib/fssm/path.rb +0 -91
  196. data/vendor/fssm/lib/fssm/pathname.rb +0 -502
  197. data/vendor/fssm/lib/fssm/state/directory.rb +0 -57
  198. data/vendor/fssm/lib/fssm/state/file.rb +0 -24
  199. data/vendor/fssm/lib/fssm/support.rb +0 -63
  200. data/vendor/fssm/lib/fssm/tree.rb +0 -176
  201. data/vendor/fssm/profile/prof-cache.rb +0 -40
  202. data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
  203. data/vendor/fssm/profile/prof-pathname.rb +0 -68
  204. data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
  205. data/vendor/fssm/profile/prof.html +0 -2379
  206. data/vendor/fssm/spec/path_spec.rb +0 -75
  207. data/vendor/fssm/spec/root/duck/quack.txt +0 -0
  208. data/vendor/fssm/spec/root/file.css +0 -0
  209. data/vendor/fssm/spec/root/file.rb +0 -0
  210. data/vendor/fssm/spec/root/file.yml +0 -0
  211. data/vendor/fssm/spec/root/moo/cow.txt +0 -0
  212. data/vendor/fssm/spec/spec_helper.rb +0 -14
@@ -1,156 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
- require File.dirname(__FILE__) + '/../../test_helper'
4
- require 'sass/engine'
5
-
6
- class ScssRxTest < Test::Unit::TestCase
7
- include Sass::SCSS::RX
8
-
9
- def test_identifiers
10
- assert_match IDENT, "foo"
11
- assert_match IDENT, "\xC3\xBFoo" # Initial char can be nonascii
12
- assert_match IDENT, "\\123abcoo" # Initial char can be unicode escape
13
- assert_match IDENT, "\\f oo" # Unicode escapes can be followed by whitespace
14
- assert_match IDENT, "\\fa\too"
15
- assert_match IDENT, "\\ff2\roo"
16
- assert_match IDENT, "\\f13a\foo"
17
- assert_match IDENT, "\\f13abcoo"
18
- assert_match IDENT, "\\ oo" # Initial char can be a plain escape as well
19
- assert_match IDENT, "\\~oo"
20
- assert_match IDENT, "\\\\oo"
21
- assert_match IDENT, "\\{oo"
22
- assert_match IDENT, "\\\xC3\xBFoo"
23
- assert_match IDENT, "-foo" # Can put a - before anything
24
- assert_match IDENT, "-\xC3\xBFoo"
25
- assert_match IDENT, "-\\f oo"
26
- assert_match IDENT, "_foo" # Can put a _ before anything
27
- assert_match IDENT, "_\xC3\xBFoo"
28
- assert_match IDENT, "_\\f oo"
29
-
30
- assert_match IDENT, "foo-bar"
31
- assert_match IDENT, "f012-23"
32
- assert_match IDENT, "foo_-_bar"
33
- assert_match IDENT, "f012_23"
34
-
35
- # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/escapes-003.xht
36
- assert_match IDENT, "c\\lass"
37
- # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/escapes-004.xht
38
- assert_match IDENT, "c\\00006Cas\\000073"
39
- # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-001.xht
40
- assert_match IDENT, "IdE6n-3t0_6"
41
- # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-006.xht
42
- assert_match IDENT, "\\6000ident"
43
- # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-007.xht
44
- assert_match IDENT, "iden\\6000t\\6000"
45
- # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/ident-013.xht
46
- assert_match IDENT, "\\-ident"
47
- end
48
-
49
- def test_underscores_in_identifiers
50
- assert_match IDENT, "foo_bar"
51
- assert_match IDENT, "_\xC3\xBFfoo"
52
- assert_match IDENT, "__foo"
53
- assert_match IDENT, "_1foo"
54
- assert_match IDENT, "-_foo"
55
- assert_match IDENT, "_-foo"
56
- end
57
-
58
- def test_invalid_identifiers
59
- assert_no_match IDENT, ""
60
- assert_no_match IDENT, "1foo"
61
- assert_no_match IDENT, "-1foo"
62
- assert_no_match IDENT, "--foo"
63
- assert_no_match IDENT, "foo bar"
64
- assert_no_match IDENT, "foo~bar"
65
-
66
- # http://www.w3.org/Style/CSS/Test/CSS2.1/current/xhtml1/escapes-008.xht
67
- assert_no_match IDENT, "c\\06C ass"
68
- assert_no_match IDENT, "back\\67\n round"
69
- end
70
-
71
- def test_double_quote_strings
72
- assert_match STRING, '"foo bar"'
73
- assert_match STRING, '"foo\\\nbar"'
74
- assert_match STRING, "\"\\\"\""
75
- assert_match STRING, '"\t !#$%&(-~()*+,-./0123456789~"'
76
- end
77
-
78
- def test_single_quote_strings
79
- assert_match STRING, "'foo bar'"
80
- assert_match STRING, "'foo\\\nbar'"
81
- assert_match STRING, "'\\''"
82
- assert_match STRING, "'\t !#\$%&(-~()*+,-./0123456789~'"
83
- end
84
-
85
- def test_invalid_strings
86
- assert_no_match STRING, "\"foo\nbar\""
87
- assert_no_match STRING, "\"foo\"bar\""
88
- assert_no_match STRING, "'foo\nbar'"
89
- assert_no_match STRING, "'foo'bar'"
90
- end
91
-
92
- def test_uri
93
- assert_match URI, 'url("foo bar)")'
94
- assert_match URI, "url('foo bar)')"
95
- assert_match URI, 'url( "foo bar)" )'
96
- assert_match URI, "url(#\\%&**+,-./0123456789~)"
97
- end
98
-
99
- def test_invalid_uri
100
- assert_no_match URI, 'url(foo)bar)'
101
- end
102
-
103
- def test_unicode_range
104
- assert_match UNICODERANGE, 'U+00-Ff'
105
- assert_match UNICODERANGE, 'u+980-9FF'
106
- assert_match UNICODERANGE, 'U+9aF??'
107
- assert_match UNICODERANGE, 'U+??'
108
- end
109
-
110
- def test_escape_empty_ident
111
- assert_equal "", Sass::SCSS::RX.escape_ident("")
112
- end
113
-
114
- def test_escape_just_prefix_ident
115
- assert_equal "\\-", Sass::SCSS::RX.escape_ident("-")
116
- assert_equal "\\_", Sass::SCSS::RX.escape_ident("_")
117
- end
118
-
119
- def test_escape_plain_ident
120
- assert_equal "foo", Sass::SCSS::RX.escape_ident("foo")
121
- assert_equal "foo-1bar", Sass::SCSS::RX.escape_ident("foo-1bar")
122
- assert_equal "-foo-bar", Sass::SCSS::RX.escape_ident("-foo-bar")
123
- assert_equal "f2oo_bar", Sass::SCSS::RX.escape_ident("f2oo_bar")
124
- assert_equal "_foo_bar", Sass::SCSS::RX.escape_ident("_foo_bar")
125
- end
126
-
127
- def test_escape_initial_funky_ident
128
- assert_equal "\\000035foo", Sass::SCSS::RX.escape_ident("5foo")
129
- assert_equal "-\\000035foo", Sass::SCSS::RX.escape_ident("-5foo")
130
- assert_equal "_\\000035foo", Sass::SCSS::RX.escape_ident("_5foo")
131
-
132
- assert_equal "\\&foo", Sass::SCSS::RX.escape_ident("&foo")
133
- assert_equal "-\\&foo", Sass::SCSS::RX.escape_ident("-&foo")
134
-
135
- assert_equal "-\\ foo", Sass::SCSS::RX.escape_ident("- foo")
136
- end
137
-
138
- def test_escape_mid_funky_ident
139
- assert_equal "foo\\&bar", Sass::SCSS::RX.escape_ident("foo&bar")
140
- assert_equal "foo\\ \\ bar", Sass::SCSS::RX.escape_ident("foo bar")
141
- assert_equal "foo\\00007fbar", Sass::SCSS::RX.escape_ident("foo\177bar")
142
- end
143
-
144
- private
145
-
146
- def assert_match(rx, str)
147
- assert_not_nil(match = rx.match(str))
148
- assert_equal str.size, match[0].size
149
- end
150
-
151
- def assert_no_match(rx, str)
152
- match = rx.match(str)
153
- assert_not_equal str.size, match && match[0].size
154
- end
155
-
156
- end
@@ -1,1122 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
- require File.dirname(__FILE__) + '/test_helper'
4
-
5
- class ScssTest < Test::Unit::TestCase
6
- include ScssTestHelper
7
-
8
- ## One-Line Comments
9
-
10
- def test_one_line_comments
11
- assert_equal <<CSS, render(<<SCSS)
12
- .foo {
13
- baz: bang; }
14
- CSS
15
- .foo {// bar: baz;}
16
- baz: bang; //}
17
- }
18
- SCSS
19
- assert_equal <<CSS, render(<<SCSS)
20
- .foo bar[val="//"] {
21
- baz: bang; }
22
- CSS
23
- .foo bar[val="//"] {
24
- baz: bang; //}
25
- }
26
- SCSS
27
- end
28
-
29
- ## Script
30
-
31
- def test_variables
32
- assert_equal <<CSS, render(<<SCSS)
33
- blat {
34
- a: foo; }
35
- CSS
36
- $var: foo;
37
-
38
- blat {a: $var}
39
- SCSS
40
-
41
- assert_equal <<CSS, render(<<SCSS)
42
- foo {
43
- a: 2;
44
- b: 6; }
45
- CSS
46
- foo {
47
- $var: 2;
48
- $another-var: 4;
49
- a: $var;
50
- b: $var + $another-var;}
51
- SCSS
52
- end
53
-
54
- def test_unicode_variables
55
- assert_equal <<CSS, render(<<SCSS)
56
- blat {
57
- a: foo; }
58
- CSS
59
- $vär: foo;
60
-
61
- blat {a: $vär}
62
- SCSS
63
- end
64
-
65
- def test_guard_assign
66
- assert_equal <<CSS, render(<<SCSS)
67
- foo {
68
- a: 1; }
69
- CSS
70
- $var: 1;
71
- $var: 2 !default;
72
-
73
- foo {a: $var}
74
- SCSS
75
-
76
- assert_equal <<CSS, render(<<SCSS)
77
- foo {
78
- a: 2; }
79
- CSS
80
- $var: 2 !default;
81
-
82
- foo {a: $var}
83
- SCSS
84
- end
85
-
86
- def test_sass_script
87
- assert_equal <<CSS, render(<<SCSS)
88
- foo {
89
- a: 3;
90
- b: -1;
91
- c: foobar;
92
- d: 12px; }
93
- CSS
94
- foo {
95
- a: 1 + 2;
96
- b: 1 - 2;
97
- c: foo + bar;
98
- d: floor(12.3px); }
99
- SCSS
100
- end
101
-
102
- def test_debug_directive
103
- assert_warning "test_debug_directive_inline.scss:2 DEBUG: hello world!" do
104
- assert_equal <<CSS, render(<<SCSS)
105
- foo {
106
- a: b; }
107
-
108
- bar {
109
- c: d; }
110
- CSS
111
- foo {a: b}
112
- @debug "hello world!";
113
- bar {c: d}
114
- SCSS
115
- end
116
- end
117
-
118
- def test_warn_directive
119
- expected_warning = <<EXPECTATION
120
- WARNING: this is a warning
121
- on line 2 of test_warn_directive_inline.scss
122
-
123
- WARNING: this is a mixin
124
- on line 1 of test_warn_directive_inline.scss, in `foo'
125
- from line 3 of test_warn_directive_inline.scss
126
- EXPECTATION
127
- assert_warning expected_warning do
128
- assert_equal <<CSS, render(<<SCSS)
129
- bar {
130
- c: d; }
131
- CSS
132
- @mixin foo { @warn "this is a mixin";}
133
- @warn "this is a warning";
134
- bar {c: d; @include foo;}
135
- SCSS
136
- end
137
- end
138
-
139
- def test_for_directive
140
- assert_equal <<CSS, render(<<SCSS)
141
- .foo {
142
- a: 1;
143
- a: 2;
144
- a: 3;
145
- a: 4; }
146
- CSS
147
- .foo {
148
- @for $var from 1 to 5 {a: $var;}
149
- }
150
- SCSS
151
-
152
- assert_equal <<CSS, render(<<SCSS)
153
- .foo {
154
- a: 1;
155
- a: 2;
156
- a: 3;
157
- a: 4;
158
- a: 5; }
159
- CSS
160
- .foo {
161
- @for $var from 1 through 5 {a: $var;}
162
- }
163
- SCSS
164
- end
165
-
166
- def test_if_directive
167
- assert_equal <<CSS, render(<<SCSS)
168
- foo {
169
- a: b; }
170
- CSS
171
- @if "foo" == "foo" {foo {a: b}}
172
- @if "foo" != "foo" {bar {a: b}}
173
- SCSS
174
-
175
- assert_equal <<CSS, render(<<SCSS)
176
- bar {
177
- a: b; }
178
- CSS
179
- @if "foo" != "foo" {foo {a: b}}
180
- @else if "foo" == "foo" {bar {a: b}}
181
- @else if true {baz {a: b}}
182
- SCSS
183
-
184
- assert_equal <<CSS, render(<<SCSS)
185
- bar {
186
- a: b; }
187
- CSS
188
- @if "foo" != "foo" {foo {a: b}}
189
- @else {bar {a: b}}
190
- SCSS
191
- end
192
-
193
- def test_comment_after_if_directive
194
- assert_equal <<CSS, render(<<SCSS)
195
- foo {
196
- a: b;
197
- /* This is a comment */
198
- c: d; }
199
- CSS
200
- foo {
201
- @if true {a: b}
202
- /* This is a comment */
203
- c: d }
204
- SCSS
205
- assert_equal <<CSS, render(<<SCSS)
206
- foo {
207
- a: b;
208
- /* This is a comment */
209
- c: d; }
210
- CSS
211
- foo {
212
- @if true {a: b}
213
- @else {x: y}
214
- /* This is a comment */
215
- c: d }
216
- SCSS
217
- end
218
-
219
- def test_while_directive
220
- assert_equal <<CSS, render(<<SCSS)
221
- .foo {
222
- a: 1;
223
- a: 2;
224
- a: 3;
225
- a: 4; }
226
- CSS
227
- $i: 1;
228
-
229
- .foo {
230
- @while $i != 5 {
231
- a: $i;
232
- $i: $i + 1;
233
- }
234
- }
235
- SCSS
236
- end
237
-
238
- def test_css_import_directive
239
- assert_equal "@import url(foo.css);\n", render('@import "foo.css";')
240
- assert_equal "@import url(foo.css);\n", render("@import 'foo.css';")
241
- assert_equal "@import url(\"foo.css\");\n", render('@import url("foo.css");')
242
- assert_equal "@import url('foo.css');\n", render("@import url('foo.css');")
243
- assert_equal "@import url(foo.css);\n", render('@import url(foo.css);')
244
- end
245
-
246
- def test_media_import
247
- assert_equal("@import \"./fonts.sass\" all;\n", render("@import \"./fonts.sass\" all;"))
248
- end
249
-
250
- def test_http_import
251
- assert_equal("@import \"http://fonts.googleapis.com/css?family=Droid+Sans\";\n",
252
- render("@import \"http://fonts.googleapis.com/css?family=Droid+Sans\";"))
253
- end
254
-
255
- def test_url_import
256
- assert_equal("@import url(fonts.sass);\n", render("@import url(fonts.sass);"))
257
- end
258
-
259
- def test_block_comment_in_script
260
- assert_equal <<CSS, render(<<SCSS)
261
- foo {
262
- a: 1bar; }
263
- CSS
264
- foo {a: 1 + /* flang */ bar}
265
- SCSS
266
- end
267
-
268
- def test_line_comment_in_script
269
- assert_equal <<CSS, render(<<SCSS)
270
- foo {
271
- a: 1blang; }
272
- CSS
273
- foo {a: 1 + // flang }
274
- blang }
275
- SCSS
276
- end
277
-
278
- ## Nested Rules
279
-
280
- def test_nested_rules
281
- assert_equal <<CSS, render(<<SCSS)
282
- foo bar {
283
- a: b; }
284
- CSS
285
- foo {bar {a: b}}
286
- SCSS
287
- assert_equal <<CSS, render(<<SCSS)
288
- foo bar {
289
- a: b; }
290
- foo baz {
291
- b: c; }
292
- CSS
293
- foo {
294
- bar {a: b}
295
- baz {b: c}}
296
- SCSS
297
- assert_equal <<CSS, render(<<SCSS)
298
- foo bar baz {
299
- a: b; }
300
- foo bang bip {
301
- a: b; }
302
- CSS
303
- foo {
304
- bar {baz {a: b}}
305
- bang {bip {a: b}}}
306
- SCSS
307
- end
308
-
309
- def test_nested_rules_with_declarations
310
- assert_equal <<CSS, render(<<SCSS)
311
- foo {
312
- a: b; }
313
- foo bar {
314
- c: d; }
315
- CSS
316
- foo {
317
- a: b;
318
- bar {c: d}}
319
- SCSS
320
- assert_equal <<CSS, render(<<SCSS)
321
- foo {
322
- a: b; }
323
- foo bar {
324
- c: d; }
325
- CSS
326
- foo {
327
- bar {c: d}
328
- a: b}
329
- SCSS
330
- assert_equal <<CSS, render(<<SCSS)
331
- foo {
332
- ump: nump;
333
- grump: clump; }
334
- foo bar {
335
- blat: bang;
336
- habit: rabbit; }
337
- foo bar baz {
338
- a: b; }
339
- foo bar bip {
340
- c: d; }
341
- foo bibble bap {
342
- e: f; }
343
- CSS
344
- foo {
345
- ump: nump;
346
- grump: clump;
347
- bar {
348
- blat: bang;
349
- habit: rabbit;
350
- baz {a: b}
351
- bip {c: d}}
352
- bibble {
353
- bap {e: f}}}
354
- SCSS
355
- end
356
-
357
- def test_nested_rules_with_fancy_selectors
358
- assert_equal <<CSS, render(<<SCSS)
359
- foo .bar {
360
- a: b; }
361
- foo :baz {
362
- c: d; }
363
- foo bang:bop {
364
- e: f; }
365
- CSS
366
- foo {
367
- .bar {a: b}
368
- :baz {c: d}
369
- bang:bop {e: f}}
370
- SCSS
371
- end
372
-
373
- def test_almost_ambiguous_nested_rules_and_declarations
374
- assert_equal <<CSS, render(<<SCSS)
375
- foo {
376
- bar: baz bang bop biddle woo look at all these elems; }
377
- foo bar:baz:bang:bop:biddle:woo:look:at:all:these:pseudoclasses {
378
- a: b; }
379
- foo bar:baz bang bop biddle woo look at all these elems {
380
- a: b; }
381
- CSS
382
- foo {
383
- bar:baz:bang:bop:biddle:woo:look:at:all:these:pseudoclasses {a: b};
384
- bar:baz bang bop biddle woo look at all these elems {a: b};
385
- bar:baz bang bop biddle woo look at all these elems; }
386
- SCSS
387
- end
388
-
389
- def test_newlines_in_selectors
390
- assert_equal <<CSS, render(<<SCSS)
391
- foo
392
- bar {
393
- a: b; }
394
- CSS
395
- foo
396
- bar {a: b}
397
- SCSS
398
-
399
- assert_equal <<CSS, render(<<SCSS)
400
- foo baz,
401
- foo bang,
402
- bar baz,
403
- bar bang {
404
- a: b; }
405
- CSS
406
- foo,
407
- bar {
408
- baz,
409
- bang {a: b}}
410
- SCSS
411
-
412
- assert_equal <<CSS, render(<<SCSS)
413
- foo
414
- bar baz
415
- bang {
416
- a: b; }
417
- foo
418
- bar bip bop {
419
- c: d; }
420
- CSS
421
- foo
422
- bar {
423
- baz
424
- bang {a: b}
425
-
426
- bip bop {c: d}}
427
- SCSS
428
-
429
- assert_equal <<CSS, render(<<SCSS)
430
- foo bang, foo bip
431
- bop, bar
432
- baz bang, bar
433
- baz bip
434
- bop {
435
- a: b; }
436
- CSS
437
- foo, bar
438
- baz {
439
- bang, bip
440
- bop {a: b}}
441
- SCSS
442
- end
443
-
444
- def test_parent_selectors
445
- assert_equal <<CSS, render(<<SCSS)
446
- foo:hover {
447
- a: b; }
448
- bar foo.baz {
449
- c: d; }
450
- CSS
451
- foo {
452
- &:hover {a: b}
453
- bar &.baz {c: d}}
454
- SCSS
455
- end
456
-
457
- ## Namespace Properties
458
-
459
- def test_namespace_properties
460
- assert_equal <<CSS, render(<<SCSS)
461
- foo {
462
- bar: baz;
463
- bang-bip: 1px;
464
- bang-bop: bar; }
465
- CSS
466
- foo {
467
- bar: baz;
468
- bang: {
469
- bip: 1px;
470
- bop: bar;}}
471
- SCSS
472
- end
473
-
474
- def test_several_namespace_properties
475
- assert_equal <<CSS, render(<<SCSS)
476
- foo {
477
- bar: baz;
478
- bang-bip: 1px;
479
- bang-bop: bar;
480
- buzz-fram: "foo";
481
- buzz-frum: moo; }
482
- CSS
483
- foo {
484
- bar: baz;
485
- bang: {
486
- bip: 1px;
487
- bop: bar;}
488
- buzz: {
489
- fram: "foo";
490
- frum: moo;
491
- }
492
- }
493
- SCSS
494
- end
495
-
496
- def test_nested_namespace_properties
497
- assert_equal <<CSS, render(<<SCSS)
498
- foo {
499
- bar: baz;
500
- bang-bip: 1px;
501
- bang-bop: bar;
502
- bang-blat-baf: bort; }
503
- CSS
504
- foo {
505
- bar: baz;
506
- bang: {
507
- bip: 1px;
508
- bop: bar;
509
- blat:{baf:bort}}}
510
- SCSS
511
- end
512
-
513
- def test_namespace_properties_with_value
514
- assert_equal <<CSS, render(<<SCSS)
515
- foo {
516
- bar: baz;
517
- bar-bip: bop;
518
- bar-bing: bop; }
519
- CSS
520
- foo {
521
- bar: baz {
522
- bip: bop;
523
- bing: bop; }}
524
- SCSS
525
- end
526
-
527
- def test_namespace_properties_with_script_value
528
- assert_equal <<CSS, render(<<SCSS)
529
- foo {
530
- bar: bazbang;
531
- bar-bip: bop;
532
- bar-bing: bop; }
533
- CSS
534
- foo {
535
- bar: baz + bang {
536
- bip: bop;
537
- bing: bop; }}
538
- SCSS
539
- end
540
-
541
- def test_no_namespace_properties_without_space
542
- assert_equal <<CSS, render(<<SCSS)
543
- foo bar:baz {
544
- bip: bop; }
545
- CSS
546
- foo {
547
- bar:baz {
548
- bip: bop }}
549
- SCSS
550
- end
551
-
552
- def test_no_namespace_properties_without_space_even_when_its_unambiguous
553
- render(<<SCSS)
554
- foo {
555
- bar:1px {
556
- bip: bop }}
557
- SCSS
558
- assert(false, "Expected syntax error")
559
- rescue Sass::SyntaxError => e
560
- assert_equal <<MESSAGE, e.message
561
- Invalid CSS: a space is required between a property and its definition
562
- when it has other properties nested beneath it.
563
- MESSAGE
564
- assert_equal 2, e.sass_line
565
- end
566
-
567
- ## Mixins
568
-
569
- def test_basic_mixins
570
- assert_equal <<CSS, render(<<SCSS)
571
- .foo {
572
- a: b; }
573
- CSS
574
- @mixin foo {
575
- .foo {a: b}}
576
-
577
- @include foo;
578
- SCSS
579
-
580
- assert_equal <<CSS, render(<<SCSS)
581
- bar {
582
- c: d; }
583
- bar .foo {
584
- a: b; }
585
- CSS
586
- @mixin foo {
587
- .foo {a: b}}
588
-
589
- bar {
590
- @include foo;
591
- c: d; }
592
- SCSS
593
-
594
- assert_equal <<CSS, render(<<SCSS)
595
- bar {
596
- a: b;
597
- c: d; }
598
- CSS
599
- @mixin foo {a: b}
600
-
601
- bar {
602
- @include foo;
603
- c: d; }
604
- SCSS
605
- end
606
-
607
- def test_mixins_with_empty_args
608
- assert_equal <<CSS, render(<<SCSS)
609
- .foo {
610
- a: b; }
611
- CSS
612
- @mixin foo() {a: b}
613
-
614
- .foo {@include foo();}
615
- SCSS
616
-
617
- assert_equal <<CSS, render(<<SCSS)
618
- .foo {
619
- a: b; }
620
- CSS
621
- @mixin foo() {a: b}
622
-
623
- .foo {@include foo;}
624
- SCSS
625
-
626
- assert_equal <<CSS, render(<<SCSS)
627
- .foo {
628
- a: b; }
629
- CSS
630
- @mixin foo {a: b}
631
-
632
- .foo {@include foo();}
633
- SCSS
634
- end
635
-
636
- def test_mixins_with_args
637
- assert_equal <<CSS, render(<<SCSS)
638
- .foo {
639
- a: bar; }
640
- CSS
641
- @mixin foo($a) {a: $a}
642
-
643
- .foo {@include foo(bar)}
644
- SCSS
645
-
646
- assert_equal <<CSS, render(<<SCSS)
647
- .foo {
648
- a: bar;
649
- b: 12px; }
650
- CSS
651
- @mixin foo($a, $b) {
652
- a: $a;
653
- b: $b; }
654
-
655
- .foo {@include foo(bar, 12px)}
656
- SCSS
657
- end
658
-
659
- ## Interpolation
660
-
661
- def test_basic_selector_interpolation
662
- assert_equal <<CSS, render(<<SCSS)
663
- foo 3 baz {
664
- a: b; }
665
- CSS
666
- foo \#{1 + 2} baz {a: b}
667
- SCSS
668
- assert_equal <<CSS, render(<<SCSS)
669
- foo.bar baz {
670
- a: b; }
671
- CSS
672
- foo\#{".bar"} baz {a: b}
673
- SCSS
674
- assert_equal <<CSS, render(<<SCSS)
675
- foo.bar baz {
676
- a: b; }
677
- CSS
678
- \#{"foo"}.bar baz {a: b}
679
- SCSS
680
- end
681
-
682
- def test_selector_only_interpolation
683
- assert_equal <<CSS, render(<<SCSS)
684
- foo bar {
685
- a: b; }
686
- CSS
687
- \#{"foo" + " bar"} {a: b}
688
- SCSS
689
- end
690
-
691
- def test_selector_interpolation_before_element_name
692
- assert_equal <<CSS, render(<<SCSS)
693
- foo barbaz {
694
- a: b; }
695
- CSS
696
- \#{"foo" + " bar"}baz {a: b}
697
- SCSS
698
- end
699
-
700
- def test_selector_interpolation_in_string
701
- assert_equal <<CSS, render(<<SCSS)
702
- foo[val="bar foo bar baz"] {
703
- a: b; }
704
- CSS
705
- foo[val="bar \#{"foo" + " bar"} baz"] {a: b}
706
- SCSS
707
- end
708
-
709
- def test_selector_interpolation_in_pseudoclass
710
- assert_equal <<CSS, render(<<SCSS)
711
- foo:nth-child(5n) {
712
- a: b; }
713
- CSS
714
- foo:nth-child(\#{5 + "n"}) {a: b}
715
- SCSS
716
- end
717
-
718
- def test_selector_interpolation_at_class_begininng
719
- assert_equal <<CSS, render(<<SCSS)
720
- .zzz {
721
- a: b; }
722
- CSS
723
- $zzz: zzz;
724
- .\#{$zzz} { a: b; }
725
- SCSS
726
- end
727
-
728
- def test_selector_interpolation_at_id_begininng
729
- assert_equal <<CSS, render(<<SCSS)
730
- #zzz {
731
- a: b; }
732
- CSS
733
- $zzz: zzz;
734
- #\#{$zzz} { a: b; }
735
- SCSS
736
- end
737
-
738
- def test_selector_interpolation_at_pseudo_begininng
739
- assert_equal <<CSS, render(<<SCSS)
740
- :zzz::zzz {
741
- a: b; }
742
- CSS
743
- $zzz: zzz;
744
- :\#{$zzz}::\#{$zzz} { a: b; }
745
- SCSS
746
- end
747
-
748
- def test_selector_interpolation_at_attr_beginning
749
- assert_equal <<CSS, render(<<SCSS)
750
- [zzz=foo] {
751
- a: b; }
752
- CSS
753
- $zzz: zzz;
754
- [\#{$zzz}=foo] { a: b; }
755
- SCSS
756
- end
757
-
758
- def test_selector_interpolation_at_dashes
759
- assert_equal <<CSS, render(<<SCSS)
760
- div {
761
- -foo-a-b-foo: foo; }
762
- CSS
763
- $a : a;
764
- $b : b;
765
- div { -foo-\#{$a}-\#{$b}-foo: foo }
766
- SCSS
767
- end
768
-
769
- def test_basic_prop_name_interpolation
770
- assert_equal <<CSS, render(<<SCSS)
771
- foo {
772
- barbazbang: blip; }
773
- CSS
774
- foo {bar\#{"baz" + "bang"}: blip}
775
- SCSS
776
- assert_equal <<CSS, render(<<SCSS)
777
- foo {
778
- bar3: blip; }
779
- CSS
780
- foo {bar\#{1 + 2}: blip}
781
- SCSS
782
- end
783
-
784
- def test_prop_name_only_interpolation
785
- assert_equal <<CSS, render(<<SCSS)
786
- foo {
787
- bazbang: blip; }
788
- CSS
789
- foo {\#{"baz" + "bang"}: blip}
790
- SCSS
791
- end
792
-
793
- ## Errors
794
-
795
- def test_mixin_defs_only_at_toplevel
796
- render <<SCSS
797
- foo {
798
- @mixin bar {a: b}}
799
- SCSS
800
- assert(false, "Expected syntax error")
801
- rescue Sass::SyntaxError => e
802
- assert_equal "Mixins may only be defined at the root of a document.", e.message
803
- assert_equal 2, e.sass_line
804
- end
805
-
806
- def test_imports_only_at_toplevel
807
- render <<SCSS
808
- foo {
809
- @import "foo.scss";}
810
- SCSS
811
- assert(false, "Expected syntax error")
812
- rescue Sass::SyntaxError => e
813
- assert_equal "Import directives may only be used at the root of a document.", e.message
814
- assert_equal 2, e.sass_line
815
- end
816
-
817
- def test_rules_beneath_properties
818
- render <<SCSS
819
- foo {
820
- bar: {
821
- baz {
822
- bang: bop }}}
823
- SCSS
824
- assert(false, "Expected syntax error")
825
- rescue Sass::SyntaxError => e
826
- assert_equal 'Illegal nesting: Only properties may be nested beneath properties.', e.message
827
- assert_equal 3, e.sass_line
828
- end
829
-
830
- def test_uses_property_exception_with_star_hack
831
- render <<SCSS
832
- foo {
833
- *bar:baz [fail]; }
834
- SCSS
835
- assert(false, "Expected syntax error")
836
- rescue Sass::SyntaxError => e
837
- assert_equal 'Invalid CSS after " *bar:baz ": expected ";", was "[fail]; }"', e.message
838
- assert_equal 2, e.sass_line
839
- end
840
-
841
- def test_uses_property_exception_with_colon_hack
842
- render <<SCSS
843
- foo {
844
- :bar:baz [fail]; }
845
- SCSS
846
- assert(false, "Expected syntax error")
847
- rescue Sass::SyntaxError => e
848
- assert_equal 'Invalid CSS after " :bar:baz ": expected ";", was "[fail]; }"', e.message
849
- assert_equal 2, e.sass_line
850
- end
851
-
852
- def test_uses_rule_exception_with_dot_hack
853
- render <<SCSS
854
- foo {
855
- .bar:baz <fail>; }
856
- SCSS
857
- assert(false, "Expected syntax error")
858
- rescue Sass::SyntaxError => e
859
- assert_equal 'Invalid CSS after " .bar:baz ": expected "{", was "<fail>; }"', e.message
860
- assert_equal 2, e.sass_line
861
- end
862
-
863
- def test_uses_property_exception_with_space_after_name
864
- render <<SCSS
865
- foo {
866
- bar: baz [fail]; }
867
- SCSS
868
- assert(false, "Expected syntax error")
869
- rescue Sass::SyntaxError => e
870
- assert_equal 'Invalid CSS after " bar: baz ": expected ";", was "[fail]; }"', e.message
871
- assert_equal 2, e.sass_line
872
- end
873
-
874
- def test_uses_property_exception_with_non_identifier_after_name
875
- render <<SCSS
876
- foo {
877
- bar:1px [fail]; }
878
- SCSS
879
- assert(false, "Expected syntax error")
880
- rescue Sass::SyntaxError => e
881
- assert_equal 'Invalid CSS after " bar:1px ": expected ";", was "[fail]; }"', e.message
882
- assert_equal 2, e.sass_line
883
- end
884
-
885
- def test_uses_property_exception_when_followed_by_open_bracket
886
- render <<SCSS
887
- foo {
888
- bar:{baz: .fail} }
889
- SCSS
890
- assert(false, "Expected syntax error")
891
- rescue Sass::SyntaxError => e
892
- assert_equal 'Invalid CSS after " bar:{baz: ": expected expression (e.g. 1px, bold), was ".fail} }"', e.message
893
- assert_equal 2, e.sass_line
894
- end
895
-
896
- def test_script_error
897
- render <<SCSS
898
- foo {
899
- bar: "baz" * * }
900
- SCSS
901
- assert(false, "Expected syntax error")
902
- rescue Sass::SyntaxError => e
903
- assert_equal 'Invalid CSS after " bar: "baz" * ": expected expression (e.g. 1px, bold), was "* }"', e.message
904
- assert_equal 2, e.sass_line
905
- end
906
-
907
- def test_multiline_script_syntax_error
908
- render <<SCSS
909
- foo {
910
- bar:
911
- "baz" * * }
912
- SCSS
913
- assert(false, "Expected syntax error")
914
- rescue Sass::SyntaxError => e
915
- assert_equal 'Invalid CSS after " "baz" * ": expected expression (e.g. 1px, bold), was "* }"', e.message
916
- assert_equal 3, e.sass_line
917
- end
918
-
919
- def test_multiline_script_runtime_error
920
- render <<SCSS
921
- foo {
922
- bar: "baz" +
923
- "bar" +
924
- $bang }
925
- SCSS
926
- assert(false, "Expected syntax error")
927
- rescue Sass::SyntaxError => e
928
- assert_equal "Undefined variable: \"$bang\".", e.message
929
- assert_equal 4, e.sass_line
930
- end
931
-
932
- def test_post_multiline_script_runtime_error
933
- render <<SCSS
934
- foo {
935
- bar: "baz" +
936
- "bar" +
937
- "baz";
938
- bip: $bop; }
939
- SCSS
940
- assert(false, "Expected syntax error")
941
- rescue Sass::SyntaxError => e
942
- assert_equal "Undefined variable: \"$bop\".", e.message
943
- assert_equal 5, e.sass_line
944
- end
945
-
946
- def test_multiline_property_runtime_error
947
- render <<SCSS
948
- foo {
949
- bar: baz
950
- bar
951
- \#{$bang} }
952
- SCSS
953
- assert(false, "Expected syntax error")
954
- rescue Sass::SyntaxError => e
955
- assert_equal "Undefined variable: \"$bang\".", e.message
956
- assert_equal 4, e.sass_line
957
- end
958
-
959
- def test_post_resolution_selector_error
960
- render "\n\nfoo \#{\") bar\"} {a: b}"
961
- assert(false, "Expected syntax error")
962
- rescue Sass::SyntaxError => e
963
- assert_equal 'Invalid CSS after "foo ": expected selector, was ") bar"', e.message
964
- assert_equal 3, e.sass_line
965
- end
966
-
967
- def test_parent_in_mid_selector_error
968
- assert_raise_message(Sass::SyntaxError, <<MESSAGE) {render <<SCSS}
969
- Invalid CSS after ".foo": expected "{", was "&.bar"
970
-
971
- In Sass 3, the parent selector & can only be used where element names are valid,
972
- since it could potentially be replaced by an element name.
973
- MESSAGE
974
- flim {
975
- .foo&.bar {a: b}
976
- }
977
- SCSS
978
- end
979
-
980
- def test_parent_in_mid_selector_error
981
- assert_raise_message(Sass::SyntaxError, <<MESSAGE) {render <<SCSS}
982
- Invalid CSS after " .foo.bar": expected "{", was "& {a: b}"
983
-
984
- In Sass 3, the parent selector & can only be used where element names are valid,
985
- since it could potentially be replaced by an element name.
986
- MESSAGE
987
- flim {
988
- .foo.bar& {a: b}
989
- }
990
- SCSS
991
- end
992
-
993
- def test_double_parent_selector_error
994
- assert_raise_message(Sass::SyntaxError, <<MESSAGE) {render <<SCSS}
995
- Invalid CSS after " &": expected "{", was "& {a: b}"
996
-
997
- In Sass 3, the parent selector & can only be used where element names are valid,
998
- since it could potentially be replaced by an element name.
999
- MESSAGE
1000
- flim {
1001
- && {a: b}
1002
- }
1003
- SCSS
1004
- end
1005
-
1006
- def test_no_interpolation_in_media_queries
1007
- assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render <<SCSS}
1008
- Invalid CSS after "...nd (min-width: ": expected expression (e.g. 1px, bold), was "\#{100}px) {"
1009
- MESSAGE
1010
- @media screen and (min-width: \#{100}px) {
1011
- foo {bar: baz}
1012
- }
1013
- SCSS
1014
- end
1015
-
1016
- def test_no_interpolation_in_unrecognized_directives
1017
- assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render <<SCSS}
1018
- Invalid CSS after "@foo ": expected selector or at-rule, was "\#{100} {"
1019
- MESSAGE
1020
- @foo \#{100} {
1021
- foo {bar: baz}
1022
- }
1023
- SCSS
1024
- end
1025
-
1026
- def test_no_lonely_else
1027
- assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render <<SCSS}
1028
- Invalid CSS: @else must come after @if
1029
- MESSAGE
1030
- @else {foo: bar}
1031
- SCSS
1032
- end
1033
-
1034
- # Regression
1035
-
1036
- def test_weird_added_space
1037
- assert_equal <<CSS, render(<<SCSS)
1038
- foo {
1039
- bar: -moz-bip; }
1040
- CSS
1041
- $value : bip;
1042
-
1043
- foo {
1044
- bar: -moz-\#{$value};
1045
- }
1046
- SCSS
1047
- end
1048
-
1049
- def test_interpolation_with_bracket_on_next_line
1050
- assert_equal <<CSS, render(<<SCSS)
1051
- a.foo b {
1052
- color: red; }
1053
- CSS
1054
- a.\#{"foo"} b
1055
- {color: red}
1056
- SCSS
1057
- end
1058
-
1059
- def test_extra_comma_in_mixin_arglist_error
1060
- assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render <<SCSS}
1061
- Invalid CSS after "...clude foo(bar, ": expected mixin argument, was ");"
1062
- MESSAGE
1063
- @mixin foo($a1, $a2) {
1064
- baz: $a1 $a2;
1065
- }
1066
-
1067
- .bar {
1068
- @include foo(bar, );
1069
- }
1070
- SCSS
1071
- end
1072
-
1073
- def test_interpolation
1074
- assert_equal <<CSS, render(<<SCSS)
1075
- ul li#foo a span.label {
1076
- foo: bar; }
1077
- CSS
1078
- $bar : "#foo";
1079
- ul li\#{$bar} a span.label { foo: bar; }
1080
- SCSS
1081
- end
1082
-
1083
- def test_newlines_removed_from_selectors_when_compressed
1084
- assert_equal <<CSS, render(<<SCSS, :style=>:compressed)
1085
- z a,z b{display:block}
1086
- CSS
1087
- a,
1088
- b {
1089
- z & {
1090
- display: block;
1091
- }
1092
- }
1093
- SCSS
1094
- end
1095
-
1096
- def test_if_error_line
1097
- assert_raise_line(2) {render(<<SCSS)}
1098
- @if true {foo: bar}
1099
- }
1100
- SCSS
1101
- end
1102
-
1103
- def test_multiline_var
1104
- assert_equal <<CSS, render(<<SCSS)
1105
- foo {
1106
- a: 3;
1107
- b: false;
1108
- c: a b c; }
1109
- CSS
1110
- foo {
1111
- $var1: 1 +
1112
- 2;
1113
- $var2: true and
1114
- false;
1115
- $var3: a b
1116
- c;
1117
- a: $var1;
1118
- b: $var2;
1119
- c: $var3; }
1120
- SCSS
1121
- end
1122
- end