haml 3.0.21 → 3.0.22

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 (195) hide show
  1. data/Rakefile +1 -41
  2. data/VERSION +1 -1
  3. data/lib/haml/precompiler.rb +8 -6
  4. data/lib/haml/template/plugin.rb +16 -6
  5. data/lib/sass/less.rb +31 -12
  6. data/lib/sass/script/funcall.rb +2 -1
  7. data/lib/sass/script/operation.rb +10 -5
  8. data/lib/sass/script/parser.rb +9 -0
  9. data/test/haml/engine_test.rb +25 -0
  10. data/test/sass/less_conversion_test.rb +24 -3
  11. data/test/sass/script_conversion_test.rb +60 -0
  12. metadata +243 -426
  13. data/vendor/sass/CONTRIBUTING +0 -3
  14. data/vendor/sass/MIT-LICENSE +0 -20
  15. data/vendor/sass/README.md +0 -201
  16. data/vendor/sass/Rakefile +0 -363
  17. data/vendor/sass/TODO +0 -39
  18. data/vendor/sass/VERSION +0 -1
  19. data/vendor/sass/VERSION_NAME +0 -1
  20. data/vendor/sass/bin/css2sass +0 -13
  21. data/vendor/sass/bin/sass +0 -8
  22. data/vendor/sass/bin/sass-convert +0 -7
  23. data/vendor/sass/doc-src/FAQ.md +0 -35
  24. data/vendor/sass/doc-src/INDENTED_SYNTAX.md +0 -210
  25. data/vendor/sass/doc-src/SASS_CHANGELOG.md +0 -1870
  26. data/vendor/sass/doc-src/SASS_REFERENCE.md +0 -1713
  27. data/vendor/sass/doc-src/SCSS_FOR_SASS_USERS.md +0 -155
  28. data/vendor/sass/ext/extconf.rb +0 -10
  29. data/vendor/sass/extra/update_watch.rb +0 -13
  30. data/vendor/sass/init.rb +0 -18
  31. data/vendor/sass/lib/sass.rb +0 -71
  32. data/vendor/sass/lib/sass/cache_store.rb +0 -208
  33. data/vendor/sass/lib/sass/callbacks.rb +0 -66
  34. data/vendor/sass/lib/sass/css.rb +0 -294
  35. data/vendor/sass/lib/sass/engine.rb +0 -792
  36. data/vendor/sass/lib/sass/environment.rb +0 -143
  37. data/vendor/sass/lib/sass/error.rb +0 -201
  38. data/vendor/sass/lib/sass/exec.rb +0 -619
  39. data/vendor/sass/lib/sass/importers.rb +0 -22
  40. data/vendor/sass/lib/sass/importers/base.rb +0 -138
  41. data/vendor/sass/lib/sass/importers/filesystem.rb +0 -121
  42. data/vendor/sass/lib/sass/less.rb +0 -363
  43. data/vendor/sass/lib/sass/plugin.rb +0 -126
  44. data/vendor/sass/lib/sass/plugin/compiler.rb +0 -346
  45. data/vendor/sass/lib/sass/plugin/configuration.rb +0 -123
  46. data/vendor/sass/lib/sass/plugin/generic.rb +0 -15
  47. data/vendor/sass/lib/sass/plugin/merb.rb +0 -48
  48. data/vendor/sass/lib/sass/plugin/rack.rb +0 -47
  49. data/vendor/sass/lib/sass/plugin/rails.rb +0 -41
  50. data/vendor/sass/lib/sass/plugin/staleness_checker.rb +0 -145
  51. data/vendor/sass/lib/sass/railtie.rb +0 -8
  52. data/vendor/sass/lib/sass/repl.rb +0 -58
  53. data/vendor/sass/lib/sass/root.rb +0 -7
  54. data/vendor/sass/lib/sass/script.rb +0 -63
  55. data/vendor/sass/lib/sass/script/bool.rb +0 -18
  56. data/vendor/sass/lib/sass/script/color.rb +0 -491
  57. data/vendor/sass/lib/sass/script/css_lexer.rb +0 -29
  58. data/vendor/sass/lib/sass/script/css_parser.rb +0 -31
  59. data/vendor/sass/lib/sass/script/funcall.rb +0 -79
  60. data/vendor/sass/lib/sass/script/functions.rb +0 -852
  61. data/vendor/sass/lib/sass/script/interpolation.rb +0 -70
  62. data/vendor/sass/lib/sass/script/lexer.rb +0 -337
  63. data/vendor/sass/lib/sass/script/literal.rb +0 -236
  64. data/vendor/sass/lib/sass/script/node.rb +0 -101
  65. data/vendor/sass/lib/sass/script/number.rb +0 -423
  66. data/vendor/sass/lib/sass/script/operation.rb +0 -92
  67. data/vendor/sass/lib/sass/script/parser.rb +0 -392
  68. data/vendor/sass/lib/sass/script/string.rb +0 -67
  69. data/vendor/sass/lib/sass/script/string_interpolation.rb +0 -93
  70. data/vendor/sass/lib/sass/script/unary_operation.rb +0 -57
  71. data/vendor/sass/lib/sass/script/variable.rb +0 -48
  72. data/vendor/sass/lib/sass/scss.rb +0 -17
  73. data/vendor/sass/lib/sass/scss/css_parser.rb +0 -51
  74. data/vendor/sass/lib/sass/scss/parser.rb +0 -838
  75. data/vendor/sass/lib/sass/scss/rx.rb +0 -126
  76. data/vendor/sass/lib/sass/scss/sass_parser.rb +0 -11
  77. data/vendor/sass/lib/sass/scss/script_lexer.rb +0 -15
  78. data/vendor/sass/lib/sass/scss/script_parser.rb +0 -25
  79. data/vendor/sass/lib/sass/scss/static_parser.rb +0 -40
  80. data/vendor/sass/lib/sass/selector.rb +0 -361
  81. data/vendor/sass/lib/sass/selector/abstract_sequence.rb +0 -62
  82. data/vendor/sass/lib/sass/selector/comma_sequence.rb +0 -82
  83. data/vendor/sass/lib/sass/selector/sequence.rb +0 -236
  84. data/vendor/sass/lib/sass/selector/simple.rb +0 -113
  85. data/vendor/sass/lib/sass/selector/simple_sequence.rb +0 -135
  86. data/vendor/sass/lib/sass/shared.rb +0 -78
  87. data/vendor/sass/lib/sass/tree/comment_node.rb +0 -128
  88. data/vendor/sass/lib/sass/tree/debug_node.rb +0 -36
  89. data/vendor/sass/lib/sass/tree/directive_node.rb +0 -75
  90. data/vendor/sass/lib/sass/tree/extend_node.rb +0 -65
  91. data/vendor/sass/lib/sass/tree/for_node.rb +0 -67
  92. data/vendor/sass/lib/sass/tree/if_node.rb +0 -81
  93. data/vendor/sass/lib/sass/tree/import_node.rb +0 -124
  94. data/vendor/sass/lib/sass/tree/mixin_def_node.rb +0 -60
  95. data/vendor/sass/lib/sass/tree/mixin_node.rb +0 -123
  96. data/vendor/sass/lib/sass/tree/node.rb +0 -490
  97. data/vendor/sass/lib/sass/tree/prop_node.rb +0 -220
  98. data/vendor/sass/lib/sass/tree/root_node.rb +0 -125
  99. data/vendor/sass/lib/sass/tree/rule_node.rb +0 -273
  100. data/vendor/sass/lib/sass/tree/variable_node.rb +0 -39
  101. data/vendor/sass/lib/sass/tree/warn_node.rb +0 -42
  102. data/vendor/sass/lib/sass/tree/while_node.rb +0 -48
  103. data/vendor/sass/lib/sass/util.rb +0 -700
  104. data/vendor/sass/lib/sass/util/subset_map.rb +0 -101
  105. data/vendor/sass/lib/sass/version.rb +0 -109
  106. data/vendor/sass/rails/init.rb +0 -1
  107. data/vendor/sass/sass.gemspec +0 -32
  108. data/vendor/sass/test/sass/cache_test.rb +0 -74
  109. data/vendor/sass/test/sass/callbacks_test.rb +0 -61
  110. data/vendor/sass/test/sass/conversion_test.rb +0 -1210
  111. data/vendor/sass/test/sass/css2sass_test.rb +0 -364
  112. data/vendor/sass/test/sass/data/hsl-rgb.txt +0 -319
  113. data/vendor/sass/test/sass/engine_test.rb +0 -2283
  114. data/vendor/sass/test/sass/extend_test.rb +0 -1348
  115. data/vendor/sass/test/sass/functions_test.rb +0 -565
  116. data/vendor/sass/test/sass/importer_test.rb +0 -104
  117. data/vendor/sass/test/sass/less_conversion_test.rb +0 -632
  118. data/vendor/sass/test/sass/mock_importer.rb +0 -49
  119. data/vendor/sass/test/sass/more_results/more1.css +0 -9
  120. data/vendor/sass/test/sass/more_results/more1_with_line_comments.css +0 -26
  121. data/vendor/sass/test/sass/more_results/more_import.css +0 -29
  122. data/vendor/sass/test/sass/more_templates/_more_partial.sass +0 -2
  123. data/vendor/sass/test/sass/more_templates/more1.sass +0 -23
  124. data/vendor/sass/test/sass/more_templates/more_import.sass +0 -11
  125. data/vendor/sass/test/sass/plugin_test.rb +0 -430
  126. data/vendor/sass/test/sass/results/alt.css +0 -4
  127. data/vendor/sass/test/sass/results/basic.css +0 -9
  128. data/vendor/sass/test/sass/results/compact.css +0 -5
  129. data/vendor/sass/test/sass/results/complex.css +0 -86
  130. data/vendor/sass/test/sass/results/compressed.css +0 -1
  131. data/vendor/sass/test/sass/results/expanded.css +0 -19
  132. data/vendor/sass/test/sass/results/import.css +0 -31
  133. data/vendor/sass/test/sass/results/line_numbers.css +0 -49
  134. data/vendor/sass/test/sass/results/mixins.css +0 -95
  135. data/vendor/sass/test/sass/results/multiline.css +0 -24
  136. data/vendor/sass/test/sass/results/nested.css +0 -22
  137. data/vendor/sass/test/sass/results/options.css +0 -1
  138. data/vendor/sass/test/sass/results/parent_ref.css +0 -13
  139. data/vendor/sass/test/sass/results/script.css +0 -16
  140. data/vendor/sass/test/sass/results/scss_import.css +0 -31
  141. data/vendor/sass/test/sass/results/scss_importee.css +0 -2
  142. data/vendor/sass/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  143. data/vendor/sass/test/sass/results/subdir/subdir.css +0 -3
  144. data/vendor/sass/test/sass/results/units.css +0 -11
  145. data/vendor/sass/test/sass/results/warn.css +0 -0
  146. data/vendor/sass/test/sass/results/warn_imported.css +0 -0
  147. data/vendor/sass/test/sass/script_conversion_test.rb +0 -254
  148. data/vendor/sass/test/sass/script_test.rb +0 -470
  149. data/vendor/sass/test/sass/scss/css_test.rb +0 -897
  150. data/vendor/sass/test/sass/scss/rx_test.rb +0 -156
  151. data/vendor/sass/test/sass/scss/scss_test.rb +0 -1088
  152. data/vendor/sass/test/sass/scss/test_helper.rb +0 -37
  153. data/vendor/sass/test/sass/templates/_partial.sass +0 -2
  154. data/vendor/sass/test/sass/templates/alt.sass +0 -16
  155. data/vendor/sass/test/sass/templates/basic.sass +0 -23
  156. data/vendor/sass/test/sass/templates/bork1.sass +0 -2
  157. data/vendor/sass/test/sass/templates/bork2.sass +0 -2
  158. data/vendor/sass/test/sass/templates/bork3.sass +0 -2
  159. data/vendor/sass/test/sass/templates/bork4.sass +0 -2
  160. data/vendor/sass/test/sass/templates/compact.sass +0 -17
  161. data/vendor/sass/test/sass/templates/complex.sass +0 -305
  162. data/vendor/sass/test/sass/templates/compressed.sass +0 -15
  163. data/vendor/sass/test/sass/templates/expanded.sass +0 -17
  164. data/vendor/sass/test/sass/templates/import.sass +0 -12
  165. data/vendor/sass/test/sass/templates/importee.less +0 -2
  166. data/vendor/sass/test/sass/templates/importee.sass +0 -19
  167. data/vendor/sass/test/sass/templates/line_numbers.sass +0 -13
  168. data/vendor/sass/test/sass/templates/mixin_bork.sass +0 -5
  169. data/vendor/sass/test/sass/templates/mixins.sass +0 -76
  170. data/vendor/sass/test/sass/templates/multiline.sass +0 -20
  171. data/vendor/sass/test/sass/templates/nested.sass +0 -25
  172. data/vendor/sass/test/sass/templates/nested_bork1.sass +0 -2
  173. data/vendor/sass/test/sass/templates/nested_bork2.sass +0 -2
  174. data/vendor/sass/test/sass/templates/nested_bork3.sass +0 -2
  175. data/vendor/sass/test/sass/templates/nested_bork4.sass +0 -2
  176. data/vendor/sass/test/sass/templates/nested_mixin_bork.sass +0 -6
  177. data/vendor/sass/test/sass/templates/options.sass +0 -2
  178. data/vendor/sass/test/sass/templates/parent_ref.sass +0 -25
  179. data/vendor/sass/test/sass/templates/script.sass +0 -101
  180. data/vendor/sass/test/sass/templates/scss_import.scss +0 -11
  181. data/vendor/sass/test/sass/templates/scss_importee.scss +0 -1
  182. data/vendor/sass/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  183. data/vendor/sass/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  184. data/vendor/sass/test/sass/templates/subdir/subdir.sass +0 -6
  185. data/vendor/sass/test/sass/templates/units.sass +0 -11
  186. data/vendor/sass/test/sass/templates/warn.sass +0 -3
  187. data/vendor/sass/test/sass/templates/warn_imported.sass +0 -4
  188. data/vendor/sass/test/sass/test_helper.rb +0 -8
  189. data/vendor/sass/test/sass/util/subset_map_test.rb +0 -91
  190. data/vendor/sass/test/sass/util_test.rb +0 -275
  191. data/vendor/sass/test/test_helper.rb +0 -64
  192. data/vendor/sass/yard/callbacks.rb +0 -29
  193. data/vendor/sass/yard/default/fulldoc/html/css/common.sass +0 -26
  194. data/vendor/sass/yard/default/layout/html/footer.erb +0 -12
  195. data/vendor/sass/yard/inherited_hash.rb +0 -41
