haml 3.1.3 → 3.1.4

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 (134) hide show
  1. data/Rakefile +42 -17
  2. data/VERSION +1 -1
  3. data/lib/haml/compiler.rb +3 -3
  4. data/lib/haml/helpers/action_view_mods.rb +4 -3
  5. data/lib/haml/template.rb +3 -1
  6. data/test/gemfiles/Gemfile.rails-2.0.x +8 -0
  7. data/test/gemfiles/Gemfile.rails-2.0.x.lock +38 -0
  8. data/test/gemfiles/Gemfile.rails-2.1.x +8 -0
  9. data/test/gemfiles/Gemfile.rails-2.1.x.lock +38 -0
  10. data/test/gemfiles/Gemfile.rails-2.2.x +8 -0
  11. data/test/gemfiles/Gemfile.rails-2.2.x.lock +38 -0
  12. data/test/gemfiles/Gemfile.rails-2.3.x +8 -0
  13. data/test/gemfiles/Gemfile.rails-2.3.x.lock +40 -0
  14. data/test/gemfiles/Gemfile.rails-3.0.x +8 -0
  15. data/test/gemfiles/Gemfile.rails-3.0.x.lock +85 -0
  16. data/test/gemfiles/Gemfile.rails-3.1.x +8 -0
  17. data/test/gemfiles/Gemfile.rails-3.1.x.lock +98 -0
  18. data/test/gemfiles/Gemfile.rails-xss-2.3.x +9 -0
  19. data/test/gemfiles/Gemfile.rails-xss-2.3.x.lock +42 -0
  20. data/test/haml/engine_test.rb +19 -0
  21. data/test/haml/html2haml_test.rb +1 -1
  22. data/test/haml/template_test.rb +20 -2
  23. data/test/haml/templates/partial_layout.haml +4 -1
  24. data/test/linked_rails.rb +4 -4
  25. data/vendor/sass/VERSION +1 -1
  26. data/vendor/sass/doc-src/SASS_CHANGELOG.md +115 -2
  27. data/vendor/sass/doc-src/SASS_REFERENCE.md +12 -4
  28. data/vendor/sass/lib/sass.rb +1 -0
  29. data/vendor/sass/lib/sass/cache_stores/base.rb +3 -1
  30. data/vendor/sass/lib/sass/cache_stores/filesystem.rb +2 -0
  31. data/vendor/sass/lib/sass/css.rb +2 -1
  32. data/vendor/sass/lib/sass/engine.rb +39 -23
  33. data/vendor/sass/lib/sass/environment.rb +11 -0
  34. data/vendor/sass/lib/sass/exec.rb +14 -1
  35. data/vendor/sass/lib/sass/importers/base.rb +2 -1
  36. data/vendor/sass/lib/sass/importers/filesystem.rb +18 -13
  37. data/vendor/sass/lib/sass/less.rb +2 -2
  38. data/vendor/sass/lib/sass/logger.rb +15 -0
  39. data/vendor/sass/lib/sass/logger/base.rb +32 -0
  40. data/vendor/sass/lib/sass/logger/log_level.rb +49 -0
  41. data/vendor/sass/lib/sass/plugin.rb +4 -8
  42. data/vendor/sass/lib/sass/plugin/compiler.rb +42 -17
  43. data/vendor/sass/lib/sass/plugin/configuration.rb +0 -2
  44. data/vendor/sass/lib/sass/railtie.rb +1 -1
  45. data/vendor/sass/lib/sass/script/funcall.rb +14 -1
  46. data/vendor/sass/lib/sass/script/functions.rb +44 -1
  47. data/vendor/sass/lib/sass/script/interpolation.rb +9 -0
  48. data/vendor/sass/lib/sass/script/lexer.rb +6 -1
  49. data/vendor/sass/lib/sass/script/list.rb +7 -0
  50. data/vendor/sass/lib/sass/script/literal.rb +5 -0
  51. data/vendor/sass/lib/sass/script/node.rb +8 -0
  52. data/vendor/sass/lib/sass/script/number.rb +28 -5
  53. data/vendor/sass/lib/sass/script/operation.rb +8 -0
  54. data/vendor/sass/lib/sass/script/parser.rb +12 -5
  55. data/vendor/sass/lib/sass/script/string_interpolation.rb +9 -0
  56. data/vendor/sass/lib/sass/script/unary_operation.rb +7 -0
  57. data/vendor/sass/lib/sass/script/variable.rb +5 -0
  58. data/vendor/sass/lib/sass/scss/parser.rb +78 -38
  59. data/vendor/sass/lib/sass/scss/rx.rb +2 -1
  60. data/vendor/sass/lib/sass/scss/static_parser.rb +2 -2
  61. data/vendor/sass/lib/sass/shared.rb +1 -1
  62. data/vendor/sass/lib/sass/tree/comment_node.rb +24 -11
  63. data/vendor/sass/lib/sass/tree/debug_node.rb +1 -1
  64. data/vendor/sass/lib/sass/tree/each_node.rb +1 -1
  65. data/vendor/sass/lib/sass/tree/extend_node.rb +1 -1
  66. data/vendor/sass/lib/sass/tree/for_node.rb +2 -2
  67. data/vendor/sass/lib/sass/tree/function_node.rb +1 -1
  68. data/vendor/sass/lib/sass/tree/if_node.rb +1 -14
  69. data/vendor/sass/lib/sass/tree/mixin_def_node.rb +1 -1
  70. data/vendor/sass/lib/sass/tree/mixin_node.rb +2 -2
  71. data/vendor/sass/lib/sass/tree/node.rb +2 -5
  72. data/vendor/sass/lib/sass/tree/prop_node.rb +2 -9
  73. data/vendor/sass/lib/sass/tree/return_node.rb +1 -1
  74. data/vendor/sass/lib/sass/tree/rule_node.rb +9 -2
  75. data/vendor/sass/lib/sass/tree/variable_node.rb +1 -1
  76. data/vendor/sass/lib/sass/tree/visitors/check_nesting.rb +17 -18
  77. data/vendor/sass/lib/sass/tree/visitors/convert.rb +10 -5
  78. data/vendor/sass/lib/sass/tree/visitors/deep_copy.rb +87 -0
  79. data/vendor/sass/lib/sass/tree/visitors/perform.rb +50 -19
  80. data/vendor/sass/lib/sass/tree/visitors/set_options.rb +97 -0
  81. data/vendor/sass/lib/sass/tree/visitors/to_css.rb +9 -15
  82. data/vendor/sass/lib/sass/tree/warn_node.rb +1 -1
  83. data/vendor/sass/lib/sass/tree/while_node.rb +1 -1
  84. data/vendor/sass/lib/sass/util.rb +58 -6
  85. data/vendor/sass/sass.gemspec +2 -1
  86. data/vendor/sass/test/Gemfile +4 -0
  87. data/vendor/sass/test/Gemfile.lock +19 -0
  88. data/vendor/sass/test/sass/cache_test.rb +15 -0
  89. data/vendor/sass/test/sass/conversion_test.rb +2 -6
  90. data/vendor/sass/test/sass/css2sass_test.rb +9 -0
  91. data/vendor/sass/test/sass/engine_test.rb +124 -26
  92. data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.css +1 -0
  93. data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.scss +1 -0
  94. data/vendor/sass/test/sass/functions_test.rb +13 -0
  95. data/vendor/sass/test/sass/importer_test.rb +110 -0
  96. data/vendor/sass/test/sass/logger_test.rb +58 -0
  97. data/vendor/sass/test/sass/plugin_test.rb +16 -13
  98. data/vendor/sass/test/sass/script_conversion_test.rb +2 -0
  99. data/vendor/sass/test/sass/script_test.rb +18 -0
  100. data/vendor/sass/test/sass/scss/css_test.rb +7 -1
  101. data/vendor/sass/test/sass/scss/scss_test.rb +37 -13
  102. data/vendor/sass/test/sass/templates/bork5.sass +3 -0
  103. data/vendor/sass/test/sass/templates/nested_bork5.sass +2 -0
  104. data/vendor/sass/test/sass/test_helper.rb +1 -1
  105. data/vendor/sass/test/sass/util_test.rb +12 -0
  106. data/vendor/sass/vendor/fssm/Gemfile +3 -0
  107. data/vendor/sass/vendor/fssm/LICENSE +1 -1
  108. data/vendor/sass/vendor/fssm/README.markdown +55 -27
  109. data/vendor/sass/vendor/fssm/Rakefile +6 -54
  110. data/vendor/sass/vendor/fssm/example.rb +6 -3
  111. data/vendor/sass/vendor/fssm/fssm.gemspec +17 -70
  112. data/vendor/sass/vendor/fssm/lib/fssm.rb +7 -3
  113. data/vendor/sass/vendor/fssm/lib/fssm/backends/fsevents.rb +1 -1
  114. data/vendor/sass/vendor/fssm/lib/fssm/backends/inotify.rb +2 -2
  115. data/vendor/sass/vendor/fssm/lib/fssm/backends/polling.rb +2 -2
  116. data/vendor/sass/vendor/fssm/lib/fssm/backends/rbfsevent.rb +42 -0
  117. data/vendor/sass/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +10 -10
  118. data/vendor/sass/vendor/fssm/lib/fssm/monitor.rb +19 -9
  119. data/vendor/sass/vendor/fssm/lib/fssm/path.rb +24 -21
  120. data/vendor/sass/vendor/fssm/lib/fssm/pathname.rb +13 -479
  121. data/vendor/sass/vendor/fssm/lib/fssm/state/directory.rb +29 -11
  122. data/vendor/sass/vendor/fssm/lib/fssm/state/file.rb +1 -1
  123. data/vendor/sass/vendor/fssm/lib/fssm/support.rb +41 -12
  124. data/vendor/sass/vendor/fssm/lib/fssm/tree.rb +6 -6
  125. data/vendor/sass/vendor/fssm/lib/fssm/version.rb +3 -0
  126. data/vendor/sass/vendor/fssm/profile/prof-cache.rb +3 -3
  127. data/vendor/sass/vendor/fssm/profile/prof-pathname-rubinius.rb +35 -0
  128. data/vendor/sass/vendor/fssm/profile/prof-pathname.rb +7 -7
  129. data/vendor/sass/vendor/fssm/spec/count_down_latch.rb +151 -0
  130. data/vendor/sass/vendor/fssm/spec/monitor_spec.rb +202 -0
  131. data/vendor/sass/vendor/fssm/spec/path_spec.rb +36 -15
  132. data/vendor/sass/vendor/fssm/spec/spec_helper.rb +6 -6
  133. metadata +36 -5
  134. data/vendor/sass/vendor/fssm/VERSION.yml +0 -5
