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
@@ -1,101 +0,0 @@
1
- require 'set'
2
-
3
- module Sass
4
- module Util
5
- # A map from sets to values.
6
- # A value is \{#\[]= set} by providing a set (the "set-set") and a value,
7
- # which is then recorded as corresponding to that set.
8
- # Values are \{#\[] accessed} by providing a set (the "get-set")
9
- # and returning all values that correspond to set-sets
10
- # that are subsets of the get-set.
11
- #
12
- # SubsetMap preserves the order of values as they're inserted.
13
- #
14
- # @example
15
- # ssm = SubsetMap.new
16
- # ssm[Set[1, 2]] = "Foo"
17
- # ssm[Set[2, 3]] = "Bar"
18
- # ssm[Set[1, 2, 3]] = "Baz"
19
- #
20
- # ssm[Set[1, 2, 3]] #=> ["Foo", "Bar", "Baz"]
21
- class SubsetMap
22
- # Creates a new, empty SubsetMap.
23
- def initialize
24
- @hash = {}
25
- @vals = []
26
- end
27
-
28
- # Whether or not this SubsetMap has any key-value pairs.
29
- #
30
- # @return [Boolean]
31
- def empty?
32
- @hash.empty?
33
- end
34
-
35
- # Associates a value with a set.
36
- # When `set` or any of its supersets is accessed,
37
- # `value` will be among the values returned.
38
- #
39
- # Note that if the same `set` is passed to this method multiple times,
40
- # all given `value`s will be associated with that `set`.
41
- #
42
- # This runs in `O(n)` time, where `n` is the size of `set`.
43
- #
44
- # @param set [#to_set] The set to use as the map key. May not be empty.
45
- # @param value [Object] The value to associate with `set`.
46
- # @raise [ArgumentError] If `set` is empty.
47
- def []=(set, value)
48
- raise ArgumentError.new("SubsetMap keys may not be empty.") if set.empty?
49
-
50
- index = @vals.size
51
- @vals << value
52
- set.each do |k|
53
- @hash[k] ||= []
54
- @hash[k] << [set, set.to_set, index]
55
- end
56
- end
57
-
58
- # Returns all values associated with subsets of `set`.
59
- #
60
- # In the worst case, this runs in `O(m*max(n, log m))` time,
61
- # where `n` is the size of `set`
62
- # and `m` is the number of assocations in the map.
63
- # However, unless many keys in the map overlap with `set`,
64
- # `m` will typically be much smaller.
65
- #
66
- # @param set [Set] The set to use as the map key.
67
- # @return [Array<(Object, #to_set)>] An array of pairs,
68
- # where the first value is the value associated with a subset of `set`,
69
- # and the second value is that subset of `set`
70
- # (or whatever `#to_set` object was used to set the value)
71
- # This array is in insertion order.
72
- # @see #[]
73
- def get(set)
74
- res = set.map do |k|
75
- next unless subsets = @hash[k]
76
- subsets.map do |subenum, subset, index|
77
- next unless subset.subset?(set)
78
- [index, subenum]
79
- end
80
- end
81
- res = Sass::Util.flatten(res, 1)
82
- res.compact!
83
- res.uniq!
84
- res.sort!
85
- res.map! {|i, s| [@vals[i], s]}
86
- return res
87
- end
88
-
89
- # Same as \{#get}, but doesn't return the subsets of the argument
90
- # for which values were found.
91
- #
92
- # @param set [Set] The set to use as the map key.
93
- # @return [Array] The array of all values
94
- # associated with subsets of `set`, in insertion order.
95
- # @see #get
96
- def [](set)
97
- get(set).map {|v, _| v}
98
- end
99
- end
100
- end
101
- end
@@ -1,109 +0,0 @@
1
- require 'sass/util'
2
-
3
- module Sass
4
- # Handles Sass version-reporting.
5
- # Sass not only reports the standard three version numbers,
6
- # but its Git revision hash as well,
7
- # if it was installed from Git.
8
- module Version
9
- include Sass::Util
10
-
11
- # Returns a hash representing the version of Sass.
12
- # The `:major`, `:minor`, and `:teeny` keys have their respective numbers as Fixnums.
13
- # The `:name` key has the name of the version.
14
- # The `:string` key contains a human-readable string representation of the version.
15
- # The `:number` key is the major, minor, and teeny keys separated by periods.
16
- # If Sass is checked out from Git, the `:rev` key will have the revision hash.
17
- # For example:
18
- #
19
- # {
20
- # :string => "2.1.0.9616393",
21
- # :rev => "9616393b8924ef36639c7e82aa88a51a24d16949",
22
- # :number => "2.1.0",
23
- # :major => 2, :minor => 1, :teeny => 0
24
- # }
25
- #
26
- # If a prerelease version of Sass is being used,
27
- # the `:string` and `:number` fields will reflect the full version
28
- # (e.g. `"2.2.beta.1"`), and the `:teeny` field will be `-1`.
29
- # A `:prerelease` key will contain the name of the prerelease (e.g. `"beta"`),
30
- # and a `:prerelease_number` key will contain the rerelease number.
31
- # For example:
32
- #
33
- # {
34
- # :string => "3.0.beta.1",
35
- # :number => "3.0.beta.1",
36
- # :major => 3, :minor => 0, :teeny => -1,
37
- # :prerelease => "beta",
38
- # :prerelease_number => 1
39
- # }
40
- #
41
- # @return [{Symbol => String/Fixnum}] The version hash
42
- def version
43
- return @@version if defined?(@@version)
44
-
45
- numbers = File.read(scope('VERSION')).strip.split('.').
46
- map {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
47
- name = File.read(scope('VERSION_NAME')).strip
48
- @@version = {
49
- :major => numbers[0],
50
- :minor => numbers[1],
51
- :teeny => numbers[2],
52
- :name => name
53
- }
54
-
55
- if numbers[3].is_a?(String)
56
- @@version[:teeny] = -1
57
- @@version[:prerelease] = numbers[3]
58
- @@version[:prerelease_number] = numbers[4]
59
- end
60
-
61
- @@version[:number] = numbers.join('.')
62
- @@version[:string] = @@version[:number].dup
63
-
64
- if rev = revision_number
65
- @@version[:rev] = rev
66
- unless rev[0] == ?(
67
- @@version[:string] << "." << rev[0...7]
68
- end
69
- end
70
-
71
- @@version[:string] << " (#{name})"
72
- @@version
73
- end
74
-
75
- private
76
-
77
- def revision_number
78
- if File.exists?(scope('REVISION'))
79
- rev = File.read(scope('REVISION')).strip
80
- return rev unless rev =~ /^([a-f0-9]+|\(.*\))$/ || rev == '(unknown)'
81
- end
82
-
83
- return unless File.exists?(scope('.git/HEAD'))
84
- rev = File.read(scope('.git/HEAD')).strip
85
- return rev unless rev =~ /^ref: (.*)$/
86
-
87
- ref_name = $1
88
- ref_file = scope(".git/#{ref_name}")
89
- info_file = scope(".git/info/refs")
90
- return File.read(ref_file).strip if File.exists?(ref_file)
91
- return unless File.exists?(info_file)
92
- File.open(info_file) do |f|
93
- f.each do |l|
94
- sha, ref = l.strip.split("\t", 2)
95
- next unless ref == ref_name
96
- return sha
97
- end
98
- end
99
- return nil
100
- end
101
- end
102
-
103
- extend Sass::Version
104
-
105
- # A string representing the version of Sass.
106
- # A more fine-grained representation is available from Sass.version.
107
- # @api public
108
- VERSION = version[:string] unless defined?(Sass::VERSION)
109
- end
@@ -1 +0,0 @@
1
- Kernel.load File.join(File.dirname(__FILE__), '..', 'init.rb')
@@ -1,32 +0,0 @@
1
- require 'rubygems'
2
-
3
- # Note that Sass's gem-compilation process requires access to the filesystem.
4
- # This means that it cannot be automatically run by e.g. GitHub's gem system.
5
- # However, a build server automatically packages the master branch
6
- # every time it's pushed to; this is made available as a prerelease gem.
7
- SASS_GEMSPEC = Gem::Specification.new do |spec|
8
- spec.rubyforge_project = 'sass'
9
- spec.name = 'sass'
10
- spec.summary = "A powerful but elegant CSS compiler that makes CSS fun again."
11
- spec.version = File.read(File.dirname(__FILE__) + '/VERSION').strip
12
- spec.authors = ['Nathan Weizenbaum', 'Chris Eppstein', 'Hampton Catlin']
13
- spec.email = 'sass-lang@googlegroups.com'
14
- spec.description = <<-END
15
- Sass makes CSS fun again. Sass is an extension of CSS3, adding
16
- nested rules, variables, mixins, selector inheritance, and more.
17
- It's translated to well-formatted, standard CSS using the
18
- command line tool or a web-framework plugin.
19
- END
20
-
21
- spec.add_development_dependency 'yard', '>= 0.5.3'
22
- spec.add_development_dependency 'maruku', '>= 0.5.9'
23
-
24
- readmes = Dir['*'].reject{ |x| x =~ /(^|[^.a-z])[a-z]+/ || x == "TODO" }
25
- spec.executables = ['sass', 'css2sass', 'sass-convert']
26
- spec.files = Dir['rails/init.rb', 'lib/**/*', 'vendor/**/*',
27
- 'bin/*', 'test/**/*', 'extra/**/*', 'Rakefile', 'init.rb',
28
- '.yardopts'] + readmes
29
- spec.homepage = 'http://sass-lang.com/'
30
- spec.has_rdoc = false
31
- spec.test_files = Dir['test/**/*_test.rb']
32
- end
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../test_helper'
3
- require 'sass/engine'
4
-
5
- class CacheTest < Test::Unit::TestCase
6
- @@cache_dir = "tmp/file_cache"
7
-
8
- def setup
9
- FileUtils.mkdir_p @@cache_dir
10
- end
11
-
12
- def teardown
13
- FileUtils.rm_rf @@cache_dir
14
- end
15
-
16
- def test_file_cache_writes_a_file
17
- file_store = Sass::FileCacheStore.new(@@cache_dir)
18
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
19
- assert File.exists?("#{@@cache_dir}/asdf/foo.scssc")
20
- end
21
-
22
- def test_file_cache_reads_a_file
23
- file_store = Sass::FileCacheStore.new(@@cache_dir)
24
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
25
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
26
- assert File.exists?("#{@@cache_dir}/asdf/foo.scssc")
27
- assert_kind_of Sass::Tree::RootNode, file_store.retrieve("asdf/foo.scssc", "fakesha1")
28
- end
29
-
30
- def test_file_cache_miss_returns_nil
31
- file_store = Sass::FileCacheStore.new(@@cache_dir)
32
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
33
- assert_nil file_store.retrieve("asdf/foo.scssc", "fakesha1")
34
- end
35
-
36
- def test_sha_change_invalidates_cache_and_cleans_up
37
- file_store = Sass::FileCacheStore.new(@@cache_dir)
38
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
39
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
40
- assert File.exists?("#{@@cache_dir}/asdf/foo.scssc")
41
- assert_nil file_store.retrieve("asdf/foo.scssc", "differentsha1")
42
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
43
- end
44
-
45
- def test_version_change_invalidates_cache_and_cleans_up
46
- file_store = Sass::FileCacheStore.new(@@cache_dir)
47
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
48
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
49
- assert File.exists?("#{@@cache_dir}/asdf/foo.scssc")
50
- real_version = Sass::VERSION
51
- begin
52
- Sass::VERSION.replace("a different version")
53
- assert_nil file_store.retrieve("asdf/foo.scssc", "fakesha1")
54
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
55
- ensure
56
- Sass::VERSION.replace(real_version)
57
- end
58
- end
59
-
60
- def test_arbitrary_objects_can_go_into_cache
61
- cache = Sass::InMemoryCacheStore.new
62
- an_object = {:foo => :bar}
63
- cache.store("an_object", "", an_object)
64
- assert_equal an_object, cache.retrieve("an_object", "")
65
- end
66
-
67
- private
68
- def root_node
69
- Sass::Engine.new(<<-SCSS, :syntax => :scss).to_tree
70
- @mixin color($c) { color: $c}
71
- div { @include color(red); }
72
- SCSS
73
- end
74
- end
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../test_helper'
3
- require 'sass/callbacks'
4
-
5
- class CallerBack
6
- extend Sass::Callbacks
7
- define_callback :foo
8
- define_callback :bar
9
-
10
- def do_foo
11
- run_foo
12
- end
13
-
14
- def do_bar
15
- run_bar 12
16
- end
17
- end
18
-
19
- module ClassLevelCallerBack
20
- extend Sass::Callbacks
21
- define_callback :foo
22
- extend self
23
-
24
- def do_foo
25
- run_foo
26
- end
27
- end
28
-
29
- class SassCallbacksTest < Test::Unit::TestCase
30
- def test_simple_callback
31
- cb = CallerBack.new
32
- there = false
33
- cb.on_foo {there = true}
34
- cb.do_foo
35
- assert there, "Expected callback to be called."
36
- end
37
-
38
- def test_multiple_callbacks
39
- cb = CallerBack.new
40
- str = ""
41
- cb.on_foo {str += "first"}
42
- cb.on_foo {str += " second"}
43
- cb.do_foo
44
- assert_equal "first second", str
45
- end
46
-
47
- def test_callback_with_arg
48
- cb = CallerBack.new
49
- val = nil
50
- cb.on_bar {|a| val = a}
51
- cb.do_bar
52
- assert_equal 12, val
53
- end
54
-
55
- def test_class_level_callback
56
- there = false
57
- ClassLevelCallerBack.on_foo {there = true}
58
- ClassLevelCallerBack.do_foo
59
- assert there, "Expected callback to be called."
60
- end
61
- end
@@ -1,1210 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../test_helper'
3
-
4
- class ConversionTest < Test::Unit::TestCase
5
- def test_basic
6
- assert_renders <<SASS, <<SCSS
7
- foo bar
8
- baz: bang
9
- bip: bop
10
- SASS
11
- foo bar {
12
- baz: bang;
13
- bip: bop; }
14
- SCSS
15
- assert_renders <<SASS, <<SCSS, :old => true
16
- foo bar
17
- :baz bang
18
- :bip bop
19
- SASS
20
- foo bar {
21
- baz: bang;
22
- bip: bop; }
23
- SCSS
24
- end
25
-
26
- def test_empty_selector
27
- assert_renders "foo bar", "foo bar {}"
28
- end
29
-
30
- def test_empty_directive
31
- assert_scss_to_sass "@media screen", "@media screen {}"
32
- assert_scss_to_scss "@media screen {}"
33
- end
34
-
35
- def test_empty_control_directive
36
- assert_renders "@if false", "@if false {}"
37
- end
38
-
39
- def test_nesting
40
- assert_renders <<SASS, <<SCSS
41
- foo bar
42
- baz bang
43
- baz: bang
44
- bip: bop
45
- blat: boo
46
- SASS
47
- foo bar {
48
- baz bang {
49
- baz: bang;
50
- bip: bop; }
51
- blat: boo; }
52
- SCSS
53
- end
54
-
55
- def test_nesting_with_parent_ref
56
- assert_renders <<SASS, <<SCSS
57
- foo bar
58
- &:hover
59
- baz: bang
60
- SASS
61
- foo bar {
62
- &:hover {
63
- baz: bang; } }
64
- SCSS
65
- end
66
-
67
- def test_selector_interpolation
68
- assert_renders <<SASS, <<SCSS
69
- foo \#{$bar + "baz"}.bip
70
- baz: bang
71
- SASS
72
- foo \#{$bar + "baz"}.bip {
73
- baz: bang; }
74
- SCSS
75
- end
76
-
77
- def test_multiline_selector_with_commas
78
- assert_renders <<SASS, <<SCSS
79
- foo bar,
80
- baz bang
81
- baz: bang
82
- SASS
83
- foo bar,
84
- baz bang {
85
- baz: bang; }
86
- SCSS
87
-
88
- assert_renders <<SASS, <<SCSS
89
- blat
90
- foo bar,
91
- baz bang
92
- baz: bang
93
- SASS
94
- blat {
95
- foo bar,
96
- baz bang {
97
- baz: bang; } }
98
- SCSS
99
- end
100
-
101
- def test_multiline_selector_without_commas
102
- assert_scss_to_sass <<SASS, <<SCSS
103
- foo bar baz bang
104
- baz: bang
105
- SASS
106
- foo bar
107
- baz bang {
108
- baz: bang; }
109
- SCSS
110
-
111
- assert_scss_to_scss <<SCSS
112
- foo bar
113
- baz bang {
114
- baz: bang; }
115
- SCSS
116
- end
117
-
118
- def test_escaped_selector
119
- assert_renders <<SASS, <<SCSS
120
- foo bar
121
- \\:hover
122
- baz: bang
123
- SASS
124
- foo bar {
125
- :hover {
126
- baz: bang; } }
127
- SCSS
128
- end
129
-
130
- def test_property_name_interpolation
131
- assert_renders <<SASS, <<SCSS
132
- foo bar
133
- baz\#{$bang}bip\#{$bop}: 12
134
- SASS
135
- foo bar {
136
- baz\#{$bang}bip\#{$bop}: 12; }
137
- SCSS
138
- end
139
-
140
- def test_property_name_interpolation
141
- assert_renders <<SASS, <<SCSS
142
- foo bar
143
- baz\#{$bang}bip\#{$bop}: 12
144
- SASS
145
- foo bar {
146
- baz\#{$bang}bip\#{$bop}: 12; }
147
- SCSS
148
- end
149
-
150
- def test_property_value_interpolation
151
- assert_renders <<SASS, <<SCSS
152
- foo bar
153
- baz: 12 \#{$bang} bip \#{"bop"} blat
154
- SASS
155
- foo bar {
156
- baz: 12 \#{$bang} bip \#{"bop"} blat; }
157
- SCSS
158
- end
159
-
160
- def test_dynamic_properties
161
- assert_renders <<SASS, <<SCSS
162
- foo bar
163
- baz: 12 $bang "bip"
164
- SASS
165
- foo bar {
166
- baz: 12 $bang "bip"; }
167
- SCSS
168
-
169
- assert_sass_to_scss <<SCSS, <<SASS
170
- foo bar {
171
- baz: 12 $bang bip; }
172
- SCSS
173
- foo bar
174
- baz= 12 $bang "bip"
175
- SASS
176
- end
177
-
178
- def test_dynamic_properties_with_old
179
- assert_renders <<SASS, <<SCSS, :old => true
180
- foo bar
181
- :baz 12 $bang "bip"
182
- SASS
183
- foo bar {
184
- baz: 12 $bang "bip"; }
185
- SCSS
186
-
187
- assert_sass_to_scss <<SCSS, <<SASS, :old => true
188
- foo bar {
189
- baz: 12 $bang bip; }
190
- SCSS
191
- foo bar
192
- :baz= 12 $bang "bip"
193
- SASS
194
- end
195
-
196
- def test_multiline_properties
197
- assert_scss_to_sass <<SASS, <<SCSS
198
- foo bar
199
- baz: bip bam boon
200
- SASS
201
- foo bar {
202
- baz:
203
- bip
204
- bam
205
- boon; }
206
- SCSS
207
-
208
- assert_scss_to_scss <<OUT, <<IN
209
- foo bar {
210
- baz: bip bam boon; }
211
- OUT
212
- foo bar {
213
- baz:
214
- bip
215
- bam
216
- boon; }
217
- IN
218
- end
219
-
220
- def test_multiline_dynamic_properties
221
- assert_scss_to_sass <<SASS, <<SCSS
222
- foo bar
223
- baz: $bip "bam" 12px
224
- SASS
225
- foo bar {
226
- baz:
227
- $bip
228
- "bam"
229
- 12px; }
230
- SCSS
231
-
232
- assert_scss_to_scss <<OUT, <<IN
233
- foo bar {
234
- baz: $bip "bam" 12px; }
235
- OUT
236
- foo bar {
237
- baz:
238
- $bip
239
- "bam"
240
- 12px; }
241
- IN
242
- end
243
-
244
- def test_silent_comments
245
- assert_renders <<SASS, <<SCSS
246
- // foo
247
-
248
- // bar
249
-
250
- // baz
251
-
252
- foo bar
253
- a: b
254
- SASS
255
- // foo
256
-
257
- // bar
258
-
259
- // baz
260
-
261
- foo bar {
262
- a: b; }
263
- SCSS
264
-
265
- assert_renders <<SASS, <<SCSS
266
- // foo
267
- // bar
268
- // baz
269
- // bang
270
-
271
- foo bar
272
- a: b
273
- SASS
274
- // foo
275
- // bar
276
- // baz
277
- // bang
278
-
279
- foo bar {
280
- a: b; }
281
- SCSS
282
-
283
- assert_sass_to_scss <<SCSS, <<SASS
284
- // foo
285
- // bar
286
- // baz
287
- // bang
288
-
289
- foo bar {
290
- a: b; }
291
- SCSS
292
- // foo
293
- // bar
294
- // baz
295
- // bang
296
-
297
- foo bar
298
- a: b
299
- SASS
300
- end
301
-
302
- def test_nested_silent_comments
303
- assert_renders <<SASS, <<SCSS
304
- foo
305
- bar: baz
306
- // bip bop
307
- // beep boop
308
- bang: bizz
309
- // bubble bubble
310
- // toil trouble
311
- SASS
312
- foo {
313
- bar: baz;
314
- // bip bop
315
- // beep boop
316
- bang: bizz;
317
- // bubble bubble
318
- // toil trouble
319
- }
320
- SCSS
321
-
322
- assert_sass_to_scss <<SCSS, <<SASS
323
- foo {
324
- bar: baz;
325
- // bip bop
326
- // beep boop
327
- // bap blimp
328
- bang: bizz;
329
- // bubble bubble
330
- // toil trouble
331
- // gorp
332
- }
333
- SCSS
334
- foo
335
- bar: baz
336
- // bip bop
337
- beep boop
338
- bap blimp
339
- bang: bizz
340
- // bubble bubble
341
- toil trouble
342
- gorp
343
- SASS
344
- end
345
-
346
- def test_loud_comments
347
- assert_renders <<SASS, <<SCSS
348
- /* foo
349
-
350
- /* bar
351
-
352
- /* baz
353
-
354
- foo bar
355
- a: b
356
- SASS
357
- /* foo */
358
-
359
- /* bar */
360
-
361
- /* baz */
362
-
363
- foo bar {
364
- a: b; }
365
- SCSS
366
-
367
- assert_scss_to_sass <<SASS, <<SCSS
368
- /* foo
369
- * bar
370
- * baz
371
- * bang
372
-
373
- foo bar
374
- a: b
375
- SASS
376
- /* foo
377
- bar
378
- baz
379
- bang */
380
-
381
- foo bar {
382
- a: b; }
383
- SCSS
384
-
385
- assert_scss_to_scss <<SCSS
386
- /* foo
387
- bar
388
- baz
389
- bang */
390
-
391
- foo bar {
392
- a: b; }
393
- SCSS
394
-
395
- assert_renders <<SASS, <<SCSS
396
- /* foo
397
- * bar
398
- * baz
399
- * bang
400
-
401
- foo bar
402
- a: b
403
- SASS
404
- /* foo
405
- * bar
406
- * baz
407
- * bang */
408
-
409
- foo bar {
410
- a: b; }
411
- SCSS
412
- end
413
-
414
- def test_nested_loud_comments
415
- assert_renders <<SASS, <<SCSS
416
- foo
417
- bar: baz
418
- /* bip bop
419
- * beep boop
420
- bang: bizz
421
- /* bubble bubble
422
- * toil trouble
423
- SASS
424
- foo {
425
- bar: baz;
426
- /* bip bop
427
- * beep boop */
428
- bang: bizz;
429
- /* bubble bubble
430
- * toil trouble */ }
431
- SCSS
432
-
433
- assert_sass_to_scss <<SCSS, <<SASS
434
- foo {
435
- bar: baz;
436
- /* bip bop
437
- * beep boop
438
- * bap blimp */
439
- bang: bizz;
440
- /* bubble bubble
441
- * toil trouble
442
- * gorp */ }
443
- SCSS
444
- foo
445
- bar: baz
446
- /* bip bop
447
- beep boop
448
- bap blimp
449
- bang: bizz
450
- /* bubble bubble
451
- toil trouble
452
- gorp
453
- SASS
454
- end
455
-
456
- def test_loud_comments_with_weird_indentation
457
- assert_scss_to_sass <<SASS, <<SCSS
458
- foo
459
- /* foo
460
- * bar
461
- * baz
462
- a: b
463
- SASS
464
- foo {
465
- /* foo
466
- bar
467
- baz */
468
- a: b; }
469
- SCSS
470
-
471
- assert_sass_to_scss <<SCSS, <<SASS
472
- foo {
473
- /* foo
474
- * bar
475
- * baz */
476
- a: b; }
477
- SCSS
478
- foo
479
- /* foo
480
- bar
481
- baz
482
- a: b
483
- SASS
484
- end
485
-
486
- def test_immediately_preceding_comments
487
- assert_renders <<SASS, <<SCSS
488
- /* Foo
489
- * Bar
490
- * Baz
491
- .foo#bar
492
- a: b
493
- SASS
494
- /* Foo
495
- * Bar
496
- * Baz */
497
- .foo#bar {
498
- a: b; }
499
- SCSS
500
-
501
- assert_renders <<SASS, <<SCSS
502
- // Foo
503
- // Bar
504
- // Baz
505
- =foo
506
- a: b
507
- SASS
508
- // Foo
509
- // Bar
510
- // Baz
511
- @mixin foo {
512
- a: b; }
513
- SCSS
514
- end
515
-
516
- def test_debug
517
- assert_renders <<SASS, <<SCSS
518
- foo
519
- @debug 12px
520
- bar: baz
521
- SASS
522
- foo {
523
- @debug 12px;
524
- bar: baz; }
525
- SCSS
526
- end
527
-
528
- def test_directive_without_children
529
- assert_renders <<SASS, <<SCSS
530
- foo
531
- @foo #bar "baz"
532
- bar: baz
533
- SASS
534
- foo {
535
- @foo #bar "baz";
536
- bar: baz; }
537
- SCSS
538
- end
539
-
540
- def test_directive_with_prop_children
541
- assert_renders <<SASS, <<SCSS
542
- foo
543
- @foo #bar "baz"
544
- a: b
545
- c: d
546
-
547
- bar: baz
548
- SASS
549
- foo {
550
- @foo #bar "baz" {
551
- a: b;
552
- c: d; }
553
-
554
- bar: baz; }
555
- SCSS
556
- end
557
-
558
- def test_directive_with_rule_children
559
- assert_renders <<SASS, <<SCSS
560
- foo
561
- @foo #bar "baz"
562
- #blat
563
- a: b
564
- .bang
565
- c: d
566
- e: f
567
-
568
- bar: baz
569
- SASS
570
- foo {
571
- @foo #bar "baz" {
572
- #blat {
573
- a: b; }
574
- .bang {
575
- c: d;
576
- e: f; } }
577
-
578
- bar: baz; }
579
- SCSS
580
- end
581
-
582
- def test_directive_with_rule_and_prop_children
583
- assert_renders <<SASS, <<SCSS
584
- foo
585
- @foo #bar "baz"
586
- g: h
587
- #blat
588
- a: b
589
- .bang
590
- c: d
591
- e: f
592
- i: j
593
-
594
- bar: baz
595
- SASS
596
- foo {
597
- @foo #bar "baz" {
598
- g: h;
599
- #blat {
600
- a: b; }
601
- .bang {
602
- c: d;
603
- e: f; }
604
- i: j; }
605
-
606
- bar: baz; }
607
- SCSS
608
- end
609
-
610
- def test_for
611
- assert_renders <<SASS, <<SCSS
612
- foo
613
- @for $a from $b to $c
614
- a: b
615
- @for $c from 1 to 16
616
- d: e
617
- f: g
618
- SASS
619
- foo {
620
- @for $a from $b to $c {
621
- a: b; }
622
- @for $c from 1 to 16 {
623
- d: e;
624
- f: g; } }
625
- SCSS
626
- end
627
-
628
- def test_while
629
- assert_renders <<SASS, <<SCSS
630
- foo
631
- @while flaz($a + $b)
632
- a: b
633
- @while 1
634
- d: e
635
- f: g
636
- SASS
637
- foo {
638
- @while flaz($a + $b) {
639
- a: b; }
640
- @while 1 {
641
- d: e;
642
- f: g; } }
643
- SCSS
644
- end
645
-
646
- def test_if
647
- assert_renders <<SASS, <<SCSS
648
- foo
649
- @if $foo or $bar
650
- a: b
651
- @if $baz
652
- d: e
653
- @else if $bang
654
- f: g
655
- @else
656
- h: i
657
- SASS
658
- foo {
659
- @if $foo or $bar {
660
- a: b; }
661
- @if $baz {
662
- d: e; }
663
- @else if $bang {
664
- f: g; }
665
- @else {
666
- h: i; } }
667
- SCSS
668
- end
669
-
670
- def test_import
671
- assert_renders <<SASS, <<SCSS
672
- @import foo
673
-
674
- @import url(bar.css)
675
-
676
- foo
677
- bar: baz
678
- SASS
679
- @import "foo";
680
-
681
- @import url(bar.css);
682
-
683
- foo {
684
- bar: baz; }
685
- SCSS
686
-
687
- assert_renders <<SASS, <<SCSS
688
- @import foo.css
689
-
690
- @import url(bar.css)
691
-
692
- foo
693
- bar: baz
694
- SASS
695
- @import "foo.css";
696
-
697
- @import url(bar.css);
698
-
699
- foo {
700
- bar: baz; }
701
- SCSS
702
- end
703
-
704
- def test_import_as_directive_in_sass
705
- assert_equal "@import foo.css\n", to_sass('@import "foo.css"')
706
- end
707
-
708
- def test_import_as_directive_in_scss
709
- assert_renders <<SASS, <<SCSS
710
- @import "foo.css" print
711
- SASS
712
- @import "foo.css" print;
713
- SCSS
714
-
715
- assert_renders <<SASS, <<SCSS
716
- @import url(foo.css) screen, print
717
- SASS
718
- @import url(foo.css) screen, print;
719
- SCSS
720
- end
721
-
722
- def test_adjacent_imports
723
- assert_renders <<SASS, <<SCSS
724
- @import foo.sass
725
- @import bar.scss
726
- @import baz
727
- SASS
728
- @import "foo.sass";
729
- @import "bar.scss";
730
- @import "baz";
731
- SCSS
732
- end
733
-
734
- def test_non_adjacent_imports
735
- assert_renders <<SASS, <<SCSS
736
- @import foo.sass
737
-
738
- @import bar.scss
739
-
740
- @import baz
741
- SASS
742
- @import "foo.sass";
743
-
744
- @import "bar.scss";
745
-
746
- @import "baz";
747
- SCSS
748
- end
749
-
750
- def test_extend
751
- assert_renders <<SASS, <<SCSS
752
- .foo
753
- @extend .bar
754
- @extend .baz:bang
755
- SASS
756
- .foo {
757
- @extend .bar;
758
- @extend .baz:bang; }
759
- SCSS
760
- end
761
-
762
- def test_argless_mixin_definition
763
- assert_renders <<SASS, <<SCSS
764
- =foo-bar
765
- baz
766
- a: b
767
- SASS
768
- @mixin foo-bar {
769
- baz {
770
- a: b; } }
771
- SCSS
772
-
773
- assert_scss_to_sass <<SASS, <<SCSS
774
- =foo-bar
775
- baz
776
- a: b
777
- SASS
778
- @mixin foo-bar() {
779
- baz {
780
- a: b; } }
781
- SCSS
782
-
783
- assert_sass_to_scss <<SCSS, <<SASS
784
- @mixin foo-bar {
785
- baz {
786
- a: b; } }
787
- SCSS
788
- =foo-bar()
789
- baz
790
- a: b
791
- SASS
792
- end
793
-
794
- def test_mixin_definition_without_defaults
795
- assert_renders <<SASS, <<SCSS
796
- =foo-bar($baz, $bang)
797
- baz
798
- a: $baz $bang
799
- SASS
800
- @mixin foo-bar($baz, $bang) {
801
- baz {
802
- a: $baz $bang; } }
803
- SCSS
804
- end
805
-
806
- def test_mixin_definition_with_defaults
807
- assert_renders <<SASS, <<SCSS
808
- =foo-bar($baz, $bang: 12px)
809
- baz
810
- a: $baz $bang
811
- SASS
812
- @mixin foo-bar($baz, $bang: 12px) {
813
- baz {
814
- a: $baz $bang; } }
815
- SCSS
816
-
817
- assert_scss_to_sass <<SASS, <<SCSS
818
- =foo-bar($baz, $bang: foo)
819
- baz
820
- a: $baz $bang
821
- SASS
822
- @mixin foo-bar($baz, $bang = "foo") {
823
- baz {
824
- a: $baz $bang; } }
825
- SCSS
826
-
827
- assert_sass_to_scss <<SCSS, <<SASS
828
- @mixin foo-bar($baz, $bang: foo) {
829
- baz {
830
- a: $baz $bang; } }
831
- SCSS
832
- =foo-bar($baz, $bang = "foo")
833
- baz
834
- a: $baz $bang
835
- SASS
836
- end
837
-
838
- def test_argless_mixin_include
839
- assert_renders <<SASS, <<SCSS
840
- foo
841
- +foo-bar
842
- a: blip
843
- SASS
844
- foo {
845
- @include foo-bar;
846
- a: blip; }
847
- SCSS
848
- end
849
-
850
- def test_mixin_include
851
- assert_renders <<SASS, <<SCSS
852
- foo
853
- +foo-bar(12px, "blaz")
854
- a: blip
855
- SASS
856
- foo {
857
- @include foo-bar(12px, "blaz");
858
- a: blip; }
859
- SCSS
860
- end
861
-
862
- def test_variable_definition
863
- assert_renders <<SASS, <<SCSS
864
- $var1: 12px + 15px
865
-
866
- foo
867
- $var2: flaz(#abcdef)
868
- val: $var1 $var2
869
- SASS
870
- $var1: 12px + 15px;
871
-
872
- foo {
873
- $var2: flaz(#abcdef);
874
- val: $var1 $var2; }
875
- SCSS
876
-
877
- assert_sass_to_scss '$var: 12px $bar baz;', '$var = 12px $bar "baz"'
878
- end
879
-
880
- def test_guarded_variable_definition
881
- assert_renders <<SASS, <<SCSS
882
- $var1: 12px + 15px !default
883
-
884
- foo
885
- $var2: flaz(#abcdef) !default
886
- val: $var1 $var2
887
- SASS
888
- $var1: 12px + 15px !default;
889
-
890
- foo {
891
- $var2: flaz(#abcdef) !default;
892
- val: $var1 $var2; }
893
- SCSS
894
-
895
- assert_sass_to_scss '$var: 12px $bar baz !default;', '$var ||= 12px $bar "baz"'
896
- end
897
-
898
- def test_multiple_variable_definitions
899
- assert_renders <<SASS, <<SCSS
900
- $var1: foo
901
- $var2: bar
902
- $var3: baz
903
-
904
- $var4: bip
905
- $var5: bap
906
- SASS
907
- $var1: foo;
908
- $var2: bar;
909
- $var3: baz;
910
-
911
- $var4: bip;
912
- $var5: bap;
913
- SCSS
914
- end
915
-
916
- def test_division_asserted_with_parens
917
- assert_renders <<SASS, <<SCSS
918
- foo
919
- a: (1px / 2px)
920
- SASS
921
- foo {
922
- a: (1px / 2px); }
923
- SCSS
924
- end
925
-
926
- def test_division_not_asserted_when_unnecessary
927
- assert_renders <<SASS, <<SCSS
928
- $var: 1px / 2px
929
-
930
- foo
931
- a: $var
932
- SASS
933
- $var: 1px / 2px;
934
-
935
- foo {
936
- a: $var; }
937
- SCSS
938
-
939
- assert_renders <<SASS, <<SCSS
940
- $var: 1px
941
-
942
- foo
943
- a: $var / 2px
944
- SASS
945
- $var: 1px;
946
-
947
- foo {
948
- a: $var / 2px; }
949
- SCSS
950
-
951
- assert_renders <<SASS, <<SCSS
952
- foo
953
- a: 1 + 1px / 2px
954
- SASS
955
- foo {
956
- a: 1 + 1px / 2px; }
957
- SCSS
958
- end
959
-
960
- def test_literal_slash
961
- assert_renders <<SASS, <<SCSS
962
- foo
963
- a: 1px / 2px
964
- SASS
965
- foo {
966
- a: 1px / 2px; }
967
- SCSS
968
- end
969
-
970
- # Hacks
971
-
972
- def test_declaration_hacks
973
- assert_renders <<SASS, <<SCSS
974
- foo
975
- _name: val
976
- *name: val
977
- #name: val
978
- .name: val
979
- name/**/: val
980
- name/*\\**/: val
981
- name: val
982
- SASS
983
- foo {
984
- _name: val;
985
- *name: val;
986
- #name: val;
987
- .name: val;
988
- name/**/: val;
989
- name/*\\**/: val;
990
- name: val; }
991
- SCSS
992
- end
993
-
994
- def test_old_declaration_hacks
995
- assert_renders <<SASS, <<SCSS, :old => true
996
- foo
997
- :_name val
998
- :*name val
999
- :#name val
1000
- :.name val
1001
- :name val
1002
- SASS
1003
- foo {
1004
- _name: val;
1005
- *name: val;
1006
- #name: val;
1007
- .name: val;
1008
- name: val; }
1009
- SCSS
1010
- end
1011
-
1012
- def test_selector_hacks
1013
- assert_selector_renders = lambda do |s|
1014
- assert_renders <<SASS, <<SCSS
1015
- #{s}
1016
- a: b
1017
- SASS
1018
- #{s} {
1019
- a: b; }
1020
- SCSS
1021
- end
1022
-
1023
- assert_selector_renders['> E']
1024
- assert_selector_renders['+ E']
1025
- assert_selector_renders['~ E']
1026
- assert_selector_renders['> > E']
1027
-
1028
- assert_selector_renders['E*']
1029
- assert_selector_renders['E*.foo']
1030
- assert_selector_renders['E*:hover']
1031
- end
1032
-
1033
- def test_disallowed_colon_hack
1034
- assert_raise_message(Sass::SyntaxError, 'The ":name: val" hack is not allowed in the Sass indented syntax') do
1035
- to_sass("foo {:name: val;}", :syntax => :scss)
1036
- end
1037
- end
1038
-
1039
- # Sass 3 Deprecation conversions
1040
-
1041
- def test_simple_quoted_strings_unquoted_with_equals
1042
- assert_sass_to_scss '$var: 1px foo + bar baz;', '!var = 1px "foo" + "bar" baz'
1043
- assert_sass_to_scss '$var: -foo-bar;', '!var = "-foo-bar"'
1044
- end
1045
-
1046
- def test_complex_quoted_strings_explicitly_unquoted_with_equals
1047
- assert_sass_to_scss '$var: 1px unquote("foo + bar") baz;', '!var = 1px "foo + bar" baz'
1048
- assert_sass_to_scss "$var: unquote('foo\"bar');", '!var = "foo\"bar"'
1049
- end
1050
-
1051
- def test_division_asserted_with_equals
1052
- assert_sass_to_scss <<SCSS, <<SASS
1053
- foo {
1054
- a: (1px / 2px); }
1055
- SCSS
1056
- foo
1057
- a = 1px / 2px
1058
- SASS
1059
- end
1060
-
1061
- def test_division_not_asserted_with_equals_when_unnecessary
1062
- assert_sass_to_scss <<SCSS, <<SASS
1063
- $var: 1px / 2px;
1064
-
1065
- foo {
1066
- a: $var; }
1067
- SCSS
1068
- !var = 1px / 2px
1069
-
1070
- foo
1071
- a = !var
1072
- SASS
1073
-
1074
- assert_sass_to_scss <<SCSS, <<SASS
1075
- $var: 1px;
1076
-
1077
- foo {
1078
- a: $var / 2px; }
1079
- SCSS
1080
- !var = 1px
1081
-
1082
- foo
1083
- a = !var / 2px
1084
- SASS
1085
-
1086
- assert_sass_to_scss <<SCSS, <<SASS
1087
- foo {
1088
- a: 1 + 1px / 2px; }
1089
- SCSS
1090
- foo
1091
- a = 1 + 1px / 2px
1092
- SASS
1093
- end
1094
-
1095
- def test_nested_properties
1096
- assert_renders <<SASS, <<SCSS
1097
- div
1098
- before: before
1099
- background:
1100
- color: blue
1101
- repeat: no-repeat
1102
- after: after
1103
- SASS
1104
- div {
1105
- before: before;
1106
- background: {
1107
- color: blue;
1108
- repeat: no-repeat; };
1109
- after: after; }
1110
-
1111
- SCSS
1112
- end
1113
-
1114
- def test_dasherize
1115
- assert_sass_to_scss(<<SCSS, <<SASS, :dasherize => true)
1116
- @mixin under-scored-mixin($under-scored-arg: $under-scored-default) {
1117
- bar: $under-scored-arg; }
1118
-
1119
- div {
1120
- foo: under-scored-fn($under-scored-var + "before\#{$another-under-scored-var}after");
1121
- @include under-scored-mixin($passed-arg);
1122
- selector-\#{$under-scored-interp}: bold; }
1123
-
1124
- @if $under-scored {
1125
- @for $for-var from $from-var to $to-var {
1126
- @while $while-var == true {
1127
- $while-var: false; } } }
1128
- SCSS
1129
- =under_scored_mixin($under_scored_arg: $under_scored_default)
1130
- bar: $under_scored_arg
1131
- div
1132
- foo: under_scored_fn($under_scored_var + "before\#{$another_under_scored_var}after")
1133
- +under_scored_mixin($passed_arg)
1134
- selector-\#{$under_scored_interp}: bold
1135
- @if $under_scored
1136
- @for $for_var from $from_var to $to_var
1137
- @while $while_var == true
1138
- $while_var : false
1139
- SASS
1140
- end
1141
-
1142
- def test_sass2_var_in_property_interpolation
1143
- assert_sass_to_scss <<SCSS, <<SASS
1144
- foo {
1145
- a: b \#{$c} d; }
1146
- SCSS
1147
- foo
1148
- a: b \#{!c} d
1149
- SASS
1150
- end
1151
-
1152
- def test_sass2_var_in_selector_interpolation
1153
- assert_sass_to_scss <<SCSS, <<SASS
1154
- foo-\#{$c} {
1155
- a: b; }
1156
- SCSS
1157
- foo-\#{!c}
1158
- a: b
1159
- SASS
1160
- end
1161
-
1162
- private
1163
-
1164
- def assert_sass_to_sass(sass, options = {})
1165
- assert_equal(sass.rstrip, to_sass(sass, options).rstrip,
1166
- "Expected Sass to transform to itself")
1167
- end
1168
-
1169
- def assert_scss_to_sass(sass, scss, options = {})
1170
- assert_equal(sass.rstrip, to_sass(scss, options.merge(:syntax => :scss)).rstrip,
1171
- "Expected SCSS to transform to Sass")
1172
- end
1173
-
1174
- def assert_scss_to_scss(scss, in_scss = nil, options = nil)
1175
- if in_scss.is_a?(Hash)
1176
- options = in_scss
1177
- in_scss = nil
1178
- end
1179
-
1180
- in_scss ||= scss
1181
- options ||= {}
1182
-
1183
- assert_equal(scss.rstrip, to_scss(in_scss, options.merge(:syntax => :scss)).rstrip,
1184
- "Expected SCSS to transform to #{scss == in_scss ? 'itself' : 'SCSS'}k")
1185
- end
1186
-
1187
- def assert_sass_to_scss(scss, sass, options = {})
1188
- assert_equal(scss.rstrip, to_scss(sass, options).rstrip,
1189
- "Expected Sass to transform to SCSS")
1190
- end
1191
-
1192
- def assert_renders(sass, scss, options = {})
1193
- assert_sass_to_sass(sass, options)
1194
- assert_scss_to_sass(sass, scss, options)
1195
- assert_scss_to_scss(scss, options)
1196
- assert_sass_to_scss(scss, sass, options)
1197
- end
1198
-
1199
- def to_sass(scss, options = {})
1200
- Sass::Util.silence_sass_warnings do
1201
- Sass::Engine.new(scss, options).to_tree.to_sass(options)
1202
- end
1203
- end
1204
-
1205
- def to_scss(sass, options = {})
1206
- Sass::Util.silence_sass_warnings do
1207
- Sass::Engine.new(sass, options).to_tree.to_scss(options)
1208
- end
1209
- end
1210
- end