File without changes
@@ -1,254 +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 SassScriptConversionTest < Test::Unit::TestCase
7
- def test_bool
8
- assert_renders "true"
9
- assert_renders "false"
10
- end
11
-
12
- def test_color
13
- assert_renders "#abcdef"
14
- assert_renders "blue"
15
- assert_renders "rgba(0, 1, 2, 0.2)"
16
-
17
- assert_equal "#aabbcc", render("#abc")
18
- assert_equal "blue", render("#0000ff")
19
- end
20
-
21
- def test_number
22
- assert_renders "10"
23
- assert_renders "10.35"
24
- assert_renders "12px"
25
- assert_renders "12.45px"
26
-
27
- assert_equal "12.346", render("12.345678901")
28
- end
29
-
30
- def test_string
31
- assert_renders '"foo"'
32
- assert_renders '"bar baz"'
33
- assert_equal '"baz bang"', render("'baz bang'")
34
- end
35
-
36
- def test_string_quotes
37
- assert_equal "'quote\"quote'", render('"quote\\"quote"')
38
- assert_equal '"quote\'quote"', render("'quote\\'quote'")
39
- assert_renders '"quote\'quote\\"quote"'
40
- assert_equal '"quote\'quote\\"quote"', render("'quote\\'quote\"quote'")
41
- end
42
-
43
- def test_string_escapes
44
- assert_renders '"foo\\\\bar"'
45
- end
46
-
47
- def test_funcall
48
- assert_renders "foo(true, blue)"
49
- assert_renders "hsla(20deg, 30%, 50%, 0.3)"
50
- assert_renders "blam()"
51
-
52
- assert_renders "-\xC3\xBFoo(12px)"
53
- assert_renders "-foo(12px)"
54
- end
55
-
56
- def test_url
57
- assert_renders "url(foo.gif)"
58
- assert_renders "url($var)"
59
- assert_renders "url(\#{$var}/flip.gif)"
60
- end
61
-
62
- def test_variable
63
- assert_renders "$foo-bar"
64
- assert_renders "$flaznicate"
65
- assert_warning(<<WARN) {assert_equal "$tumbly-wumbly", render("!tumbly-wumbly")}
66
- DEPRECATION WARNING:
67
- On line 1, character 1 of 'test_variable_inline.sass'
68
- Variables with ! have been deprecated and will be removed in version 3.2.
69
- Use "$tumbly-wumbly" instead.
70
-
71
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
72
- WARN
73
- end
74
-
75
- def test_important
76
- assert_renders "!important"
77
- assert_renders "$foo !important"
78
- end
79
-
80
- def test_comma_operator
81
- assert_renders "$foo, $bar $baz"
82
- assert_renders "$foo $bar, $baz"
83
-
84
- assert_renders "($foo, $bar) $baz"
85
- assert_renders "$foo ($bar, $baz)"
86
-
87
- assert_equal "$foo, $bar $baz", render("$foo, ($bar $baz)")
88
- assert_equal "$foo $bar, $baz", render("($foo $bar), $baz")
89
- end
90
-
91
- def test_concat_operator
92
- assert_renders "$foo $bar or $baz"
93
- assert_renders "$foo or $bar $baz"
94
-
95
- assert_renders "($foo $bar) or $baz"
96
- assert_renders "$foo or ($bar $baz)"
97
-
98
- assert_equal "$foo $bar or $baz", render("$foo ($bar or $baz)")
99
- assert_equal "$foo or $bar $baz", render("($foo or $bar) $baz")
100
- end
101
-
102
- def self.test_precedence(outer, inner)
103
- op_outer = Sass::Script::Lexer::OPERATORS_REVERSE[outer]
104
- op_inner = Sass::Script::Lexer::OPERATORS_REVERSE[inner]
105
- class_eval <<RUBY
106
- def test_precedence_#{outer}_#{inner}
107
- assert_renders "$foo #{op_outer} $bar #{op_inner} $baz"
108
- assert_renders "$foo #{op_inner} $bar #{op_outer} $baz"
109
-
110
- assert_renders "($foo #{op_outer} $bar) #{op_inner} $baz"
111
- assert_renders "$foo #{op_inner} ($bar #{op_outer} $baz)"
112
-
113
- assert_equal "$foo #{op_outer} $bar #{op_inner} $baz",
114
- render("$foo #{op_outer} ($bar #{op_inner} $baz)")
115
- assert_equal "$foo #{op_inner} $bar #{op_outer} $baz",
116
- render("($foo #{op_inner} $bar) #{op_outer} $baz")
117
- end
118
- RUBY
119
- end
120
-
121
- test_precedence :or, :and
122
- test_precedence :and, :eq
123
- test_precedence :and, :neq
124
- test_precedence :eq, :gt
125
- test_precedence :eq, :gte
126
- test_precedence :eq, :lt
127
- test_precedence :eq, :lte
128
- test_precedence :gt, :plus
129
- test_precedence :gt, :minus
130
- test_precedence :plus, :times
131
- test_precedence :plus, :div
132
- test_precedence :plus, :mod
133
-
134
- def test_unary_op
135
- assert_renders "-12px"
136
- assert_renders '/"foo"'
137
- assert_renders 'not true'
138
-
139
- assert_renders "-(foo(12px))"
140
- assert_renders "-(-foo(12px))"
141
- assert_renders "-(_foo(12px))"
142
- assert_renders "-(\xC3\xBFoo(12px))"
143
- assert_renders "-(blue)"
144
-
145
- assert_equal 'not true or false', render('(not true) or false')
146
- assert_equal 'not (true or false)', render('not (true or false)')
147
- end
148
-
149
- def test_interpolation
150
- assert_renders "$foo\#{$bar}$baz"
151
- assert_renders "$foo\#{$bar} $baz"
152
- assert_renders "$foo \#{$bar}$baz"
153
- assert_renders "$foo \#{$bar} $baz"
154
- assert_renders "$foo \#{$bar}\#{$bang} $baz"
155
- assert_renders "$foo \#{$bar} \#{$bang} $baz"
156
- assert_renders "\#{$bar}$baz"
157
- assert_renders "$foo\#{$bar}"
158
- assert_renders "\#{$bar}"
159
- end
160
-
161
- def test_interpolation_in_function
162
- assert_renders 'flabnabbit(#{1 + "foo"})'
163
- assert_renders 'flabnabbit($foo #{1 + "foo"}$baz)'
164
- assert_renders 'flabnabbit($foo #{1 + "foo"}#{2 + "bar"} $baz)'
165
- end
166
-
167
- def test_interpolation_near_operators
168
- assert_renders '#{1 + 2} , #{3 + 4}'
169
- assert_renders '#{1 + 2}, #{3 + 4}'
170
- assert_renders '#{1 + 2} ,#{3 + 4}'
171
- assert_renders '#{1 + 2},#{3 + 4}'
172
-
173
- assert_renders '3 / #{3 + 4}'
174
- assert_renders '3 /#{3 + 4}'
175
- assert_renders '3/ #{3 + 4}'
176
- assert_renders '3/#{3 + 4}'
177
-
178
- assert_renders '#{1 + 2} * 7'
179
- assert_renders '#{1 + 2}* 7'
180
- assert_renders '#{1 + 2} *7'
181
- assert_renders '#{1 + 2}*7'
182
-
183
- assert_renders '-#{1 + 2}'
184
- assert_renders '- #{1 + 2}'
185
-
186
- assert_renders '5 + #{1 + 2} * #{3 + 4}'
187
- assert_renders '5 +#{1 + 2} * #{3 + 4}'
188
- assert_renders '5+#{1 + 2} * #{3 + 4}'
189
- assert_renders '#{1 + 2} * #{3 + 4} + 5'
190
- assert_renders '#{1 + 2} * #{3 + 4}+ 5'
191
- assert_renders '#{1 + 2} * #{3 + 4}+5'
192
-
193
- assert_equal '5 / #{1 + 2} + #{3 + 4}', render('5 / (#{1 + 2} + #{3 + 4})')
194
- assert_equal '5 / #{1 + 2} + #{3 + 4}', render('5 /(#{1 + 2} + #{3 + 4})')
195
- assert_equal '5 / #{1 + 2} + #{3 + 4}', render('5 /( #{1 + 2} + #{3 + 4} )')
196
- assert_equal '#{1 + 2} + #{3 + 4} / 5', render('(#{1 + 2} + #{3 + 4}) / 5')
197
- assert_equal '#{1 + 2} + #{3 + 4} / 5', render('(#{1 + 2} + #{3 + 4})/ 5')
198
- assert_equal '#{1 + 2} + #{3 + 4} / 5', render('( #{1 + 2} + #{3 + 4} )/ 5')
199
-
200
- assert_renders '#{1 + 2} + 2 + 3'
201
- assert_renders '#{1 + 2} +2 + 3'
202
- end
203
-
204
- def test_string_interpolation
205
- assert_renders '"foo#{$bar}baz"'
206
- assert_renders '"foo #{$bar}baz"'
207
- assert_renders '"foo#{$bar} baz"'
208
- assert_renders '"foo #{$bar} baz"'
209
- assert_renders '"foo #{$bar}#{$bang} baz"'
210
- assert_renders '"foo #{$bar} #{$bang} baz"'
211
- assert_renders '"#{$bar}baz"'
212
- assert_renders '"foo#{$bar}"'
213
- assert_equal '#{$bar}', render('"#{$bar}"')
214
-
215
- assert_equal '"foo#{$bar}baz"', render("'foo\#{$bar}baz'")
216
- end
217
-
218
- def test_sass2_string_interpolation
219
- assert_equal 'foo#{$bar}baz', render('"foo#{$bar}baz"', :context => :equals)
220
- assert_equal '#{$bar}baz', render('"#{$bar}baz"', :context => :equals)
221
- assert_equal 'foo#{$bar}', render('"foo#{$bar}"', :context => :equals)
222
-
223
- assert_equal 'unquote(".foo#{$bar}.bar")', render('".foo#{$bar}.bar"', :context => :equals)
224
- assert_equal 'unquote(".foo#{$bar}")', render('".foo#{$bar}"', :context => :equals)
225
- assert_equal 'unquote("#{$bar}.bar")', render('"#{$bar}.bar"', :context => :equals)
226
-
227
- assert_equal "unquote(\"f'o\#{$bar}b'z\")", render("'f\\'o\#{$bar}b\\'z'", :context => :equals)
228
- assert_equal "unquote('f\"o\#{$bar}b\"z')", render("'f\\\"o\#{$bar}b\\\"z'", :context => :equals)
229
- assert_equal "unquote(\"f'o\#{$bar}b\\\"z\")", render("'f\\'o\#{$bar}b\\\"z'", :context => :equals)
230
- end
231
-
232
- def test_sass2_urls
233
- Sass::Util.silence_sass_warnings do
234
- assert_equal 'url(foo/bar.gif)', render('url(foo/bar.gif)', :context => :equals)
235
- assert_equal 'url("foo/bar.gif")', render('url("foo/bar.gif")', :context => :equals)
236
-
237
- assert_equal 'url($var)', render('url(!var)', :context => :equals)
238
- assert_equal 'url("#{$var}/flip.gif")', render('url("#{!var}/flip.gif")', :context => :equals)
239
- end
240
- end
241
-
242
- private
243
-
244
- def assert_renders(script, options = {})
245
- assert_equal(script, render(script, options))
246
- end
247
-
248
- def render(script, options = {})
249
- munge_filename(options)
250
- node = Sass::Script.parse(script, 1, 0, options)
251
- node.context = options[:context] if options[:context]
252
- node.to_sass
253
- end
254
- end
@@ -1,470 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../test_helper'
3
- require 'sass/engine'
4
-
5
- module Sass::Script::Functions::UserFunctions
6
- def assert_options(val)
7
- val.options[:foo]
8
- Sass::Script::String.new("Options defined!")
9
- end
10
- end
11
-
12
- class SassScriptTest < Test::Unit::TestCase
13
- include Sass::Script
14
-
15
- def test_color_checks_input
16
- assert_raise_message(Sass::SyntaxError, "Blue value must be between 0 and 255") {Color.new([1, 2, -1])}
17
- assert_raise_message(Sass::SyntaxError, "Red value must be between 0 and 255") {Color.new([256, 2, 3])}
18
- end
19
-
20
- def test_color_checks_rgba_input
21
- assert_raise_message(Sass::SyntaxError, "Alpha channel must be between 0 and 1") {Color.new([1, 2, 3, 1.1])}
22
- assert_raise_message(Sass::SyntaxError, "Alpha channel must be between 0 and 1") {Color.new([1, 2, 3, -0.1])}
23
- end
24
-
25
- def test_string_escapes
26
- assert_equal "'", resolve("\"'\"")
27
- assert_equal '"', resolve("\"\\\"\"")
28
- assert_equal "\\\\", resolve("\"\\\\\"")
29
- assert_equal "\\02fa", resolve("\"\\02fa\"")
30
-
31
- assert_equal "'", resolve("'\\''")
32
- assert_equal '"', resolve("'\"'")
33
- assert_equal "\\\\", resolve("'\\\\'")
34
- assert_equal "\\02fa", resolve("'\\02fa'")
35
- end
36
-
37
- def test_string_interpolation
38
- assert_equal "foo2bar", resolve('\'foo#{1 + 1}bar\'')
39
- assert_equal "foo2bar", resolve('"foo#{1 + 1}bar"')
40
- assert_equal "foo1bar5baz4bang", resolve('\'foo#{1 + "bar#{2 + 3}baz" + 4}bang\'')
41
- end
42
-
43
- def test_color_names
44
- assert_equal "white", resolve("white")
45
- assert_equal "white", resolve("#ffffff")
46
- assert_equal "#fffffe", resolve("white - #000001")
47
- end
48
-
49
- def test_rgba_color_literals
50
- assert_equal Sass::Script::Color.new([1, 2, 3, 0.75]), eval("rgba(1, 2, 3, 0.75)")
51
- assert_equal "rgba(1, 2, 3, 0.75)", resolve("rgba(1, 2, 3, 0.75)")
52
-
53
- assert_equal Sass::Script::Color.new([1, 2, 3, 0]), eval("rgba(1, 2, 3, 0)")
54
- assert_equal "rgba(1, 2, 3, 0)", resolve("rgba(1, 2, 3, 0)")
55
-
56
- assert_equal Sass::Script::Color.new([1, 2, 3]), eval("rgba(1, 2, 3, 1)")
57
- assert_equal Sass::Script::Color.new([1, 2, 3, 1]), eval("rgba(1, 2, 3, 1)")
58
- assert_equal "#010203", resolve("rgba(1, 2, 3, 1)")
59
- assert_equal "white", resolve("rgba(255, 255, 255, 1)")
60
- end
61
-
62
- def test_rgba_color_math
63
- assert_equal "rgba(50, 50, 100, 0.35)", resolve("rgba(1, 1, 2, 0.35) * rgba(50, 50, 50, 0.35)")
64
- assert_equal "rgba(52, 52, 52, 0.25)", resolve("rgba(2, 2, 2, 0.25) + rgba(50, 50, 50, 0.25)")
65
-
66
- assert_raise_message(Sass::SyntaxError, "Alpha channels must be equal: rgba(1, 2, 3, 0.15) + rgba(50, 50, 50, 0.75)") do
67
- resolve("rgba(1, 2, 3, 0.15) + rgba(50, 50, 50, 0.75)")
68
- end
69
- assert_raise_message(Sass::SyntaxError, "Alpha channels must be equal: #123456 * rgba(50, 50, 50, 0.75)") do
70
- resolve("#123456 * rgba(50, 50, 50, 0.75)")
71
- end
72
- assert_raise_message(Sass::SyntaxError, "Alpha channels must be equal: rgba(50, 50, 50, 0.75) / #123456") do
73
- resolve("rgba(50, 50, 50, 0.75) / #123456")
74
- end
75
- end
76
-
77
- def test_rgba_number_math
78
- assert_equal "rgba(49, 49, 49, 0.75)", resolve("rgba(50, 50, 50, 0.75) - 1")
79
- assert_equal "rgba(100, 100, 100, 0.75)", resolve("rgba(50, 50, 50, 0.75) * 2")
80
- end
81
-
82
- def test_rgba_rounding
83
- assert_equal "rgba(10, 1, 0, 0.123)", resolve("rgba(10.0, 1.23456789, 0.0, 0.1234567)")
84
- end
85
-
86
- def test_compressed_colors
87
- assert_equal "#123456", resolve("#123456", :style => :compressed)
88
- assert_equal "rgba(1,2,3,0.5)", resolve("rgba(1, 2, 3, 0.5)", :style => :compressed)
89
- assert_equal "#123", resolve("#112233", :style => :compressed)
90
- assert_equal "#000", resolve("black", :style => :compressed)
91
- assert_equal "red", resolve("#f00", :style => :compressed)
92
- assert_equal "blue", resolve("#00f", :style => :compressed)
93
- assert_equal "navy", resolve("#000080", :style => :compressed)
94
- assert_equal "navy #fff", resolve("#000080 white", :style => :compressed)
95
- assert_equal "This color is #fff", resolve('"This color is #{ white }"', :style => :compressed)
96
- end
97
-
98
- def test_compressed_comma
99
- # assert_equal "foo,bar,baz", resolve("foo, bar, baz", :style => :compressed)
100
- # assert_equal "foo,#baf,baz", resolve("foo, #baf, baz", :style => :compressed)
101
- assert_equal "foo,#baf,red", resolve("foo, #baf, #f00", :style => :compressed)
102
- end
103
-
104
- def test_implicit_strings
105
- assert_equal Sass::Script::String.new("foo"), eval("foo")
106
- assert_equal Sass::Script::String.new("foo bar"), eval("foo bar")
107
- assert_equal Sass::Script::String.new("foo/bar"), eval("foo/bar")
108
- end
109
-
110
- def test_basic_interpolation
111
- assert_equal "foo3bar", resolve("foo\#{1 + 2}bar")
112
- assert_equal "foo3 bar", resolve("foo\#{1 + 2} bar")
113
- assert_equal "foo 3bar", resolve("foo \#{1 + 2}bar")
114
- assert_equal "foo 3 bar", resolve("foo \#{1 + 2} bar")
115
- assert_equal "foo 35 bar", resolve("foo \#{1 + 2}\#{2 + 3} bar")
116
- assert_equal "foo 3 5 bar", resolve("foo \#{1 + 2} \#{2 + 3} bar")
117
- assert_equal "3bar", resolve("\#{1 + 2}bar")
118
- assert_equal "foo3", resolve("foo\#{1 + 2}")
119
- assert_equal "3", resolve("\#{1 + 2}")
120
- end
121
-
122
- def test_interpolation_in_function
123
- assert_equal 'flabnabbit(1foo)', resolve('flabnabbit(#{1 + "foo"})')
124
- assert_equal 'flabnabbit(foo 1foobaz)', resolve('flabnabbit(foo #{1 + "foo"}baz)')
125
- assert_equal('flabnabbit(foo 1foo2bar baz)',
126
- resolve('flabnabbit(foo #{1 + "foo"}#{2 + "bar"} baz)'))
127
- end
128
-
129
- def test_interpolation_near_operators
130
- assert_equal '3 , 7', resolve('#{1 + 2} , #{3 + 4}')
131
- assert_equal '3, 7', resolve('#{1 + 2}, #{3 + 4}')
132
- assert_equal '3 ,7', resolve('#{1 + 2} ,#{3 + 4}')
133
- assert_equal '3,7', resolve('#{1 + 2},#{3 + 4}')
134
-
135
- assert_equal '3 / 7', resolve('3 / #{3 + 4}')
136
- assert_equal '3 /7', resolve('3 /#{3 + 4}')
137
- assert_equal '3/ 7', resolve('3/ #{3 + 4}')
138
- assert_equal '3/7', resolve('3/#{3 + 4}')
139
-
140
- assert_equal '3 * 7', resolve('#{1 + 2} * 7')
141
- assert_equal '3* 7', resolve('#{1 + 2}* 7')
142
- assert_equal '3 *7', resolve('#{1 + 2} *7')
143
- assert_equal '3*7', resolve('#{1 + 2}*7')
144
-
145
- assert_equal '-3', resolve('-#{1 + 2}')
146
- assert_equal '- 3', resolve('- #{1 + 2}')
147
-
148
- assert_equal '5 + 3 * 7', resolve('5 + #{1 + 2} * #{3 + 4}')
149
- assert_equal '5 +3 * 7', resolve('5 +#{1 + 2} * #{3 + 4}')
150
- assert_equal '5+3 * 7', resolve('5+#{1 + 2} * #{3 + 4}')
151
- assert_equal '3 * 7 + 5', resolve('#{1 + 2} * #{3 + 4} + 5')
152
- assert_equal '3 * 7+ 5', resolve('#{1 + 2} * #{3 + 4}+ 5')
153
- assert_equal '3 * 7+5', resolve('#{1 + 2} * #{3 + 4}+5')
154
-
155
- assert_equal '5/3 + 7', resolve('5 / (#{1 + 2} + #{3 + 4})')
156
- assert_equal '5/3 + 7', resolve('5 /(#{1 + 2} + #{3 + 4})')
157
- assert_equal '5/3 + 7', resolve('5 /( #{1 + 2} + #{3 + 4} )')
158
- assert_equal '3 + 7/5', resolve('(#{1 + 2} + #{3 + 4}) / 5')
159
- assert_equal '3 + 7/5', resolve('(#{1 + 2} + #{3 + 4})/ 5')
160
- assert_equal '3 + 7/5', resolve('( #{1 + 2} + #{3 + 4} )/ 5')
161
-
162
- assert_equal '3 + 5', resolve('#{1 + 2} + 2 + 3')
163
- assert_equal '3 +5', resolve('#{1 + 2} +2 + 3')
164
- end
165
-
166
- def test_string_interpolation
167
- assert_equal "foo bar, baz bang", resolve('"foo #{"bar"}, #{"baz"} bang"')
168
- assert_equal "foo bar baz bang", resolve('"foo #{"#{"ba" + "r"} baz"} bang"')
169
- assert_equal 'foo #{bar baz} bang', resolve('"foo \#{#{"ba" + "r"} baz} bang"')
170
- assert_equal 'foo #{baz bang', resolve('"foo #{"\#{" + "baz"} bang"')
171
- end
172
-
173
- def test_rule_interpolation
174
- assert_equal(<<CSS, render(<<SASS))
175
- foo bar baz bang {
176
- a: b; }
177
- CSS
178
- foo \#{"\#{"ba" + "r"} baz"} bang
179
- a: b
180
- SASS
181
- assert_equal(<<CSS, render(<<SASS))
182
- foo [bar="\#{bar baz}"] bang {
183
- a: b; }
184
- CSS
185
- foo [bar="\\\#{\#{"ba" + "r"} baz}"] bang
186
- a: b
187
- SASS
188
- assert_equal(<<CSS, render(<<SASS))
189
- foo [bar="\#{baz"] bang {
190
- a: b; }
191
- CSS
192
- foo [bar="\#{"\\\#{" + "baz"}"] bang
193
- a: b
194
- SASS
195
- end
196
-
197
- def test_inaccessible_functions
198
- assert_equal "send(to_s)", resolve("send(to_s)", :line => 2)
199
- assert_equal "public_instance_methods()", resolve("public_instance_methods()")
200
- end
201
-
202
- def test_default_functions
203
- assert_equal "url(12)", resolve("url(12)")
204
- assert_equal 'blam("foo")', resolve('blam("foo")')
205
- end
206
-
207
- def test_function_results_have_options
208
- assert_equal "Options defined!", resolve("assert_options(abs(1))")
209
- assert_equal "Options defined!", resolve("assert_options(round(1.2))")
210
- end
211
-
212
- def test_funcall_requires_no_whitespace_before_lparen
213
- assert_equal "no-repeat 15px", resolve("no-repeat (7px + 8px)")
214
- assert_equal "no-repeat(15px)", resolve("no-repeat(7px + 8px)")
215
- end
216
-
217
- def test_dynamic_url
218
- assert_equal "url(foo-bar)", resolve("url($foo)", {}, env('foo' => Sass::Script::String.new("foo-bar")))
219
- assert_equal "url(foo-bar baz)", resolve("url($foo $bar)", {}, env('foo' => Sass::Script::String.new("foo-bar"), 'bar' => Sass::Script::String.new("baz")))
220
- assert_equal "url(foo baz)", resolve("url(foo $bar)", {}, env('bar' => Sass::Script::String.new("baz")))
221
- assert_equal "url(foo bar)", resolve("url(foo bar)")
222
- end
223
-
224
- def test_url_with_interpolation
225
- assert_equal "url(http://sass-lang.com/images/foo-bar)", resolve("url(http://sass-lang.com/images/\#{foo-bar})")
226
- assert_equal 'url("http://sass-lang.com/images/foo-bar")', resolve("url('http://sass-lang.com/images/\#{foo-bar}')")
227
- assert_equal 'url("http://sass-lang.com/images/foo-bar")', resolve('url("http://sass-lang.com/images/#{foo-bar}")')
228
- assert_unquoted "url(http://sass-lang.com/images/\#{foo-bar})"
229
- end
230
-
231
- def test_hyphenated_variables
232
- assert_equal("a-b", resolve("$a-b", {}, env("a-b" => Sass::Script::String.new("a-b"))))
233
- end
234
-
235
- def test_ruby_equality
236
- assert_equal eval('"foo"'), eval('"foo"')
237
- assert_equal eval('1'), eval('1.0')
238
- assert_not_equal eval('1'), eval('"1"')
239
- end
240
-
241
- def test_booleans
242
- assert_equal "true", resolve("true")
243
- assert_equal "false", resolve("false")
244
- end
245
-
246
- def test_boolean_ops
247
- assert_equal "true", resolve("true and true")
248
- assert_equal "true", resolve("false or true")
249
- assert_equal "true", resolve("true or false")
250
- assert_equal "true", resolve("true or true")
251
- assert_equal "false", resolve("false or false")
252
- assert_equal "false", resolve("false and true")
253
- assert_equal "false", resolve("true and false")
254
- assert_equal "false", resolve("false and false")
255
-
256
- assert_equal "true", resolve("not false")
257
- assert_equal "false", resolve("not true")
258
- assert_equal "true", resolve("not not true")
259
-
260
- assert_equal "1", resolve("false or 1")
261
- assert_equal "false", resolve("false and 1")
262
- assert_equal "2", resolve("2 or 3")
263
- assert_equal "3", resolve("2 and 3")
264
- end
265
-
266
- def test_arithmetic_ops
267
- assert_equal "2", resolve("1 + 1")
268
- assert_equal "0", resolve("1 - 1")
269
- assert_equal "8", resolve("2 * 4")
270
- assert_equal "0.5", resolve("(2 / 4)")
271
- assert_equal "2", resolve("(4 / 2)")
272
-
273
- assert_equal "-1", resolve("-1")
274
- end
275
-
276
- def test_string_ops
277
- assert_equal '"foo" "bar"', resolve('"foo" "bar"')
278
- assert_equal "true 1", resolve('true 1')
279
- assert_equal '"foo", "bar"', resolve("'foo' , 'bar'")
280
- assert_equal "true, 1", resolve('true , 1')
281
- assert_equal "foobar", resolve('"foo" + "bar"')
282
- assert_equal "true1", resolve('true + 1')
283
- assert_equal '"foo"-"bar"', resolve("'foo' - 'bar'")
284
- assert_equal "true-1", resolve('true - 1')
285
- assert_equal '"foo"/"bar"', resolve('"foo" / "bar"')
286
- assert_equal "true/1", resolve('true / 1')
287
-
288
- assert_equal '-"bar"', resolve("- 'bar'")
289
- assert_equal "-true", resolve('- true')
290
- assert_equal '/"bar"', resolve('/ "bar"')
291
- assert_equal "/true", resolve('/ true')
292
- end
293
-
294
- def test_relational_ops
295
- assert_equal "false", resolve("1 > 2")
296
- assert_equal "false", resolve("2 > 2")
297
- assert_equal "true", resolve("3 > 2")
298
- assert_equal "false", resolve("1 >= 2")
299
- assert_equal "true", resolve("2 >= 2")
300
- assert_equal "true", resolve("3 >= 2")
301
- assert_equal "true", resolve("1 < 2")
302
- assert_equal "false", resolve("2 < 2")
303
- assert_equal "false", resolve("3 < 2")
304
- assert_equal "true", resolve("1 <= 2")
305
- assert_equal "true", resolve("2 <= 2")
306
- assert_equal "false", resolve("3 <= 2")
307
- end
308
-
309
- def test_equals
310
- assert_equal("true", resolve('"foo" == $foo', {},
311
- env("foo" => Sass::Script::String.new("foo"))))
312
- assert_equal "true", resolve("1 == 1.0")
313
- assert_equal "true", resolve("false != true")
314
- assert_equal "false", resolve("1em == 1px")
315
- assert_equal "false", resolve("12 != 12")
316
- end
317
-
318
- def test_operation_precedence
319
- assert_equal "false true", resolve("true and false false or true")
320
- assert_equal "true", resolve("false and true or true and true")
321
- assert_equal "true", resolve("1 == 2 or 3 == 3")
322
- assert_equal "true", resolve("1 < 2 == 3 >= 3")
323
- assert_equal "true", resolve("1 + 3 > 4 - 2")
324
- assert_equal "11", resolve("1 + 2 * 3 + 4")
325
- end
326
-
327
- def test_functions
328
- assert_equal "#80ff80", resolve("hsl(120, 100%, 75%)")
329
- assert_equal "#81ff81", resolve("hsl(120, 100%, 75%) + #010001")
330
- end
331
-
332
- def test_operator_unit_conversion
333
- assert_equal "1.1cm", resolve("1cm + 1mm")
334
- assert_equal "true", resolve("2mm < 1cm")
335
- assert_equal "true", resolve("10mm == 1cm")
336
- assert_equal "true", resolve("1 == 1cm")
337
- assert_equal "true", resolve("1.1cm == 11mm")
338
- end
339
-
340
- def test_operations_have_options
341
- assert_equal "Options defined!", resolve("assert_options(1 + 1)")
342
- assert_equal "Options defined!", resolve("assert_options('bar' + 'baz')")
343
- end
344
-
345
- def test_slash_compiles_literally_when_left_alone
346
- assert_equal "1px/2px", resolve("1px/2px")
347
- assert_equal "1px/2px/3px/4px", resolve("1px/2px/3px/4px")
348
-
349
- assert_equal "1px/2px redpx bluepx", resolve("1px/2px redpx bluepx")
350
- assert_equal "foo 1px/2px/3px bar", resolve("foo 1px/2px/3px bar")
351
- end
352
-
353
- def test_slash_divides_with_parens
354
- assert_equal "0.5", resolve("(1px/2px)")
355
- assert_equal "0.5", resolve("(1px)/2px")
356
- assert_equal "0.5", resolve("1px/(2px)")
357
- end
358
-
359
- def test_slash_divides_with_other_arithmetic
360
- assert_equal "0.5px", resolve("1px*1px/2px")
361
- assert_equal "0.5px", resolve("1px/2px*1px")
362
- assert_equal "0.5", resolve("0+1px/2px")
363
- assert_equal "0.5", resolve("1px/2px+0")
364
- end
365
-
366
- def test_slash_divides_with_variable
367
- assert_equal "0.5", resolve("$var/2px", {}, env("var" => eval("1px")))
368
- assert_equal "0.5", resolve("1px/$var", {}, env("var" => eval("2px")))
369
- assert_equal "0.5", resolve("$var", {}, env("var" => eval("1px/2px")))
370
- end
371
-
372
- def test_colors_with_wrong_number_of_digits
373
- assert_raise_message(Sass::SyntaxError,
374
- "Colors must have either three or six digits: '#0'") {eval("#0")}
375
- assert_raise_message(Sass::SyntaxError,
376
- "Colors must have either three or six digits: '#12'") {eval("#12")}
377
- assert_raise_message(Sass::SyntaxError,
378
- "Colors must have either three or six digits: '#abcd'") {eval("#abcd")}
379
- assert_raise_message(Sass::SyntaxError,
380
- "Colors must have either three or six digits: '#abcdE'") {eval("#abcdE")}
381
- assert_raise_message(Sass::SyntaxError,
382
- "Colors must have either three or six digits: '#abcdEFA'") {eval("#abcdEFA")}
383
- end
384
-
385
- def test_case_insensitive_color_names
386
- assert_equal "blue", resolve("BLUE")
387
- assert_equal "red", resolve("rEd")
388
- assert_equal "#7f4000", resolve("mix(GrEeN, ReD)")
389
- end
390
-
391
- # Regression Tests
392
-
393
- def test_funcall_has_higher_precedence_than_color_name
394
- assert_equal "teal(12)", resolve("teal(12)")
395
- assert_equal "tealbang(12)", resolve("tealbang(12)")
396
- assert_equal "teal-bang(12)", resolve("teal-bang(12)")
397
- assert_equal "teal\\+bang(12)", resolve("teal\\+bang(12)")
398
- end
399
-
400
- def test_interpolation_after_hash
401
- assert_equal "#2", resolve('"##{1 + 1}"')
402
- end
403
-
404
- def test_misplaced_comma_in_funcall
405
- assert_raise_message(Sass::SyntaxError,
406
- 'Invalid CSS after "foo(bar, ": expected function argument, was ")"') {eval('foo(bar, )')}
407
- end
408
-
409
- def test_color_prefixed_identifier
410
- assert_equal "tealbang", resolve("tealbang")
411
- assert_equal "teal-bang", resolve("teal-bang")
412
- end
413
-
414
- def test_op_prefixed_identifier
415
- assert_equal "notbang", resolve("notbang")
416
- assert_equal "not-bang", resolve("not-bang")
417
- assert_equal "or-bang", resolve("or-bang")
418
- assert_equal "and-bang", resolve("and-bang")
419
- end
420
-
421
- private
422
-
423
- def resolve(str, opts = {}, environment = env)
424
- munge_filename opts
425
- val = eval(str, opts, environment)
426
- val.is_a?(Sass::Script::String) ? val.value : val.to_s
427
- end
428
-
429
- def assert_unquoted(str, opts = {}, environment = env)
430
- munge_filename opts
431
- val = eval(str, opts, environment)
432
- assert_kind_of Sass::Script::String, val
433
- assert_equal :identifier, val.type
434
- end
435
-
436
- def assert_quoted(str, opts = {}, environment = env)
437
- munge_filename opts
438
- val = eval(str, opts, environment)
439
- assert_kind_of Sass::Script::String, val
440
- assert_equal :string, val.type
441
- end
442
-
443
- def eval(str, opts = {}, environment = env)
444
- munge_filename opts
445
- environment.options = opts
446
- Sass::Script.parse(str, opts.delete(:line) || 1,
447
- opts.delete(:offset) || 0, opts).perform(environment)
448
- end
449
-
450
- def render(sass, options = {})
451
- munge_filename options
452
- Sass::Engine.new(sass, options).render
453
- end
454
-
455
- def env(hash = {})
456
- env = Sass::Environment.new
457
- hash.each {|k, v| env.set_var(k, v)}
458
- env
459
- end
460
-
461
- def test_number_printing
462
- assert_equal "1", eval("1")
463
- assert_equal "1", eval("1.0")
464
- assert_equal "1.121", eval("1.1214")
465
- assert_equal "1.122", eval("1.1215")
466
- assert_equal "Infinity", eval("1.0/0.0")
467
- assert_equal "-Infinity", eval("-1.0/0.0")
468
- assert_equal "NaN", eval("0.0/0.0")
469
- end
470
- end