@@ -57,21 +57,11 @@ class Sass::Tree::Visitors::ToCss < Sass::Tree::Visitors::Base
57
57
 
58
58
  def visit_comment(node)
59
59
  return if node.invisible?
60
- spaces = (' ' * [@tabs - node.value[/^ */].size, 0].max)
60
+ spaces = (' ' * [@tabs - node.resolved_value[/^ */].size, 0].max)
61
61
 
62
- content = node.value.gsub(/^/, spaces).gsub(%r{^(\s*)//(.*)$}) do |md|
62
+ content = node.resolved_value.gsub(/^/, spaces).gsub(%r{^(\s*)//(.*)$}) do |md|
63
63
  "#{$1}/*#{$2} */"
64
64
  end
65
- if content =~ /[^\\]\#\{.*\}/
66
- Sass::Util.sass_warn <<MESSAGE
67
- WARNING:
68
- On line #{node.line}#{" of '#{node.filename}'" if node.filename}
69
- Comments will evaluate the contents of interpolations (\#{ ... }) in Sass 3.2.
70
- Please escape the interpolation by adding a backslash before the hash sign.
71
- MESSAGE
72
- elsif content =~ /\\\#\{.*\}/
73
- content.gsub!(/\\(\#\{.*\})/, '\1')
74
- end
75
65
  content.gsub!(/\n +(\* *(?!\/))?/, ' ') if (node.style == :compact || node.style == :compressed) && !node.loud
76
66
  content
77
67
  end
@@ -122,9 +112,9 @@ MESSAGE
122
112
  def visit_prop(node)
123
113
  tab_str = ' ' * (@tabs + node.tabs)
124
114
  if node.style == :compressed
125
- "#{tab_str}#{node.resolved_name}:#{node.resolved_value}#{'!important' if node.important}"
115
+ "#{tab_str}#{node.resolved_name}:#{node.resolved_value}"
126
116
  else
127
- "#{tab_str}#{node.resolved_name}: #{node.resolved_value}#{' !important' if node.important};"
117
+ "#{tab_str}#{node.resolved_name}: #{node.resolved_value};"
128
118
  end
129
119
  end
130
120
 
@@ -156,6 +146,10 @@ MESSAGE
156
146
  if node.style != :compressed
157
147
  if node.options[:debug_info]
158
148
  to_return << visit(debug_info_rule(node.debug_info, node.options)) << "\n"
149
+ elsif node.options[:trace_selectors]
150
+ to_return << "#{old_spaces}/* "
151
+ to_return << node.stack_trace.join("\n #{old_spaces}")
152
+ to_return << " */\n"
159
153
  elsif node.options[:line_comments]
160
154
  to_return << "#{old_spaces}/* line #{node.line}"
161
155
 
@@ -204,7 +198,7 @@ MESSAGE
204
198
  [Sass::Selector::Element.new(k.to_s.gsub(/[^\w-]/, "\\\\\\0"), nil)])
205
199
  ])
206
200
  ])
207
- prop = Sass::Tree::PropNode.new([""], "", false, :new)
201
+ prop = Sass::Tree::PropNode.new([""], Sass::Script::String.new(''), :new)
208
202
  prop.resolved_name = "font-family"
209
203
  prop.resolved_value = Sass::SCSS::RX.escape_ident(v.to_s)
210
204
  rule << prop
@@ -6,7 +6,7 @@ module Sass
6
6
  class WarnNode < Node
7
7
  # The expression to print.
8
8
  # @return [Script::Node]
9
- attr_reader :expr
9
+ attr_accessor :expr
10
10
 
11
11
  # @param expr [Script::Node] The expression to print
12
12
  def initialize(expr)
@@ -7,7 +7,7 @@ module Sass::Tree
7
7
  class WhileNode < Node
8
8
  # The parse tree for the continuation expression.
9
9
  # @return [Script::Node]
10
- attr_reader :expr
10
+ attr_accessor :expr
11
11
 
12
12
  # @param expr [Script::Node] See \{#expr}
13
13
  def initialize(expr)
@@ -293,19 +293,17 @@ module Sass
293
293
  #
294
294
  # @yield A block in which no Sass warnings will be printed
295
295
  def silence_sass_warnings
296
- old_silence_warnings = @@silence_warnings
297
- @@silence_warnings = true
296
+ old_level, Sass.logger.log_level = Sass.logger.log_level, :error
298
297
  yield
299
298
  ensure
300
- @@silence_warnings = old_silence_warnings
299
+ Sass.logger.log_level = old_level
301
300
  end
302
301
 
303
302
  # The same as `Kernel#warn`, but is silenced by \{#silence\_sass\_warnings}.
304
303
  #
305
304
  # @param msg [String]
306
305
  def sass_warn(msg)
307
- return if @@silence_warnings
308
- warn(msg)
306
+ Sass.logger.warn(msg)
309
307
  end
310
308
 
311
309
  ## Cross Rails Version Compatibility
@@ -469,7 +467,8 @@ MSG
469
467
  # We allow any printable ASCII characters but double quotes in the charset decl
470
468
  bin = str.dup.force_encoding("BINARY")
471
469
  encoding = Sass::Util::ENCODINGS_TO_CHECK.find do |enc|
472
- bin =~ Sass::Util::CHARSET_REGEXPS[enc]
470
+ re = Sass::Util::CHARSET_REGEXPS[enc]
471
+ re && bin =~ re
473
472
  end
474
473
  charset, bom = $1, $2
475
474
  if charset
@@ -510,6 +509,8 @@ MSG
510
509
  Regexp.new(/\A(?:#{_enc("\uFEFF", e)})?#{
511
510
  _enc('@charset "', e)}(.*?)#{_enc('"', e)}|\A(#{
512
511
  _enc("\uFEFF", e)})/)
