sass 3.6.0 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +1 -1
- data/README.md +10 -0
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/lib/sass/script/css_parser.rb +4 -1
- data/lib/sass/script/functions.rb +15 -25
- data/lib/sass/script/lexer.rb +45 -7
- data/lib/sass/script/parser.rb +259 -93
- data/lib/sass/scss/parser.rb +43 -16
- data/lib/sass/scss/static_parser.rb +15 -15
- data/lib/sass/util.rb +31 -0
- metadata +8 -156
- data/Rakefile +0 -364
- data/test/sass-spec.yml +0 -3
- data/test/sass/cache_test.rb +0 -130
- data/test/sass/callbacks_test.rb +0 -60
- data/test/sass/compiler_test.rb +0 -225
- data/test/sass/conversion_test.rb +0 -2138
- data/test/sass/css2sass_test.rb +0 -523
- data/test/sass/css_variable_test.rb +0 -237
- data/test/sass/data/hsl-rgb.txt +0 -319
- data/test/sass/encoding_test.rb +0 -188
- data/test/sass/engine_test.rb +0 -3499
- data/test/sass/exec_test.rb +0 -95
- data/test/sass/extend_test.rb +0 -1679
- data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
- data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
- data/test/sass/functions_test.rb +0 -2021
- data/test/sass/importer_test.rb +0 -420
- data/test/sass/logger_test.rb +0 -57
- data/test/sass/mock_importer.rb +0 -49
- data/test/sass/more_results/more1.css +0 -9
- data/test/sass/more_results/more1_with_line_comments.css +0 -26
- data/test/sass/more_results/more_import.css +0 -29
- data/test/sass/more_templates/_more_partial.sass +0 -2
- data/test/sass/more_templates/more1.sass +0 -23
- data/test/sass/more_templates/more_import.sass +0 -11
- data/test/sass/plugin_test.rb +0 -552
- data/test/sass/results/alt.css +0 -4
- data/test/sass/results/basic.css +0 -9
- data/test/sass/results/cached_import_option.css +0 -3
- data/test/sass/results/compact.css +0 -5
- data/test/sass/results/complex.css +0 -86
- data/test/sass/results/compressed.css +0 -1
- data/test/sass/results/expanded.css +0 -19
- data/test/sass/results/filename_fn.css +0 -3
- data/test/sass/results/if.css +0 -3
- data/test/sass/results/import.css +0 -31
- data/test/sass/results/import_charset.css +0 -5
- data/test/sass/results/import_charset_ibm866.css +0 -5
- data/test/sass/results/import_content.css +0 -1
- data/test/sass/results/line_numbers.css +0 -49
- data/test/sass/results/mixins.css +0 -95
- data/test/sass/results/multiline.css +0 -24
- data/test/sass/results/nested.css +0 -22
- data/test/sass/results/options.css +0 -1
- data/test/sass/results/parent_ref.css +0 -13
- data/test/sass/results/script.css +0 -16
- data/test/sass/results/scss_import.css +0 -31
- data/test/sass/results/scss_importee.css +0 -2
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
- data/test/sass/results/subdir/subdir.css +0 -3
- data/test/sass/results/units.css +0 -11
- data/test/sass/results/warn.css +0 -0
- data/test/sass/results/warn_imported.css +0 -0
- data/test/sass/script_conversion_test.rb +0 -365
- data/test/sass/script_test.rb +0 -1427
- data/test/sass/scss/css_test.rb +0 -1266
- data/test/sass/scss/rx_test.rb +0 -159
- data/test/sass/scss/scss_test.rb +0 -4238
- data/test/sass/scss/test_helper.rb +0 -37
- data/test/sass/source_map_test.rb +0 -1063
- data/test/sass/superselector_test.rb +0 -209
- data/test/sass/templates/_cached_import_option_partial.scss +0 -1
- data/test/sass/templates/_double_import_loop2.sass +0 -1
- data/test/sass/templates/_filename_fn_import.scss +0 -11
- data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
- data/test/sass/templates/_imported_charset_utf8.sass +0 -4
- data/test/sass/templates/_imported_content.sass +0 -3
- data/test/sass/templates/_partial.sass +0 -2
- data/test/sass/templates/_same_name_different_partiality.scss +0 -1
- data/test/sass/templates/alt.sass +0 -16
- data/test/sass/templates/basic.sass +0 -23
- data/test/sass/templates/bork1.sass +0 -2
- data/test/sass/templates/bork2.sass +0 -2
- data/test/sass/templates/bork3.sass +0 -2
- data/test/sass/templates/bork4.sass +0 -2
- data/test/sass/templates/bork5.sass +0 -3
- data/test/sass/templates/cached_import_option.scss +0 -3
- data/test/sass/templates/compact.sass +0 -17
- data/test/sass/templates/complex.sass +0 -305
- data/test/sass/templates/compressed.sass +0 -15
- data/test/sass/templates/double_import_loop1.sass +0 -1
- data/test/sass/templates/expanded.sass +0 -17
- data/test/sass/templates/filename_fn.scss +0 -18
- data/test/sass/templates/if.sass +0 -11
- data/test/sass/templates/import.sass +0 -12
- data/test/sass/templates/import_charset.sass +0 -9
- data/test/sass/templates/import_charset_ibm866.sass +0 -11
- data/test/sass/templates/import_content.sass +0 -4
- data/test/sass/templates/importee.less +0 -2
- data/test/sass/templates/importee.sass +0 -19
- data/test/sass/templates/line_numbers.sass +0 -13
- data/test/sass/templates/mixin_bork.sass +0 -5
- data/test/sass/templates/mixins.sass +0 -76
- data/test/sass/templates/multiline.sass +0 -20
- data/test/sass/templates/nested.sass +0 -25
- data/test/sass/templates/nested_bork1.sass +0 -2
- data/test/sass/templates/nested_bork2.sass +0 -2
- data/test/sass/templates/nested_bork3.sass +0 -2
- data/test/sass/templates/nested_bork4.sass +0 -2
- data/test/sass/templates/nested_import.sass +0 -2
- data/test/sass/templates/nested_mixin_bork.sass +0 -6
- data/test/sass/templates/options.sass +0 -2
- data/test/sass/templates/parent_ref.sass +0 -25
- data/test/sass/templates/same_name_different_ext.sass +0 -2
- data/test/sass/templates/same_name_different_ext.scss +0 -1
- data/test/sass/templates/same_name_different_partiality.scss +0 -1
- data/test/sass/templates/script.sass +0 -101
- data/test/sass/templates/scss_import.scss +0 -12
- data/test/sass/templates/scss_importee.scss +0 -1
- data/test/sass/templates/single_import_loop.sass +0 -1
- data/test/sass/templates/subdir/import_up1.scss +0 -1
- data/test/sass/templates/subdir/import_up2.scss +0 -1
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
- data/test/sass/templates/subdir/subdir.sass +0 -6
- data/test/sass/templates/units.sass +0 -11
- data/test/sass/templates/warn.sass +0 -3
- data/test/sass/templates/warn_imported.sass +0 -4
- data/test/sass/test_helper.rb +0 -8
- data/test/sass/util/multibyte_string_scanner_test.rb +0 -152
- data/test/sass/util/normalized_map_test.rb +0 -50
- data/test/sass/util/subset_map_test.rb +0 -90
- data/test/sass/util_test.rb +0 -393
- data/test/sass/value_helpers_test.rb +0 -178
- data/test/test_helper.rb +0 -149
@@ -1,178 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
|
3
|
-
class ValueHelpersTest < MiniTest::Test
|
4
|
-
include Sass::Script
|
5
|
-
include Sass::Script::Value::Helpers
|
6
|
-
|
7
|
-
def test_bool
|
8
|
-
assert_same Value::Bool::TRUE, bool(true)
|
9
|
-
assert_same Value::Bool::FALSE, bool(false)
|
10
|
-
assert_same Value::Bool::FALSE, bool(nil)
|
11
|
-
assert_same Value::Bool::TRUE, bool(Object.new)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_hex_color_with_three_digits
|
15
|
-
color = hex_color("F07")
|
16
|
-
assert_equal 255, color.red
|
17
|
-
assert_equal 0, color.green
|
18
|
-
assert_equal 119, color.blue
|
19
|
-
assert_equal 1, color.alpha
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_hex_color_without_hash
|
23
|
-
color_without_hash = hex_color("FF007F")
|
24
|
-
assert_equal 255, color_without_hash.red
|
25
|
-
assert_equal 0, color_without_hash.green
|
26
|
-
assert_equal 127, color_without_hash.blue
|
27
|
-
assert_equal 1, color_without_hash.alpha
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_hex_color_with_hash
|
31
|
-
color_with_hash = hex_color("#FF007F")
|
32
|
-
assert_equal 255, color_with_hash.red
|
33
|
-
assert_equal 0, color_with_hash.green
|
34
|
-
assert_equal 127, color_with_hash.blue
|
35
|
-
assert_equal 1, color_with_hash.alpha
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_malformed_hex_color
|
39
|
-
assert_raises ArgumentError do
|
40
|
-
hex_color("green")
|
41
|
-
end
|
42
|
-
assert_raises ArgumentError do
|
43
|
-
hex_color("#abcde")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
def test_hex_color_with_alpha
|
49
|
-
color_with_alpha = hex_color("FF007F", 0.5)
|
50
|
-
assert_equal 0.5, color_with_alpha.alpha
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_hex_color_alpha_clamps_0_to_1
|
54
|
-
assert_equal 1, hex_color("FF007F", 50).alpha
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_hsl_color_without_alpha
|
58
|
-
no_alpha = hsl_color(1, 0.5, 1)
|
59
|
-
assert_equal 1, no_alpha.hue
|
60
|
-
assert_equal 0.5, no_alpha.saturation
|
61
|
-
assert_equal 1, no_alpha.lightness
|
62
|
-
assert_equal 1, no_alpha.alpha
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_hsl_color_with_alpha
|
66
|
-
has_alpha = hsl_color(1, 0.5, 1, 0.5)
|
67
|
-
assert_equal 1, has_alpha.hue
|
68
|
-
assert_equal 0.5, has_alpha.saturation
|
69
|
-
assert_equal 1, has_alpha.lightness
|
70
|
-
assert_equal 0.5, has_alpha.alpha
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_rgb_color_without_alpha
|
74
|
-
no_alpha = rgb_color(255, 0, 0)
|
75
|
-
assert_equal 255, no_alpha.red
|
76
|
-
assert_equal 0, no_alpha.green
|
77
|
-
assert_equal 0, no_alpha.blue
|
78
|
-
assert_equal 1, no_alpha.alpha
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_rgb_color_with_alpha
|
82
|
-
has_alpha = rgb_color(255, 255, 255, 0.5)
|
83
|
-
assert_equal 255, has_alpha.red
|
84
|
-
assert_equal 255, has_alpha.green
|
85
|
-
assert_equal 255, has_alpha.blue
|
86
|
-
assert_equal 0.5, has_alpha.alpha
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_number
|
90
|
-
n = number(1)
|
91
|
-
assert_equal 1, n.value
|
92
|
-
assert_equal "1", n.to_sass
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_number_with_single_unit
|
96
|
-
n = number(1, "px")
|
97
|
-
assert_equal 1, n.value
|
98
|
-
assert_equal "1px", n.to_sass
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_number_with_singal_numerator_and_denominator
|
102
|
-
ratio = number(1, "px/em")
|
103
|
-
assert_equal "1px/em", ratio.to_sass
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_number_with_many_numerator_and_denominator_units
|
107
|
-
complex = number(1, "px*in/em*%")
|
108
|
-
assert_equal "1in*px/%*em", complex.to_sass
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_number_with_many_numerator_and_denominator_units_with_spaces
|
112
|
-
complex = number(1, "px * in / em * %")
|
113
|
-
assert_equal "1in*px/%*em", complex.to_sass
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_number_with_malformed_units
|
117
|
-
assert_raises ArgumentError do
|
118
|
-
number(1, "px/em/%")
|
119
|
-
end
|
120
|
-
assert_raises ArgumentError do
|
121
|
-
number(1, "/")
|
122
|
-
end
|
123
|
-
assert_raises ArgumentError do
|
124
|
-
number(1, "px/")
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_space_list
|
129
|
-
l = list(number(1, "px"), hex_color("#f71"), :space)
|
130
|
-
l.options = {}
|
131
|
-
assert_kind_of Sass::Script::Value::List, l
|
132
|
-
assert_equal "1px #f71", l.to_sass
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_comma_list
|
136
|
-
l = list(number(1, "px"), hex_color("#f71"), :comma)
|
137
|
-
l.options = {}
|
138
|
-
assert_kind_of Sass::Script::Value::List, l
|
139
|
-
assert_equal "1px, #f71", l.to_sass
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_missing_list_type
|
143
|
-
assert_raises ArgumentError do
|
144
|
-
list(number(1, "px"), hex_color("#f71"))
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_null
|
149
|
-
assert_kind_of Sass::Script::Value::Null, null
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_quoted_string
|
153
|
-
s = quoted_string("sassy string")
|
154
|
-
s.options = {}
|
155
|
-
assert_kind_of Sass::Script::Value::String, s
|
156
|
-
assert_equal "sassy string", s.value
|
157
|
-
assert_equal :string, s.type
|
158
|
-
assert_equal '"sassy string"', s.to_sass
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_identifier
|
162
|
-
s = identifier("a-sass-ident")
|
163
|
-
s.options = {}
|
164
|
-
assert_kind_of Sass::Script::Value::String, s
|
165
|
-
assert_equal "a-sass-ident", s.value
|
166
|
-
assert_equal :identifier, s.type
|
167
|
-
assert_equal "a-sass-ident", s.to_sass
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_unquoted_string
|
171
|
-
s = unquoted_string("a-sass-ident")
|
172
|
-
s.options = {}
|
173
|
-
assert_kind_of Sass::Script::Value::String, s
|
174
|
-
assert_equal "a-sass-ident", s.value
|
175
|
-
assert_equal :identifier, s.type
|
176
|
-
assert_equal "a-sass-ident", s.to_sass
|
177
|
-
end
|
178
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
lib_dir = File.dirname(__FILE__) + '/../lib'
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require 'fileutils'
|
5
|
-
$:.unshift lib_dir unless $:.include?(lib_dir)
|
6
|
-
require 'sass'
|
7
|
-
require 'mathn' if ENV['MATHN'] == 'true'
|
8
|
-
|
9
|
-
Sass::RAILS_LOADED = true unless defined?(Sass::RAILS_LOADED)
|
10
|
-
|
11
|
-
Sass.tests_running = true
|
12
|
-
|
13
|
-
if defined?(Encoding)
|
14
|
-
$-w, w = false, $-w
|
15
|
-
Encoding.default_external = 'UTF-8'
|
16
|
-
$-w = w
|
17
|
-
end
|
18
|
-
|
19
|
-
module Sass::Script::Functions
|
20
|
-
def option(name)
|
21
|
-
Sass::Script::Value::String.new(@options[name.value.to_sym].to_s)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class MiniTest::Test
|
26
|
-
def munge_filename(opts = {})
|
27
|
-
opts[:filename] ||= filename_for_test(opts[:syntax] || :sass)
|
28
|
-
opts[:sourcemap_filename] ||= sourcemap_filename_for_test
|
29
|
-
opts
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_name
|
33
|
-
caller.
|
34
|
-
map {|c| Sass::Util.caller_info(c)[2]}.
|
35
|
-
compact.
|
36
|
-
map {|c| c.sub(/^(block|rescue) in /, '')}.
|
37
|
-
find {|c| c =~ /^test_/}
|
38
|
-
end
|
39
|
-
|
40
|
-
def filename_for_test(syntax = :sass)
|
41
|
-
"#{test_name}_inline.#{syntax}"
|
42
|
-
end
|
43
|
-
|
44
|
-
def sourcemap_filename_for_test(syntax = :sass)
|
45
|
-
"#{test_name}_inline.css.map"
|
46
|
-
end
|
47
|
-
|
48
|
-
def clean_up_sassc
|
49
|
-
path = File.dirname(__FILE__) + "/../.sass-cache"
|
50
|
-
Sass::Util.retry_on_windows {FileUtils.rm_r(path) if File.exist?(path)}
|
51
|
-
end
|
52
|
-
|
53
|
-
def assert_warning(message)
|
54
|
-
the_real_stderr, $stderr = $stderr, StringIO.new
|
55
|
-
result = yield
|
56
|
-
|
57
|
-
if message.is_a?(Regexp)
|
58
|
-
assert_match message, $stderr.string.strip
|
59
|
-
else
|
60
|
-
assert_equal message.strip, $stderr.string.strip
|
61
|
-
end
|
62
|
-
result
|
63
|
-
ensure
|
64
|
-
$stderr = the_real_stderr
|
65
|
-
end
|
66
|
-
|
67
|
-
def assert_no_warning
|
68
|
-
the_real_stderr, $stderr = $stderr, StringIO.new
|
69
|
-
result = yield
|
70
|
-
assert_equal '', $stderr.string
|
71
|
-
result
|
72
|
-
ensure
|
73
|
-
$stderr = the_real_stderr
|
74
|
-
end
|
75
|
-
|
76
|
-
def silence_warnings(&block)
|
77
|
-
Sass::Util.silence_sass_warnings(&block)
|
78
|
-
end
|
79
|
-
|
80
|
-
def assert_raise_message(klass, message)
|
81
|
-
yield
|
82
|
-
rescue Exception => e
|
83
|
-
assert_instance_of(klass, e)
|
84
|
-
assert_equal(message, e.message)
|
85
|
-
else
|
86
|
-
flunk "Expected exception #{klass}, none raised"
|
87
|
-
end
|
88
|
-
|
89
|
-
def assert_raise_line(line)
|
90
|
-
yield
|
91
|
-
rescue Sass::SyntaxError => e
|
92
|
-
assert_equal(line, e.sass_line)
|
93
|
-
else
|
94
|
-
flunk "Expected exception on line #{line}, none raised"
|
95
|
-
end
|
96
|
-
|
97
|
-
def assert_sass_to_sass(sass, options: {})
|
98
|
-
assert_equal(sass.rstrip, to_sass(sass, options).rstrip,
|
99
|
-
"Expected Sass to transform to itself")
|
100
|
-
end
|
101
|
-
|
102
|
-
def assert_scss_to_sass(sass, scss, options: {})
|
103
|
-
assert_equal(sass.rstrip, to_sass(scss, options.merge(:syntax => :scss)).rstrip,
|
104
|
-
"Expected SCSS to transform to Sass")
|
105
|
-
end
|
106
|
-
|
107
|
-
def assert_scss_to_scss(scss, source: scss, options: {})
|
108
|
-
assert_equal(scss.rstrip, to_scss(source, options.merge(:syntax => :scss)).rstrip,
|
109
|
-
"Expected SCSS to transform to #{scss == source ? 'itself' : 'SCSS'}")
|
110
|
-
end
|
111
|
-
|
112
|
-
def assert_sass_to_scss(scss, sass, options: {})
|
113
|
-
assert_equal(scss.rstrip, to_scss(sass, options).rstrip,
|
114
|
-
"Expected Sass to transform to SCSS")
|
115
|
-
end
|
116
|
-
|
117
|
-
def assert_converts(sass, scss, options: {})
|
118
|
-
assert_sass_to_sass(sass, options: options)
|
119
|
-
assert_scss_to_sass(sass, scss, options: options)
|
120
|
-
assert_scss_to_scss(scss, options: options)
|
121
|
-
assert_sass_to_scss(scss, sass, options: options)
|
122
|
-
end
|
123
|
-
|
124
|
-
def to_sass(scss, options = {})
|
125
|
-
Sass::Util.silence_sass_warnings do
|
126
|
-
Sass::Engine.new(scss, options).to_tree.to_sass(options)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def to_scss(sass, options = {})
|
131
|
-
Sass::Util.silence_sass_warnings do
|
132
|
-
Sass::Engine.new(sass, options).to_tree.to_scss(options)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
module PublicApiLinter
|
138
|
-
def lint_api(api_class, duck_type_class)
|
139
|
-
define_method :test_lint_instance do
|
140
|
-
assert lint_instance.is_a?(duck_type_class)
|
141
|
-
end
|
142
|
-
api_class.instance_methods.each do |meth|
|
143
|
-
define_method :"test_has_#{meth}" do
|
144
|
-
assert lint_instance.respond_to?(meth),
|
145
|
-
"#{duck_type_class.name} does not implement #{meth}"
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|