512
+ rescue Encoding::ConverterNotFound => _
513
+ nil # JRuby on Java 5 doesn't support UTF-32
513
514
  rescue
514
515
  # /\A@charset "(.*?)"/
515
516
  Regexp.new(/\A#{_enc('@charset "', e)}(.*?)#{_enc('"', e)}/)
@@ -614,6 +615,57 @@ MSG
614
615
  '"' + obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]} + '"'
615
616
  end
616
617
 
618
+ # Extracts the non-string vlaues from an array containing both strings and non-strings.
619
+ # These values are replaced with escape sequences.
620
+ # This can be undone using \{#inject\_values}.
621
+ #
622
+ # This is useful e.g. when we want to do string manipulation
623
+ # on an interpolated string.
624
+ #
625
+ # The precise format of the resulting string is not guaranteed.
626
+ # However, it is guaranteed that newlines and whitespace won't be affected.
627
+ #
628
+ # @param arr [Array] The array from which values are extracted.
629
+ # @return [(String, Array)] The resulting string, and an array of extracted values.
630
+ def extract_values(arr)
631
+ values = []
632
+ return arr.map do |e|
633
+ next e.gsub('{', '{{') if e.is_a?(String)
634
+ values << e
635
+ next "{#{values.count - 1}}"
636
+ end.join, values
637
+ end
638
+
639
+ # Undoes \{#extract\_values} by transforming a string with escape sequences
640
+ # into an array of strings and non-string values.
641
+ #
642
+ # @param str [String] The string with escape sequences.
643
+ # @param values [Array] The array of values to inject.
644
+ # @return [Array] The array of strings and values.
645
+ def inject_values(str, values)
646
+ return [str.gsub('{{', '{')] if values.empty?
647
+ # Add an extra { so that we process the tail end of the string
648
+ result = (str + '{{').scan(/(.*?)(?:(\{\{)|\{(\d+)\})/m).map do |(pre, esc, n)|
649
+ [pre, esc ? '{' : '', n ? values[n.to_i] : '']
650
+ end.flatten(1)
651
+ result[-2] = '' # Get rid of the extra {
652
+ merge_adjacent_strings(result).reject {|s| s == ''}
653
+ end
654
+
655
+ # Allows modifications to be performed on the string form
656
+ # of an array containing both strings and non-strings.
657
+ #
658
+ # @param arr [Array] The array from which values are extracted.
659
+ # @yield [str] A block in which string manipulation can be done to the array.
660
+ # @yieldparam str [String] The string form of `arr`.
661
+ # @yieldreturn [String] The modified string.
662
+ # @return [Array] The modified, interpolated array.
663
+ def with_extracted_values(arr)
664
+ str, vals = extract_values(arr)
665
+ str = yield str
666
+ inject_values(str, vals)
667
+ end
668
+
617
669
  ## Static Method Stuff
618
670
 
619
671
  # The context in which the ERB for \{#def\_static\_method} will be run.
@@ -18,11 +18,12 @@ SASS_GEMSPEC = Gem::Specification.new do |spec|
18
18
  command line tool or a web-framework plugin.
19
19
  END
20
20
 
21
+ spec.required_ruby_version = '>= 1.8.7'
21
22
  spec.add_development_dependency 'yard', '>= 0.5.3'
22
23
  spec.add_development_dependency 'maruku', '>= 0.5.9'
23
24
 
24
25
  readmes = Dir['*'].reject{ |x| x =~ /(^|[^.a-z])[a-z]+/ || x == "TODO" }
25
- spec.executables = ['sass', 'sass-convert']
26
+ spec.executables = ['sass', 'sass-convert', 'scss']
26
27
  spec.files = Dir['rails/init.rb', 'lib/**/*', 'vendor/**/*',
27
28
  'bin/*', 'test/**/*', 'extra/**/*', 'Rakefile', 'init.rb',
28
29
  '.yardopts'] + readmes
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ gem 'rake'
4
+ gem 'less', '< 2.0.0'
@@ -0,0 +1,19 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ less (1.2.21)
5
+ mutter (>= 0.4.2)
6
+ treetop (>= 1.4.2)
7
+ mutter (0.5.3)
8
+ polyglot (0.3.2)
9
+ rake (0.9.2)
10
+ treetop (1.4.10)
11
+ polyglot
12
+ polyglot (>= 0.3.1)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ less (< 2.0.0)
19
+ rake
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../test_helper'
3
+ require File.dirname(__FILE__) + '/test_helper'
3
4
  require 'sass/engine'
4
5
 
5
6
  class CacheTest < Test::Unit::TestCase
@@ -11,6 +12,7 @@ class CacheTest < Test::Unit::TestCase
11
12
 
12
13
  def teardown
13
14
  FileUtils.rm_rf @@cache_dir
15
+ clean_up_sassc
14
16
  end
15
17
 
16
18
  def test_file_cache_writes_a_file
@@ -64,6 +66,19 @@ class CacheTest < Test::Unit::TestCase
64
66
  assert_equal an_object, cache.retrieve("an_object", "")
65
67
  end
66
68
 
69
+ class Unmarshalable
70
+ def _dump(_)
71
+ raise 'Unmarshalable'
72
+ end
73
+ end
74
+
75
+ def test_cache_node_with_unmarshalable_option
76
+ engine = Sass::Engine.new("foo {a: b + c}",
77
+ :syntax => :scss, :object => Unmarshalable.new, :filename => 'file.scss',
78
+ :importer => Sass::Importers::Filesystem.new(absolutize('templates')))
79
+ engine.to_tree
80
+ end
81
+
67
82
  private
68
83
  def root_node
69
84
  Sass::Engine.new(<<-SCSS, :syntax => :scss).to_tree
@@ -1131,17 +1131,13 @@ div
1131
1131
  SASS
1132
1132
  end
1133
1133
 
1134
- def test_loud_comment_conversion
1134
+ def test_loud_comment_conversion
1135
1135
  assert_renders(<<SASS, <<SCSS)
1136
1136
  /*! \#{"interpolated"}
1137
- /*!
1138
- * \#{"also interpolated"}
1139
1137
  SASS
1140
1138
  /*! \#{"interpolated"} */
1141
- /*!
1142
- * \#{"also interpolated"} */
1143
1139
  SCSS
1144
- assert_renders(<<SASS, <<SCSS)
1140
+ silence_warnings {assert_renders(<<SASS, <<SCSS)}
1145
1141
  //! \#{"interpolated"}
1146
1142
  //!
1147
1143
  //! \#{"also interpolated"}
@@ -268,6 +268,15 @@ SASS
268
268
  CSS
269
269
  end
270
270
 
271
+ def test_double_comma
272
+ assert_equal(<<SASS, css2sass(<<CSS))
273
+ foo, bar
274
+ a: b
275
+ SASS
276
+ foo, , bar { a: b }
277
+ CSS
278
+ end
279
+
271
280
  # Error reporting
272
281
 
273
282
  def test_error_reporting
@@ -57,16 +57,12 @@ MSG
57
57
  "& a\n :b c" => ["Base-level rules cannot contain the parent-selector-referencing character '&'.", 1],
58
58
  "a\n :b\n c" => "Illegal nesting: Only properties may be nested beneath properties.",
59
59
  "$a: b\n :c d\n" => "Illegal nesting: Nothing may be nested beneath variable declarations.",
60
- "@import foo.sass" => "File to import not found or unreadable: foo.sass.",
61
60
  "$a: b\n :c d\n" => "Illegal nesting: Nothing may be nested beneath variable declarations.",
62
- "@import foo.sass" => <<MSG,
63
- File to import not found or unreadable: foo.sass.
64
- Load path: .
65
- MSG
66
61
  "@import templates/basic\n foo" => "Illegal nesting: Nothing may be nested beneath import directives.",
67
62
  "foo\n @import foo.css" => "CSS import directives may only be used at the root of a document.",
68
63
  "@if true\n @import foo" => "Import directives may not be used within control directives or mixins.",
69
64
  "@mixin foo\n @import foo" => "Import directives may not be used within control directives or mixins.",
65
+ "@import foo;" => "Invalid @import: expected end of line, was \";\".",
70
66
  '$foo: "bar" "baz" !' => %Q{Invalid CSS after ""bar" "baz" ": expected expression (e.g. 1px, bold), was "!"},
71
67
  '$foo: "bar" "baz" $' => %Q{Invalid CSS after ""bar" "baz" ": expected expression (e.g. 1px, bold), was "$"},
72
68
  "=foo\n :color red\n.bar\n +bang" => "Undefined mixin 'bang'.",
@@ -263,7 +259,7 @@ SASS
263
259
  end
264
260
 
265
261
  def test_imported_exception
266
- [1, 2, 3, 4].each do |i|
262
+ [1, 2, 3, 4, 5].each do |i|
267
263
  begin
268
264
  Sass::Engine.new("@import bork#{i}", :load_paths => [File.dirname(__FILE__) + '/templates/']).render
269
265
  rescue Sass::SyntaxError => err
@@ -285,7 +281,7 @@ SASS
285
281
  end
286
282
 
287
283
  def test_double_imported_exception
288
- [1, 2, 3, 4].each do |i|
284
+ [1, 2, 3, 4, 5].each do |i|
289
285
  begin
290
286
  Sass::Engine.new("@import nested_bork#{i}", :load_paths => [File.dirname(__FILE__) + '/templates/']).render
291
287
  rescue Sass::SyntaxError => err
@@ -310,6 +306,23 @@ SASS
310
306
  end
311
307
  end
312
308
 
309
+ def test_selector_tracing
310
+ actual_css = render(<<-SCSS, :syntax => :scss, :trace_selectors => true)
311
+ @mixin mixed {
312
+ .mixed { color: red; }
313
+ }
314
+ .context {
315
+ @include mixed;
316
+ }
317
+ SCSS
318
+ assert_equal(<<CSS,actual_css)
319
+ /* on line 2 of test_selector_tracing_inline.scss, in `mixed'
320
+ from line 5 of test_selector_tracing_inline.scss */
321
+ .context .mixed {
322
+ color: red; }
323
+ CSS
324
+ end
325
+
313
326
  def test_mixin_exception
314
327
  render(<<SASS)
315
328
  =error-mixin($a)
@@ -579,12 +592,21 @@ CSS
579
592
  assert File.exists?(sassc_file)
580
593
  end
581
594
 
595
+ def test_nonexistent_import
596
+ assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) do
597
+ File to import not found or unreadable: nonexistent.sass.
598
+ Load path: #{Dir.pwd}
599
+ ERR
600
+ render("@import nonexistent.sass")
601
+ end
602
+ end
603
+
582
604
  def test_nonexistent_extensionless_import
583
605
  assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) do
584
606
  File to import not found or unreadable: nonexistent.
585
- Load path: .
607
+ Load path: #{Dir.pwd}
586
608
  ERR
587
- assert_equal("@import url(nonexistent.css);\n", render("@import nonexistent"))
609
+ render("@import nonexistent")
588
610
  end
589
611
  end
590
612
 
@@ -1181,6 +1203,18 @@ bar
1181
1203
  SASS
1182
1204
  end
1183
1205
 
1206
+ def test_control_directive_in_nested_property
1207
+ assert_equal(<<CSS, render(<<SASS))
1208
+ foo {
1209
+ a-b: c; }
1210
+ CSS
1211
+ foo
1212
+ a:
1213
+ @if true
1214
+ b: c
1215
+ SASS
1216
+ end
1217
+
1184
1218
  def test_interpolation
1185
1219
  assert_equal("a-1 {\n b-2-3: c-3; }\n", render(<<SASS))
1186
1220
  $a: 1
@@ -1548,11 +1582,11 @@ foo
1548
1582
  */
1549
1583
  SASS
1550
1584
  end
1585
+
1551
1586
  def test_loud_comment_in_silent_comment
1552
- assert_equal <<CSS, render(<<SASS, :style => :compressed)
1587
+ silence_warnings {assert_equal <<CSS, render(<<SASS, :style => :compressed)}
1553
1588
  foo{color:blue;/* foo */
1554
1589
  /* bar */
1555
- /* */
1556
1590
  /* bip */
1557
1591
  /* baz */}
1558
1592
  CSS
@@ -1568,8 +1602,7 @@ SASS
1568
1602
 
1569
1603
  def test_loud_comment_is_evaluated
1570
1604
  assert_equal <<CSS, render(<<SASS)
1571
- /*
1572
- * Hue: 327.216deg */
1605
+ /* Hue: 327.216deg */
1573
1606
  CSS
1574
1607
  /*!
1575
1608
  Hue: \#{hue(#f836a0)}
@@ -1772,22 +1805,22 @@ SASS
1772
1805
 
1773
1806
  def test_interpolation_doesnt_deep_unquote_strings
1774
1807
  assert_equal(<<CSS, render(<<SASS))
1775
- .foo- "bar" "baz" {
1776
- a: b; }
1808
+ .foo {
1809
+ a: "bar" "baz"; }
1777
1810
  CSS
1778
- .foo-\#{"bar" "baz"}
1779
- a: b
1811
+ .foo
1812
+ a: \#{"bar" "baz"}
1780
1813
  SASS
1781
1814
  end
1782
1815
 
1783
1816
  def test_warn_directive
1784
1817
  expected_warning = <<EXPECTATION
1785
1818
  WARNING: this is a warning
1786
- on line 4 of test_warn_directive_inline.sass
1819
+ on line 4 of test_warn_directive_inline.sass
1787
1820
 
1788
1821
  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
1822
+ on line 2 of test_warn_directive_inline.sass, in `foo'
1823
+ from line 7 of test_warn_directive_inline.sass
1791
1824
  EXPECTATION
1792
1825
  assert_warning expected_warning do
1793
1826
  assert_equal <<CSS, render(<<SASS)
@@ -1817,15 +1850,15 @@ SASS
1817
1850
  def test_warn_with_imports
1818
1851
  expected_warning = <<WARN
1819
1852
  WARNING: In the main file
1820
- on line 1 of #{File.dirname(__FILE__)}/templates/warn.sass
1853
+ on line 1 of #{File.dirname(__FILE__)}/templates/warn.sass
1821
1854
 
1822
1855
  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
1856
+ on line 1 of #{File.dirname(__FILE__)}/templates/warn_imported.sass
1857
+ from line 2 of #{File.dirname(__FILE__)}/templates/warn.sass
1825
1858
 
1826
1859
  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
1860
+ on line 4 of #{File.dirname(__FILE__)}/templates/warn_imported.sass, in `emits-a-warning'
1861
+ from line 3 of #{File.dirname(__FILE__)}/templates/warn.sass
1829
1862
  WARN
1830
1863
  assert_warning expected_warning do
1831
1864
  renders_correctly "warn", :style => :compact, :load_paths => [File.dirname(__FILE__) + "/templates"]
@@ -2008,6 +2041,31 @@ CSS
2008
2041
 
2009
2042
  # Regression tests
2010
2043
 
2044
+ def test_interpolated_comment_in_mixin
2045
+ assert_equal <<CSS, render(<<SASS)
2046
+ /* color: red */
2047
+ .foo {
2048
+ color: red; }
2049
+
2050
+ /* color: blue */
2051
+ .foo {
2052
+ color: blue; }
2053
+
2054
+ /* color: green */
2055
+ .foo {
2056
+ color: green; }
2057
+ CSS
2058
+ =foo($var)
2059
+ /*! color: \#{$var}
2060
+ .foo
2061
+ color: $var
2062
+
2063
+ +foo(red)
2064
+ +foo(blue)
2065
+ +foo(green)
2066
+ SASS
2067
+ end
2068
+
2011
2069
  def test_parens_in_mixins
2012
2070
  assert_equal(<<CSS, render(<<SASS))
2013
2071
  .foo {
@@ -2148,6 +2206,16 @@ CSS
2148
2206
  SASS
2149
2207
  end
2150
2208
 
2209
+ def test_silent_comment_in_prop_val_after_important
2210
+ assert_equal(<<CSS, render(<<SASS))
2211
+ .advanced {
2212
+ display: none !important; }
2213
+ CSS
2214
+ .advanced
2215
+ display: none !important // yeah, yeah. it's not really a style anyway.
2216
+ SASS
2217
+ end
2218
+
2151
2219
  def test_mixin_with_keyword_args
2152
2220
  assert_equal <<CSS, render(<<SASS)
2153
2221
  .mixed {
@@ -2276,7 +2344,16 @@ SASS
2276
2344
  WARNING:
2277
2345
  On line 1 of 'test_comment_interpolation_warning_inline.sass'
2278
2346
  Comments will evaluate the contents of interpolations (\#{ ... }) in Sass 3.2.
2279
- Please escape the interpolation by adding a backslash before the hash sign.
2347
+ Please escape the interpolation by adding a backslash before the `#`.
2348
+ END
2349
+ end
2350
+
2351
+ def test_loud_silent_comment_warning
2352
+ assert_warning(<<END) {render("//! \#{foo}")}
2353
+ WARNING:
2354
+ On line 1 of 'test_loud_silent_comment_warning_inline.sass'
2355
+ `//` comments will no longer be allowed to use the `!` flag in Sass 3.2.
2356
+ Please change to `/*` comments.
2280
2357
  END
2281
2358
  end
2282
2359
 
@@ -2420,6 +2497,27 @@ SASS
2420
2497
  assert_equal original_filename, importer.engine("imported").options[:original_filename]
2421
2498
  end
2422
2499
 
2500
+ def test_deprecated_PRECISION
2501
+ assert_warning(<<END) {assert_equal 1000.0, Sass::Script::Number::PRECISION}
2502
+ Sass::Script::Number::PRECISION is deprecated and will be removed in a future release. Use Sass::Script::Number.precision_factor instead.
2503
+ END
2504
+ end
2505
+ def test_changing_precision
2506
+ begin
2507
+ Sass::Script::Number.precision = 8
2508
+ assert_equal <<CSS, render(<<SASS)
2509
+ div {
2510
+ maximum: 1.00000001;
2511
+ too-much: 1.0; }
2512
+ CSS
2513
+ div
2514
+ maximum : 1.00000001
2515
+ too-much: 1.000000001
2516
+ SASS
2517
+ ensure
2518
+ Sass::Script::Number.precision = 3
2519
+ end
2520
+ end
2423
2521
 
2424
2522
  private
2425
2523