oreorenasass 3.4.4 → 3.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +50 -70
- data/Rakefile +5 -26
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/bin/sass +1 -1
- data/bin/scss +1 -1
- data/lib/sass.rb +12 -19
- data/lib/sass/cache_stores/base.rb +2 -2
- data/lib/sass/cache_stores/chain.rb +1 -2
- data/lib/sass/cache_stores/filesystem.rb +5 -1
- data/lib/sass/cache_stores/memory.rb +1 -1
- data/lib/sass/cache_stores/null.rb +2 -2
- data/lib/sass/callbacks.rb +0 -1
- data/lib/sass/css.rb +13 -11
- data/lib/sass/engine.rb +173 -424
- data/lib/sass/environment.rb +58 -148
- data/lib/sass/error.rb +14 -11
- data/lib/sass/exec.rb +703 -5
- data/lib/sass/importers/base.rb +6 -49
- data/lib/sass/importers/filesystem.rb +19 -44
- data/lib/sass/logger.rb +4 -1
- data/lib/sass/logger/base.rb +4 -2
- data/lib/sass/logger/log_level.rb +7 -3
- data/lib/sass/media.rb +23 -20
- data/lib/sass/plugin.rb +7 -7
- data/lib/sass/plugin/compiler.rb +145 -304
- data/lib/sass/plugin/configuration.rb +23 -18
- data/lib/sass/plugin/merb.rb +1 -1
- data/lib/sass/plugin/staleness_checker.rb +3 -3
- data/lib/sass/repl.rb +3 -3
- data/lib/sass/script.rb +8 -35
- data/lib/sass/script/{value/arg_list.rb → arg_list.rb} +25 -9
- data/lib/sass/script/bool.rb +18 -0
- data/lib/sass/script/color.rb +606 -0
- data/lib/sass/script/css_lexer.rb +4 -8
- data/lib/sass/script/css_parser.rb +2 -5
- data/lib/sass/script/funcall.rb +245 -0
- data/lib/sass/script/functions.rb +408 -1491
- data/lib/sass/script/interpolation.rb +79 -0
- data/lib/sass/script/lexer.rb +68 -172
- data/lib/sass/script/list.rb +85 -0
- data/lib/sass/script/literal.rb +221 -0
- data/lib/sass/script/{tree/node.rb → node.rb} +12 -22
- data/lib/sass/script/{value/null.rb → null.rb} +7 -14
- data/lib/sass/script/{value/number.rb → number.rb} +75 -152
- data/lib/sass/script/{tree/operation.rb → operation.rb} +24 -17
- data/lib/sass/script/parser.rb +110 -245
- data/lib/sass/script/string.rb +51 -0
- data/lib/sass/script/{tree/string_interpolation.rb → string_interpolation.rb} +4 -5
- data/lib/sass/script/{tree/unary_operation.rb → unary_operation.rb} +6 -6
- data/lib/sass/script/variable.rb +58 -0
- data/lib/sass/scss/css_parser.rb +3 -9
- data/lib/sass/scss/parser.rb +421 -450
- data/lib/sass/scss/rx.rb +11 -19
- data/lib/sass/scss/static_parser.rb +7 -321
- data/lib/sass/selector.rb +194 -68
- data/lib/sass/selector/abstract_sequence.rb +14 -29
- data/lib/sass/selector/comma_sequence.rb +25 -108
- data/lib/sass/selector/sequence.rb +66 -159
- data/lib/sass/selector/simple.rb +25 -23
- data/lib/sass/selector/simple_sequence.rb +63 -173
- data/lib/sass/shared.rb +1 -1
- data/lib/sass/supports.rb +15 -13
- data/lib/sass/tree/charset_node.rb +1 -1
- data/lib/sass/tree/comment_node.rb +3 -3
- data/lib/sass/tree/css_import_node.rb +11 -11
- data/lib/sass/tree/debug_node.rb +2 -2
- data/lib/sass/tree/directive_node.rb +4 -21
- data/lib/sass/tree/each_node.rb +8 -8
- data/lib/sass/tree/extend_node.rb +7 -14
- data/lib/sass/tree/for_node.rb +4 -4
- data/lib/sass/tree/function_node.rb +4 -9
- data/lib/sass/tree/if_node.rb +1 -1
- data/lib/sass/tree/import_node.rb +5 -4
- data/lib/sass/tree/media_node.rb +14 -4
- data/lib/sass/tree/mixin_def_node.rb +4 -4
- data/lib/sass/tree/mixin_node.rb +8 -21
- data/lib/sass/tree/node.rb +12 -54
- data/lib/sass/tree/prop_node.rb +20 -39
- data/lib/sass/tree/return_node.rb +2 -3
- data/lib/sass/tree/root_node.rb +3 -19
- data/lib/sass/tree/rule_node.rb +22 -35
- data/lib/sass/tree/supports_node.rb +13 -0
- data/lib/sass/tree/trace_node.rb +1 -2
- data/lib/sass/tree/variable_node.rb +3 -9
- data/lib/sass/tree/visitors/base.rb +8 -5
- data/lib/sass/tree/visitors/check_nesting.rb +19 -49
- data/lib/sass/tree/visitors/convert.rb +56 -74
- data/lib/sass/tree/visitors/cssize.rb +74 -202
- data/lib/sass/tree/visitors/deep_copy.rb +5 -10
- data/lib/sass/tree/visitors/extend.rb +7 -7
- data/lib/sass/tree/visitors/perform.rb +185 -278
- data/lib/sass/tree/visitors/set_options.rb +6 -20
- data/lib/sass/tree/visitors/to_css.rb +81 -234
- data/lib/sass/tree/warn_node.rb +2 -2
- data/lib/sass/tree/while_node.rb +2 -2
- data/lib/sass/util.rb +152 -522
- data/lib/sass/util/multibyte_string_scanner.rb +0 -2
- data/lib/sass/util/subset_map.rb +3 -4
- data/lib/sass/util/test.rb +1 -0
- data/lib/sass/version.rb +22 -20
- data/test/Gemfile +3 -0
- data/test/Gemfile.lock +10 -0
- data/test/sass/cache_test.rb +20 -62
- data/test/sass/callbacks_test.rb +1 -1
- data/test/sass/conversion_test.rb +2 -296
- data/test/sass/css2sass_test.rb +4 -23
- data/test/sass/engine_test.rb +354 -411
- data/test/sass/exec_test.rb +2 -2
- data/test/sass/extend_test.rb +145 -324
- data/test/sass/functions_test.rb +86 -873
- data/test/sass/importer_test.rb +21 -241
- data/test/sass/logger_test.rb +1 -1
- data/test/sass/more_results/more_import.css +1 -1
- data/test/sass/plugin_test.rb +26 -16
- data/test/sass/results/compact.css +1 -1
- data/test/sass/results/complex.css +4 -4
- data/test/sass/results/expanded.css +1 -1
- data/test/sass/results/import.css +1 -1
- data/test/sass/results/import_charset_ibm866.css +2 -2
- data/test/sass/results/mixins.css +17 -17
- data/test/sass/results/nested.css +1 -1
- data/test/sass/results/parent_ref.css +2 -2
- data/test/sass/results/script.css +3 -3
- data/test/sass/results/scss_import.css +1 -1
- data/test/sass/script_conversion_test.rb +7 -36
- data/test/sass/script_test.rb +53 -485
- data/test/sass/scss/css_test.rb +28 -143
- data/test/sass/scss/rx_test.rb +4 -4
- data/test/sass/scss/scss_test.rb +325 -2119
- data/test/sass/templates/scss_import.scss +1 -2
- data/test/sass/test_helper.rb +1 -1
- data/test/sass/util/multibyte_string_scanner_test.rb +1 -1
- data/test/sass/util/subset_map_test.rb +2 -2
- data/test/sass/util_test.rb +1 -86
- data/test/test_helper.rb +8 -37
- metadata +19 -66
- data/lib/sass/exec/base.rb +0 -187
- data/lib/sass/exec/sass_convert.rb +0 -264
- data/lib/sass/exec/sass_scss.rb +0 -424
- data/lib/sass/features.rb +0 -47
- data/lib/sass/script/tree.rb +0 -16
- data/lib/sass/script/tree/funcall.rb +0 -306
- data/lib/sass/script/tree/interpolation.rb +0 -118
- data/lib/sass/script/tree/list_literal.rb +0 -77
- data/lib/sass/script/tree/literal.rb +0 -45
- data/lib/sass/script/tree/map_literal.rb +0 -64
- data/lib/sass/script/tree/selector.rb +0 -26
- data/lib/sass/script/tree/variable.rb +0 -57
- data/lib/sass/script/value.rb +0 -11
- data/lib/sass/script/value/base.rb +0 -240
- data/lib/sass/script/value/bool.rb +0 -35
- data/lib/sass/script/value/color.rb +0 -680
- data/lib/sass/script/value/helpers.rb +0 -262
- data/lib/sass/script/value/list.rb +0 -113
- data/lib/sass/script/value/map.rb +0 -70
- data/lib/sass/script/value/string.rb +0 -97
- data/lib/sass/selector/pseudo.rb +0 -256
- data/lib/sass/source/map.rb +0 -210
- data/lib/sass/source/position.rb +0 -39
- data/lib/sass/source/range.rb +0 -41
- data/lib/sass/stack.rb +0 -120
- data/lib/sass/tree/at_root_node.rb +0 -83
- data/lib/sass/tree/error_node.rb +0 -18
- data/lib/sass/tree/keyframe_rule_node.rb +0 -15
- data/lib/sass/util/cross_platform_random.rb +0 -19
- data/lib/sass/util/normalized_map.rb +0 -130
- data/lib/sass/util/ordered_hash.rb +0 -192
- data/test/sass/compiler_test.rb +0 -232
- data/test/sass/encoding_test.rb +0 -219
- data/test/sass/source_map_test.rb +0 -977
- data/test/sass/superselector_test.rb +0 -191
- data/test/sass/util/normalized_map_test.rb +0 -51
- data/test/sass/value_helpers_test.rb +0 -179
data/test/sass/css2sass_test.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require '
|
2
|
+
require 'test/unit'
|
3
3
|
require File.dirname(__FILE__) + '/../test_helper'
|
4
4
|
require 'sass/css'
|
5
5
|
|
6
|
-
class CSS2SassTest <
|
6
|
+
class CSS2SassTest < Test::Unit::TestCase
|
7
7
|
def test_basic
|
8
8
|
css = <<CSS
|
9
9
|
h1 {
|
@@ -62,7 +62,7 @@ div .debug
|
|
62
62
|
SASS
|
63
63
|
div .warning {
|
64
64
|
color: #d21a19; }
|
65
|
-
span .debug {
|
65
|
+
span .debug {
|
66
66
|
cursor: crosshair;}
|
67
67
|
div .debug {
|
68
68
|
cursor: default; }
|
@@ -238,7 +238,7 @@ CSS
|
|
238
238
|
end
|
239
239
|
|
240
240
|
def test_subject
|
241
|
-
|
241
|
+
assert_equal(<<SASS, css2sass(<<CSS))
|
242
242
|
.foo
|
243
243
|
.bar!
|
244
244
|
.baz
|
@@ -265,25 +265,6 @@ CSS
|
|
265
265
|
|
266
266
|
# Regressions
|
267
267
|
|
268
|
-
def test_nesting_with_matching_property
|
269
|
-
assert_equal(<<SASS, css2sass(<<CSS))
|
270
|
-
ul
|
271
|
-
width: 10px
|
272
|
-
div
|
273
|
-
width: 20px
|
274
|
-
|
275
|
-
article
|
276
|
-
width: 10px
|
277
|
-
p
|
278
|
-
width: 20px
|
279
|
-
SASS
|
280
|
-
ul {width: 10px}
|
281
|
-
ul div {width: 20px}
|
282
|
-
article {width: 10px}
|
283
|
-
article p {width: 20px}
|
284
|
-
CSS
|
285
|
-
end
|
286
|
-
|
287
268
|
def test_empty_rule
|
288
269
|
assert_equal(<<SASS, css2sass(<<CSS))
|
289
270
|
a
|
data/test/sass/engine_test.rb
CHANGED
@@ -9,29 +9,11 @@ require 'pathname'
|
|
9
9
|
|
10
10
|
module Sass::Script::Functions::UserFunctions
|
11
11
|
def option(name)
|
12
|
-
Sass::Script::
|
12
|
+
Sass::Script::String.new(@options[name.value.to_sym].to_s)
|
13
13
|
end
|
14
|
-
|
15
|
-
def set_a_variable(name, value)
|
16
|
-
environment.set_var(name.value, value)
|
17
|
-
return Sass::Script::Value::Null.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def set_a_global_variable(name, value)
|
21
|
-
environment.set_global_var(name.value, value)
|
22
|
-
return Sass::Script::Value::Null.new
|
23
|
-
end
|
24
|
-
|
25
|
-
def get_a_variable(name)
|
26
|
-
environment.var(name.value) || Sass::Script::Value::String.new("undefined")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
module Sass::Script::Functions
|
31
|
-
include Sass::Script::Functions::UserFunctions
|
32
14
|
end
|
33
15
|
|
34
|
-
class SassEngineTest <
|
16
|
+
class SassEngineTest < Test::Unit::TestCase
|
35
17
|
FAKE_FILE_NAME = __FILE__.gsub(/rb$/,"sass")
|
36
18
|
# A map of erroneous Sass documents to the error messages they should produce.
|
37
19
|
# The error messages may be arrays;
|
@@ -72,9 +54,9 @@ MSG
|
|
72
54
|
"$a: 1b <= 2c" => "Incompatible units: 'c' and 'b'.",
|
73
55
|
"$a: 1b >= 2c" => "Incompatible units: 'c' and 'b'.",
|
74
56
|
"a\n b: 1b * 2c" => "2b*c isn't a valid CSS value.",
|
75
|
-
"a\n b: 1b % 2c" => "
|
76
|
-
"$a: 2px + #ccc" => "Cannot add a number with units (2px) to a color (#
|
77
|
-
"$a: #ccc + 2px" => "Cannot add a number with units (2px) to a color (#
|
57
|
+
"a\n b: 1b % 2c" => "Cannot modulo by a number with units: 2c.",
|
58
|
+
"$a: 2px + #ccc" => "Cannot add a number with units (2px) to a color (#cccccc).",
|
59
|
+
"$a: #ccc + 2px" => "Cannot add a number with units (2px) to a color (#cccccc).",
|
78
60
|
"& a\n :b c" => ["Base-level rules cannot contain the parent-selector-referencing character '&'.", 1],
|
79
61
|
"a\n :b\n c" => "Illegal nesting: Only properties may be nested beneath properties.",
|
80
62
|
"$a: b\n :c d\n" => "Illegal nesting: Nothing may be nested beneath variable declarations.",
|
@@ -146,8 +128,6 @@ MSG
|
|
146
128
|
'@while' => "Invalid while directive '@while': expected expression.",
|
147
129
|
'@debug' => "Invalid debug directive '@debug': expected expression.",
|
148
130
|
%Q{@debug "a message"\n "nested message"} => "Illegal nesting: Nothing may be nested beneath debug directives.",
|
149
|
-
'@error' => "Invalid error directive '@error': expected expression.",
|
150
|
-
%Q{@error "a message"\n "nested message"} => "Illegal nesting: Nothing may be nested beneath error directives.",
|
151
131
|
'@warn' => "Invalid warn directive '@warn': expected expression.",
|
152
132
|
%Q{@warn "a message"\n "nested message"} => "Illegal nesting: Nothing may be nested beneath warn directives.",
|
153
133
|
"/* foo\n bar\n baz" => "Inconsistent indentation: previous line was indented by 4 spaces, but this line was indented by 2 spaces.",
|
@@ -165,13 +145,14 @@ MSG
|
|
165
145
|
"$var: true\n@while $var\n @extend .bar\n $var: false" => ["Extend directives may only be used within rules.", 3],
|
166
146
|
"@for $i from 0 to 1\n @extend .bar" => ["Extend directives may only be used within rules.", 2],
|
167
147
|
"@mixin foo\n @extend .bar\n@include foo" => ["Extend directives may only be used within rules.", 2],
|
148
|
+
"foo\n &a\n b: c" => ["Invalid CSS after \"&\": expected \"{\", was \"a\"\n\n\"a\" may only be used at the beginning of a compound selector.", 2],
|
149
|
+
"foo\n &1\n b: c" => ["Invalid CSS after \"&\": expected \"{\", was \"1\"\n\n\"1\" may only be used at the beginning of a compound selector.", 2],
|
168
150
|
"foo %\n a: b" => ['Invalid CSS after "foo %": expected placeholder name, was ""', 1],
|
169
151
|
"=foo\n @content error" => "Invalid content directive. Trailing characters found: \"error\".",
|
170
152
|
"=foo\n @content\n b: c" => "Illegal nesting: Nothing may be nested beneath @content directives.",
|
171
153
|
"@content" => '@content may only be used within a mixin.',
|
172
154
|
"=simple\n .simple\n color: red\n+simple\n color: blue" => ['Mixin "simple" does not accept a content block.', 4],
|
173
155
|
"@import \"foo\" // bar" => "Invalid CSS after \"\"foo\" \": expected media query list, was \"// bar\"",
|
174
|
-
"@at-root\n a: b" => "Properties are only allowed within rules, directives, mixin includes, or other properties.",
|
175
156
|
|
176
157
|
# Regression tests
|
177
158
|
"a\n b:\n c\n d" => ["Illegal nesting: Only properties may be nested beneath properties.", 3],
|
@@ -239,30 +220,42 @@ MSG
|
|
239
220
|
end
|
240
221
|
|
241
222
|
def test_import_same_name_different_ext
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
223
|
+
assert_warning <<WARNING do
|
224
|
+
WARNING: On line 1 of test_import_same_name_different_ext_inline.sass:
|
225
|
+
It's not clear which file to import for '@import "same_name_different_ext"'.
|
226
|
+
Candidates:
|
227
|
+
same_name_different_ext.sass
|
228
|
+
same_name_different_ext.scss
|
229
|
+
For now I'll choose same_name_different_ext.sass.
|
230
|
+
This will be an error in future versions of Sass.
|
231
|
+
WARNING
|
249
232
|
options = {:load_paths => [File.dirname(__FILE__) + '/templates/']}
|
250
233
|
munge_filename options
|
251
|
-
Sass::Engine.new("@import 'same_name_different_ext'", options).render
|
234
|
+
result = Sass::Engine.new("@import 'same_name_different_ext'", options).render
|
235
|
+
assert_equal(<<CSS, result)
|
236
|
+
.foo {
|
237
|
+
ext: sass; }
|
238
|
+
CSS
|
252
239
|
end
|
253
240
|
end
|
254
241
|
|
255
242
|
def test_import_same_name_different_partiality
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
243
|
+
assert_warning <<WARNING do
|
244
|
+
WARNING: On line 1 of test_import_same_name_different_partiality_inline.sass:
|
245
|
+
It's not clear which file to import for '@import "same_name_different_partiality"'.
|
246
|
+
Candidates:
|
247
|
+
_same_name_different_partiality.scss
|
248
|
+
same_name_different_partiality.scss
|
249
|
+
For now I'll choose _same_name_different_partiality.scss.
|
250
|
+
This will be an error in future versions of Sass.
|
251
|
+
WARNING
|
263
252
|
options = {:load_paths => [File.dirname(__FILE__) + '/templates/']}
|
264
253
|
munge_filename options
|
265
|
-
Sass::Engine.new("@import 'same_name_different_partiality'", options).render
|
254
|
+
result = Sass::Engine.new("@import 'same_name_different_partiality'", options).render
|
255
|
+
assert_equal(<<CSS, result)
|
256
|
+
.foo {
|
257
|
+
partial: yes; }
|
258
|
+
CSS
|
266
259
|
end
|
267
260
|
end
|
268
261
|
|
@@ -474,25 +467,89 @@ SASS
|
|
474
467
|
assert_hash_has(err.sass_backtrace[4], :filename => nil, :mixin => nil, :line => 1)
|
475
468
|
end
|
476
469
|
|
477
|
-
def
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
@each $key, $value in $map-or-color
|
489
|
-
.\#{$key}
|
490
|
-
@include map-to-rule($value)
|
491
|
-
@else
|
492
|
-
color: $map-or-color
|
470
|
+
def test_basic_mixin_loop_exception
|
471
|
+
render <<SASS
|
472
|
+
@mixin foo
|
473
|
+
@include foo
|
474
|
+
@include foo
|
475
|
+
SASS
|
476
|
+
assert(false, "Exception not raised")
|
477
|
+
rescue Sass::SyntaxError => err
|
478
|
+
assert_equal("An @include loop has been found: foo includes itself", err.message)
|
479
|
+
assert_hash_has(err.sass_backtrace[0], :mixin => "foo", :line => 2)
|
480
|
+
end
|
493
481
|
|
494
|
-
|
482
|
+
def test_double_mixin_loop_exception
|
483
|
+
render <<SASS
|
484
|
+
@mixin foo
|
485
|
+
@include bar
|
486
|
+
@mixin bar
|
487
|
+
@include foo
|
488
|
+
@include foo
|
495
489
|
SASS
|
490
|
+
assert(false, "Exception not raised")
|
491
|
+
rescue Sass::SyntaxError => err
|
492
|
+
assert_equal(<<MESSAGE.rstrip, err.message)
|
493
|
+
An @include loop has been found:
|
494
|
+
foo includes bar
|
495
|
+
bar includes foo
|
496
|
+
MESSAGE
|
497
|
+
assert_hash_has(err.sass_backtrace[0], :mixin => "bar", :line => 4)
|
498
|
+
assert_hash_has(err.sass_backtrace[1], :mixin => "foo", :line => 2)
|
499
|
+
end
|
500
|
+
|
501
|
+
def test_deep_mixin_loop_exception
|
502
|
+
render <<SASS
|
503
|
+
@mixin foo
|
504
|
+
@include bar
|
505
|
+
|
506
|
+
@mixin bar
|
507
|
+
@include baz
|
508
|
+
|
509
|
+
@mixin baz
|
510
|
+
@include foo
|
511
|
+
|
512
|
+
@include foo
|
513
|
+
SASS
|
514
|
+
assert(false, "Exception not raised")
|
515
|
+
rescue Sass::SyntaxError => err
|
516
|
+
assert_equal(<<MESSAGE.rstrip, err.message)
|
517
|
+
An @include loop has been found:
|
518
|
+
foo includes bar
|
519
|
+
bar includes baz
|
520
|
+
baz includes foo
|
521
|
+
MESSAGE
|
522
|
+
assert_hash_has(err.sass_backtrace[0], :mixin => "baz", :line => 8)
|
523
|
+
assert_hash_has(err.sass_backtrace[1], :mixin => "bar", :line => 5)
|
524
|
+
assert_hash_has(err.sass_backtrace[2], :mixin => "foo", :line => 2)
|
525
|
+
end
|
526
|
+
|
527
|
+
def test_mixin_loop_with_content
|
528
|
+
render <<SASS
|
529
|
+
=foo
|
530
|
+
@content
|
531
|
+
=bar
|
532
|
+
+foo
|
533
|
+
+bar
|
534
|
+
+bar
|
535
|
+
SASS
|
536
|
+
assert(false, "Exception not raised")
|
537
|
+
rescue Sass::SyntaxError => err
|
538
|
+
assert_equal("An @include loop has been found: bar includes itself", err.message)
|
539
|
+
assert_hash_has(err.sass_backtrace[0], :mixin => "@content", :line => 5)
|
540
|
+
end
|
541
|
+
|
542
|
+
def test_basic_import_loop_exception
|
543
|
+
import = filename_for_test
|
544
|
+
importer = MockImporter.new
|
545
|
+
importer.add_import(import, "@import '#{import}'")
|
546
|
+
|
547
|
+
engine = Sass::Engine.new("@import '#{import}'", :filename => import,
|
548
|
+
:load_paths => [importer])
|
549
|
+
|
550
|
+
assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) {engine.render}
|
551
|
+
An @import loop has been found: #{import} imports itself
|
552
|
+
ERR
|
496
553
|
end
|
497
554
|
|
498
555
|
def test_double_import_loop_exception
|
@@ -533,9 +590,9 @@ ERR
|
|
533
590
|
opts = {:full_exception => true, :line => 362}
|
534
591
|
render(("a\n b: c\n" * 10) + "d\n e:\n" + ("f\n g: h\n" * 10), opts)
|
535
592
|
rescue Sass::SyntaxError => e
|
536
|
-
assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e, opts
|
593
|
+
assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e, opts).split("\n")[0..15].join("\n"))
|
537
594
|
/*
|
538
|
-
|
595
|
+
Syntax error: Invalid property: "e:" (no value).
|
539
596
|
on line 383 of test_exception_css_with_offset_inline.sass
|
540
597
|
|
541
598
|
378: a
|
@@ -555,7 +612,8 @@ CSS
|
|
555
612
|
end
|
556
613
|
|
557
614
|
def test_exception_css_with_mixins
|
558
|
-
|
615
|
+
opts = {:full_exception => true}
|
616
|
+
render(<<SASS, opts)
|
559
617
|
=error-mixin($a)
|
560
618
|
color: $a * 1em * 1px
|
561
619
|
|
@@ -566,9 +624,9 @@ CSS
|
|
566
624
|
+outer-mixin(12)
|
567
625
|
SASS
|
568
626
|
rescue Sass::SyntaxError => e
|
569
|
-
assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e).split("\n")[0..13].join("\n"))
|
627
|
+
assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e, opts).split("\n")[0..13].join("\n"))
|
570
628
|
/*
|
571
|
-
|
629
|
+
Syntax error: 12em*px isn't a valid CSS value.
|
572
630
|
on line 2 of test_exception_css_with_mixins_inline.sass, in `error-mixin'
|
573
631
|
from line 5 of test_exception_css_with_mixins_inline.sass, in `outer-mixin'
|
574
632
|
from line 8 of test_exception_css_with_mixins_inline.sass
|
@@ -586,7 +644,8 @@ CSS
|
|
586
644
|
end
|
587
645
|
|
588
646
|
def test_cssize_exception_css
|
589
|
-
|
647
|
+
opts = {:full_exception => true}
|
648
|
+
render(<<SASS, opts)
|
590
649
|
.filler
|
591
650
|
stuff: "stuff!"
|
592
651
|
|
@@ -596,9 +655,9 @@ a: b
|
|
596
655
|
a: b
|
597
656
|
SASS
|
598
657
|
rescue Sass::SyntaxError => e
|
599
|
-
assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e).split("\n")[0..11].join("\n"))
|
658
|
+
assert_equal(<<CSS, Sass::SyntaxError.exception_to_css(e, opts).split("\n")[0..11].join("\n"))
|
600
659
|
/*
|
601
|
-
|
660
|
+
Syntax error: Properties are only allowed within rules, directives, mixin includes, or other properties.
|
602
661
|
on line 4 of test_cssize_exception_css_inline.sass
|
603
662
|
|
604
663
|
1: .filler
|
@@ -618,12 +677,12 @@ CSS
|
|
618
677
|
end
|
619
678
|
|
620
679
|
def test_http_import
|
621
|
-
assert_equal("@import
|
680
|
+
assert_equal("@import url(http://fonts.googleapis.com/css?family=Droid+Sans);\n",
|
622
681
|
render("@import \"http://fonts.googleapis.com/css?family=Droid+Sans\""))
|
623
682
|
end
|
624
683
|
|
625
684
|
def test_protocol_relative_import
|
626
|
-
assert_equal("@import
|
685
|
+
assert_equal("@import url(//fonts.googleapis.com/css?family=Droid+Sans);\n",
|
627
686
|
render("@import \"//fonts.googleapis.com/css?family=Droid+Sans\""))
|
628
687
|
end
|
629
688
|
|
@@ -653,18 +712,18 @@ SASS
|
|
653
712
|
|
654
713
|
def test_sass_import
|
655
714
|
sassc_file = sassc_path("importee")
|
656
|
-
assert !File.
|
715
|
+
assert !File.exists?(sassc_file)
|
657
716
|
renders_correctly "import", { :style => :compact, :load_paths => [File.dirname(__FILE__) + "/templates"] }
|
658
|
-
assert File.
|
717
|
+
assert File.exists?(sassc_file)
|
659
718
|
end
|
660
719
|
|
661
720
|
def test_sass_pathname_import
|
662
721
|
sassc_file = sassc_path("importee")
|
663
|
-
assert !File.
|
722
|
+
assert !File.exists?(sassc_file)
|
664
723
|
renders_correctly("import",
|
665
724
|
:style => :compact,
|
666
725
|
:load_paths => [Pathname.new(File.dirname(__FILE__) + "/templates")])
|
667
|
-
assert File.
|
726
|
+
assert File.exists?(sassc_file)
|
668
727
|
end
|
669
728
|
|
670
729
|
def test_import_from_global_load_paths
|
@@ -696,23 +755,23 @@ ERR
|
|
696
755
|
end
|
697
756
|
|
698
757
|
def test_no_cache
|
699
|
-
assert !File.
|
758
|
+
assert !File.exists?(sassc_path("importee"))
|
700
759
|
renders_correctly("import", {
|
701
760
|
:style => :compact, :cache => false,
|
702
761
|
:load_paths => [File.dirname(__FILE__) + "/templates"],
|
703
762
|
})
|
704
|
-
assert !File.
|
763
|
+
assert !File.exists?(sassc_path("importee"))
|
705
764
|
end
|
706
765
|
|
707
766
|
def test_import_in_rule
|
708
767
|
assert_equal(<<CSS, render(<<SASS, :load_paths => [File.dirname(__FILE__) + '/templates/']))
|
709
768
|
.foo #foo {
|
710
|
-
background-color: #
|
769
|
+
background-color: #bbaaff; }
|
711
770
|
|
712
771
|
.bar {
|
713
772
|
a: b; }
|
714
773
|
.bar #foo {
|
715
|
-
background-color: #
|
774
|
+
background-color: #bbaaff; }
|
716
775
|
CSS
|
717
776
|
.foo
|
718
777
|
@import partial
|
@@ -1031,6 +1090,7 @@ SASS
|
|
1031
1090
|
@-webkit-keyframes warm {
|
1032
1091
|
from {
|
1033
1092
|
color: black; }
|
1093
|
+
|
1034
1094
|
to {
|
1035
1095
|
color: red; } }
|
1036
1096
|
CSS
|
@@ -1134,13 +1194,7 @@ SASS
|
|
1134
1194
|
end
|
1135
1195
|
|
1136
1196
|
def test_default_values_for_mixin_arguments
|
1137
|
-
assert_equal(
|
1138
|
-
white {
|
1139
|
-
color: #FFF; }
|
1140
|
-
|
1141
|
-
black {
|
1142
|
-
color: #000; }
|
1143
|
-
CSS
|
1197
|
+
assert_equal("white {\n color: white; }\n\nblack {\n color: black; }\n", render(<<SASS))
|
1144
1198
|
=foo($a: #FFF)
|
1145
1199
|
:color $a
|
1146
1200
|
white
|
@@ -1150,17 +1204,17 @@ black
|
|
1150
1204
|
SASS
|
1151
1205
|
assert_equal(<<CSS, render(<<SASS))
|
1152
1206
|
one {
|
1153
|
-
color:
|
1207
|
+
color: white;
|
1154
1208
|
padding: 1px;
|
1155
1209
|
margin: 4px; }
|
1156
1210
|
|
1157
1211
|
two {
|
1158
|
-
color:
|
1212
|
+
color: white;
|
1159
1213
|
padding: 2px;
|
1160
1214
|
margin: 5px; }
|
1161
1215
|
|
1162
1216
|
three {
|
1163
|
-
color:
|
1217
|
+
color: white;
|
1164
1218
|
padding: 2px;
|
1165
1219
|
margin: 3px; }
|
1166
1220
|
CSS
|
@@ -1178,17 +1232,17 @@ three
|
|
1178
1232
|
SASS
|
1179
1233
|
assert_equal(<<CSS, render(<<SASS))
|
1180
1234
|
one {
|
1181
|
-
color:
|
1235
|
+
color: white;
|
1182
1236
|
padding: 1px;
|
1183
1237
|
margin: 4px; }
|
1184
1238
|
|
1185
1239
|
two {
|
1186
|
-
color:
|
1240
|
+
color: white;
|
1187
1241
|
padding: 2px;
|
1188
1242
|
margin: 5px; }
|
1189
1243
|
|
1190
1244
|
three {
|
1191
|
-
color:
|
1245
|
+
color: white;
|
1192
1246
|
padding: 2px;
|
1193
1247
|
margin: 3px; }
|
1194
1248
|
CSS
|
@@ -1374,44 +1428,6 @@ bar
|
|
1374
1428
|
SASS
|
1375
1429
|
end
|
1376
1430
|
|
1377
|
-
def test_user_defined_function_variable_scope
|
1378
|
-
render(<<SASS)
|
1379
|
-
bar
|
1380
|
-
-no-op: set-a-variable(variable, 5)
|
1381
|
-
a: $variable
|
1382
|
-
SASS
|
1383
|
-
flunk("Exception not raised for test_user_defined_function_variable_scope")
|
1384
|
-
rescue Sass::SyntaxError => e
|
1385
|
-
assert_equal('Undefined variable: "$variable".', e.message)
|
1386
|
-
end
|
1387
|
-
|
1388
|
-
def test_user_defined_function_can_change_global_variable
|
1389
|
-
assert_equal(<<CSS, render(<<SASS))
|
1390
|
-
bar {
|
1391
|
-
a: 5; }
|
1392
|
-
CSS
|
1393
|
-
$variable: 0
|
1394
|
-
bar
|
1395
|
-
$local: 10
|
1396
|
-
-no-op: set-a-global-variable(variable, 5)
|
1397
|
-
a: $variable
|
1398
|
-
SASS
|
1399
|
-
end
|
1400
|
-
|
1401
|
-
def test_user_defined_function_cannot_read_local_variable
|
1402
|
-
assert_equal(<<CSS, render(<<SASS))
|
1403
|
-
bar {
|
1404
|
-
global: 0;
|
1405
|
-
local: undefined; }
|
1406
|
-
CSS
|
1407
|
-
$global: 0
|
1408
|
-
bar
|
1409
|
-
$local: 10
|
1410
|
-
global: get-a-variable(global)
|
1411
|
-
local: get-a-variable(local)
|
1412
|
-
SASS
|
1413
|
-
end
|
1414
|
-
|
1415
1431
|
def test_control_directive_in_nested_property
|
1416
1432
|
assert_equal(<<CSS, render(<<SASS))
|
1417
1433
|
foo {
|
@@ -1525,7 +1541,7 @@ $a: 5
|
|
1525
1541
|
@while $a != 0
|
1526
1542
|
a-\#{$a}
|
1527
1543
|
blooble: gloop
|
1528
|
-
$a: $a - 1
|
1544
|
+
$a: $a - 1
|
1529
1545
|
SASS
|
1530
1546
|
end
|
1531
1547
|
|
@@ -1592,43 +1608,50 @@ a
|
|
1592
1608
|
SASS
|
1593
1609
|
end
|
1594
1610
|
|
1595
|
-
def test_destructuring_each
|
1596
|
-
assert_equal <<CSS, render(<<SCSS)
|
1597
|
-
a {
|
1598
|
-
foo: 1px;
|
1599
|
-
bar: 2px;
|
1600
|
-
baz: 3px; }
|
1601
|
-
|
1602
|
-
c {
|
1603
|
-
foo: "Value is bar";
|
1604
|
-
bar: "Value is baz";
|
1605
|
-
bang: "Value is "; }
|
1606
|
-
CSS
|
1607
|
-
a
|
1608
|
-
@each $name, $number in (foo: 1px, bar: 2px, baz: 3px)
|
1609
|
-
\#{$name}: $number
|
1610
|
-
c
|
1611
|
-
@each $key, $value in (foo bar) (bar, baz) bang
|
1612
|
-
\#{$key}: "Value is \#{$value}"
|
1613
|
-
SCSS
|
1614
|
-
end
|
1615
|
-
|
1616
1611
|
def test_variable_reassignment
|
1617
1612
|
assert_equal(<<CSS, render(<<SASS))
|
1618
1613
|
a {
|
1619
1614
|
b: 1;
|
1620
1615
|
c: 2; }
|
1621
1616
|
CSS
|
1617
|
+
$a: 1
|
1622
1618
|
a
|
1623
|
-
$a: 1
|
1624
1619
|
b: $a
|
1625
1620
|
$a: 2
|
1626
1621
|
c: $a
|
1627
1622
|
SASS
|
1628
1623
|
end
|
1629
1624
|
|
1625
|
+
def test_variable_scope
|
1626
|
+
assert_equal(<<CSS, render(<<SASS))
|
1627
|
+
a {
|
1628
|
+
b-1: c;
|
1629
|
+
b-2: c;
|
1630
|
+
d: 12; }
|
1631
|
+
|
1632
|
+
b {
|
1633
|
+
d: 17; }
|
1634
|
+
CSS
|
1635
|
+
$i: 12
|
1636
|
+
a
|
1637
|
+
@for $i from 1 through 2
|
1638
|
+
b-\#{$i}: c
|
1639
|
+
d: $i
|
1640
|
+
|
1641
|
+
=foo
|
1642
|
+
$i: 17
|
1643
|
+
|
1644
|
+
b
|
1645
|
+
+foo
|
1646
|
+
d: $i
|
1647
|
+
SASS
|
1648
|
+
end
|
1649
|
+
|
1630
1650
|
def test_hyphen_underscore_insensitive_variables
|
1631
1651
|
assert_equal(<<CSS, render(<<SASS))
|
1652
|
+
a {
|
1653
|
+
b: c; }
|
1654
|
+
|
1632
1655
|
d {
|
1633
1656
|
e: 13;
|
1634
1657
|
f: foobar; }
|
@@ -1636,8 +1659,10 @@ CSS
|
|
1636
1659
|
$var-hyphen: 12
|
1637
1660
|
$var_under: foo
|
1638
1661
|
|
1639
|
-
|
1640
|
-
$
|
1662
|
+
a
|
1663
|
+
$var_hyphen: 1 + $var_hyphen
|
1664
|
+
$var-under: $var-under + bar
|
1665
|
+
b: c
|
1641
1666
|
|
1642
1667
|
d
|
1643
1668
|
e: $var-hyphen
|
@@ -1669,7 +1694,7 @@ SASS
|
|
1669
1694
|
end
|
1670
1695
|
|
1671
1696
|
def test_argument_error
|
1672
|
-
|
1697
|
+
assert_raise(Sass::SyntaxError) { render("a\n b: hsl(1)") }
|
1673
1698
|
end
|
1674
1699
|
|
1675
1700
|
def test_comments_at_the_top_of_a_document
|
@@ -1794,9 +1819,11 @@ SASS
|
|
1794
1819
|
|
1795
1820
|
def test_loud_comment_is_evaluated
|
1796
1821
|
assert_equal <<CSS, render(<<SASS)
|
1797
|
-
/*!
|
1822
|
+
/*!
|
1823
|
+
* Hue: 327.21649deg */
|
1798
1824
|
CSS
|
1799
|
-
/*!
|
1825
|
+
/*!
|
1826
|
+
Hue: \#{hue(#f836a0)}
|
1800
1827
|
SASS
|
1801
1828
|
end
|
1802
1829
|
|
@@ -2014,10 +2041,10 @@ $var: "bar"
|
|
2014
2041
|
SASS
|
2015
2042
|
end
|
2016
2043
|
|
2017
|
-
def
|
2044
|
+
def test_interpolation_doesnt_deep_unquote_strings
|
2018
2045
|
assert_equal(<<CSS, render(<<SASS))
|
2019
2046
|
.foo {
|
2020
|
-
a: bar baz; }
|
2047
|
+
a: "bar" "baz"; }
|
2021
2048
|
CSS
|
2022
2049
|
.foo
|
2023
2050
|
a: \#{"bar" "baz"}
|
@@ -2203,36 +2230,6 @@ CSS
|
|
2203
2230
|
SASS
|
2204
2231
|
end
|
2205
2232
|
|
2206
|
-
def test_double_media_bubbling_with_surrounding_rules
|
2207
|
-
assert_equal <<CSS, render(<<SASS)
|
2208
|
-
@media (min-width: 0) {
|
2209
|
-
a {
|
2210
|
-
a: a; }
|
2211
|
-
|
2212
|
-
b {
|
2213
|
-
before: b;
|
2214
|
-
after: b; } }
|
2215
|
-
@media (min-width: 0) and (max-width: 5000px) {
|
2216
|
-
b {
|
2217
|
-
x: x; } }
|
2218
|
-
|
2219
|
-
@media (min-width: 0) {
|
2220
|
-
c {
|
2221
|
-
c: c; } }
|
2222
|
-
CSS
|
2223
|
-
@media (min-width: 0)
|
2224
|
-
a
|
2225
|
-
a: a
|
2226
|
-
b
|
2227
|
-
before: b
|
2228
|
-
@media (max-width: 5000px)
|
2229
|
-
x: x
|
2230
|
-
after: b
|
2231
|
-
c
|
2232
|
-
c: c
|
2233
|
-
SASS
|
2234
|
-
end
|
2235
|
-
|
2236
2233
|
def test_rule_media_rule_bubbling
|
2237
2234
|
assert_equal <<CSS, render(<<SASS)
|
2238
2235
|
@media bar {
|
@@ -2259,10 +2256,9 @@ SASS
|
|
2259
2256
|
@media print {
|
2260
2257
|
.outside {
|
2261
2258
|
color: black; } }
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
2259
|
+
@media print and (a: b) {
|
2260
|
+
.outside .inside {
|
2261
|
+
border: 1px solid black; } }
|
2266
2262
|
.outside .middle {
|
2267
2263
|
display: block; }
|
2268
2264
|
CSS
|
@@ -2400,76 +2396,8 @@ $val: 20
|
|
2400
2396
|
SASS
|
2401
2397
|
end
|
2402
2398
|
|
2403
|
-
def test_at_root
|
2404
|
-
assert_equal <<CSS, render(<<SASS)
|
2405
|
-
.bar {
|
2406
|
-
a: b; }
|
2407
|
-
CSS
|
2408
|
-
.foo
|
2409
|
-
@at-root
|
2410
|
-
.bar
|
2411
|
-
a: b
|
2412
|
-
SASS
|
2413
|
-
end
|
2414
|
-
|
2415
|
-
def test_at_root_with_selector
|
2416
|
-
assert_equal <<CSS, render(<<SASS)
|
2417
|
-
.bar {
|
2418
|
-
a: b; }
|
2419
|
-
CSS
|
2420
|
-
.foo
|
2421
|
-
@at-root .bar
|
2422
|
-
a: b
|
2423
|
-
SASS
|
2424
|
-
end
|
2425
|
-
|
2426
|
-
def test_at_root_with_query
|
2427
|
-
assert_equal <<CSS, render(<<SASS)
|
2428
|
-
.foo .bar {
|
2429
|
-
a: b; }
|
2430
|
-
CSS
|
2431
|
-
.foo
|
2432
|
-
@media screen
|
2433
|
-
@at-root (without: media)
|
2434
|
-
.bar
|
2435
|
-
a: b
|
2436
|
-
SASS
|
2437
|
-
end
|
2438
|
-
|
2439
|
-
def test_variable_assignment_with_global
|
2440
|
-
assert_no_warning {assert_equal(<<CSS, render(<<SASS))}
|
2441
|
-
.foo {
|
2442
|
-
a: x; }
|
2443
|
-
|
2444
|
-
.bar {
|
2445
|
-
b: x; }
|
2446
|
-
CSS
|
2447
|
-
$var: 1
|
2448
|
-
|
2449
|
-
.foo
|
2450
|
-
$var: x !global
|
2451
|
-
a: $var
|
2452
|
-
|
2453
|
-
.bar
|
2454
|
-
b: $var
|
2455
|
-
SASS
|
2456
|
-
end
|
2457
|
-
|
2458
2399
|
# Regression tests
|
2459
2400
|
|
2460
|
-
def test_list_separator_with_arg_list
|
2461
|
-
assert_equal(<<CSS, render(<<SASS))
|
2462
|
-
.test {
|
2463
|
-
separator: comma; }
|
2464
|
-
CSS
|
2465
|
-
@mixin arglist-test($args...)
|
2466
|
-
separator: list-separator($args)
|
2467
|
-
|
2468
|
-
.test
|
2469
|
-
@include arglist-test(this, is, comma, separated)
|
2470
|
-
SASS
|
2471
|
-
end
|
2472
|
-
|
2473
2401
|
def test_parent_mixin_in_content_nested
|
2474
2402
|
assert_equal(<<CSS, render(<<SASS))
|
2475
2403
|
a {
|
@@ -2540,6 +2468,24 @@ body
|
|
2540
2468
|
SASS
|
2541
2469
|
end
|
2542
2470
|
|
2471
|
+
def test_tricky_mixin_loop_exception
|
2472
|
+
render <<SASS
|
2473
|
+
@mixin foo($a)
|
2474
|
+
@if $a
|
2475
|
+
@include foo(false)
|
2476
|
+
@include foo(true)
|
2477
|
+
@else
|
2478
|
+
a: b
|
2479
|
+
|
2480
|
+
a
|
2481
|
+
@include foo(true)
|
2482
|
+
SASS
|
2483
|
+
assert(false, "Exception not raised")
|
2484
|
+
rescue Sass::SyntaxError => err
|
2485
|
+
assert_equal("An @include loop has been found: foo includes itself", err.message)
|
2486
|
+
assert_hash_has(err.sass_backtrace[0], :mixin => "foo", :line => 3)
|
2487
|
+
end
|
2488
|
+
|
2543
2489
|
def test_interpolated_comment_in_mixin
|
2544
2490
|
assert_equal <<CSS, render(<<SASS)
|
2545
2491
|
/*! color: red */
|
@@ -2883,6 +2829,145 @@ CSS
|
|
2883
2829
|
SASS
|
2884
2830
|
end
|
2885
2831
|
|
2832
|
+
# Encodings
|
2833
|
+
|
2834
|
+
unless Sass::Util.ruby1_8?
|
2835
|
+
def test_encoding_error
|
2836
|
+
render("foo\nbar\nb\xFEaz".force_encoding("utf-8"))
|
2837
|
+
assert(false, "Expected exception")
|
2838
|
+
rescue Sass::SyntaxError => e
|
2839
|
+
assert_equal(3, e.sass_line)
|
2840
|
+
assert_equal('Invalid UTF-8 character "\xFE"', e.message)
|
2841
|
+
end
|
2842
|
+
|
2843
|
+
def test_ascii_incompatible_encoding_error
|
2844
|
+
template = "foo\nbar\nb_z".encode("utf-16le")
|
2845
|
+
template[9] = "\xFE".force_encoding("utf-16le")
|
2846
|
+
render(template)
|
2847
|
+
assert(false, "Expected exception")
|
2848
|
+
rescue Sass::SyntaxError => e
|
2849
|
+
assert_equal(3, e.sass_line)
|
2850
|
+
assert_equal('Invalid UTF-16LE character "\xFE"', e.message)
|
2851
|
+
end
|
2852
|
+
|
2853
|
+
def test_same_charset_as_encoding
|
2854
|
+
assert_renders_encoded(<<CSS, <<SASS)
|
2855
|
+
@charset "UTF-8";
|
2856
|
+
fóó {
|
2857
|
+
a: b; }
|
2858
|
+
CSS
|
2859
|
+
@charset "utf-8"
|
2860
|
+
fóó
|
2861
|
+
a: b
|
2862
|
+
SASS
|
2863
|
+
end
|
2864
|
+
|
2865
|
+
def test_different_charset_than_encoding
|
2866
|
+
assert_renders_encoded(<<CSS.force_encoding("IBM866"), <<SASS)
|
2867
|
+
@charset "IBM866";
|
2868
|
+
fóó {
|
2869
|
+
a: b; }
|
2870
|
+
CSS
|
2871
|
+
@charset "ibm866"
|
2872
|
+
fóó
|
2873
|
+
a: b
|
2874
|
+
SASS
|
2875
|
+
end
|
2876
|
+
|
2877
|
+
def test_different_encoding_than_system
|
2878
|
+
assert_renders_encoded(<<CSS.encode("IBM866"), <<SASS.encode("IBM866"))
|
2879
|
+
@charset "IBM866";
|
2880
|
+
тАЬ {
|
2881
|
+
a: b; }
|
2882
|
+
CSS
|
2883
|
+
тАЬ
|
2884
|
+
a: b
|
2885
|
+
SASS
|
2886
|
+
end
|
2887
|
+
|
2888
|
+
def test_multibyte_charset
|
2889
|
+
assert_renders_encoded(<<CSS.encode("UTF-16LE"), <<SASS.encode("UTF-16LE").force_encoding("UTF-8"))
|
2890
|
+
@charset "UTF-16LE";
|
2891
|
+
fóó {
|
2892
|
+
a: b; }
|
2893
|
+
CSS
|
2894
|
+
@charset "utf-16le"
|
2895
|
+
fóó
|
2896
|
+
a: b
|
2897
|
+
SASS
|
2898
|
+
end
|
2899
|
+
|
2900
|
+
def test_multibyte_charset_without_endian_specifier
|
2901
|
+
assert_renders_encoded(<<CSS.encode("UTF-32BE"), <<SASS.encode("UTF-32BE").force_encoding("UTF-8"))
|
2902
|
+
@charset "UTF-32BE";
|
2903
|
+
fóó {
|
2904
|
+
a: b; }
|
2905
|
+
CSS
|
2906
|
+
@charset "utf-32"
|
2907
|
+
fóó
|
2908
|
+
a: b
|
2909
|
+
SASS
|
2910
|
+
end
|
2911
|
+
|
2912
|
+
def test_utf8_bom
|
2913
|
+
assert_renders_encoded(<<CSS, <<SASS.force_encoding("BINARY"))
|
2914
|
+
@charset "UTF-8";
|
2915
|
+
fóó {
|
2916
|
+
a: b; }
|
2917
|
+
CSS
|
2918
|
+
\uFEFFfóó
|
2919
|
+
a: b
|
2920
|
+
SASS
|
2921
|
+
end
|
2922
|
+
|
2923
|
+
def test_utf16le_bom
|
2924
|
+
assert_renders_encoded(<<CSS.encode("UTF-16LE"), <<SASS.encode("UTF-16LE").force_encoding("BINARY"))
|
2925
|
+
@charset "UTF-16LE";
|
2926
|
+
fóó {
|
2927
|
+
a: b; }
|
2928
|
+
CSS
|
2929
|
+
\uFEFFfóó
|
2930
|
+
a: b
|
2931
|
+
SASS
|
2932
|
+
end
|
2933
|
+
|
2934
|
+
def test_utf32be_bom
|
2935
|
+
assert_renders_encoded(<<CSS.encode("UTF-32BE"), <<SASS.encode("UTF-32BE").force_encoding("BINARY"))
|
2936
|
+
@charset "UTF-32BE";
|
2937
|
+
fóó {
|
2938
|
+
a: b; }
|
2939
|
+
CSS
|
2940
|
+
\uFEFFfóó
|
2941
|
+
a: b
|
2942
|
+
SASS
|
2943
|
+
end
|
2944
|
+
|
2945
|
+
# Encoding Regression Test
|
2946
|
+
|
2947
|
+
def test_multibyte_prop_name
|
2948
|
+
assert_equal(<<CSS, render(<<SASS))
|
2949
|
+
@charset "UTF-8";
|
2950
|
+
#bar {
|
2951
|
+
cölor: blue; }
|
2952
|
+
CSS
|
2953
|
+
#bar
|
2954
|
+
cölor: blue
|
2955
|
+
SASS
|
2956
|
+
end
|
2957
|
+
|
2958
|
+
def test_multibyte_and_interpolation
|
2959
|
+
assert_equal(<<CSS, render(<<SCSS, :syntax => :scss))
|
2960
|
+
#bar {
|
2961
|
+
background: a 0%; }
|
2962
|
+
CSS
|
2963
|
+
#bar {
|
2964
|
+
//
|
2965
|
+
background: \#{a} 0%;
|
2966
|
+
}
|
2967
|
+
SCSS
|
2968
|
+
end
|
2969
|
+
end
|
2970
|
+
|
2886
2971
|
def test_original_filename_set
|
2887
2972
|
importer = MockImporter.new
|
2888
2973
|
importer.add_import("imported", "div{color:red}")
|
@@ -2896,10 +2981,16 @@ SASS
|
|
2896
2981
|
assert_equal original_filename, importer.engine("imported").options[:original_filename]
|
2897
2982
|
end
|
2898
2983
|
|
2984
|
+
def test_deprecated_PRECISION
|
2985
|
+
assert_warning(<<END) {assert_equal 100_000.0, Sass::Script::Number::PRECISION}
|
2986
|
+
Sass::Script::Number::PRECISION is deprecated and will be removed in a future release. Use Sass::Script::Number.precision_factor instead.
|
2987
|
+
END
|
2988
|
+
end
|
2989
|
+
|
2899
2990
|
def test_changing_precision
|
2900
|
-
old_precision = Sass::Script::
|
2991
|
+
old_precision = Sass::Script::Number.precision
|
2901
2992
|
begin
|
2902
|
-
Sass::Script::
|
2993
|
+
Sass::Script::Number.precision = 8
|
2903
2994
|
assert_equal <<CSS, render(<<SASS)
|
2904
2995
|
div {
|
2905
2996
|
maximum: 1.00000001;
|
@@ -2910,7 +3001,7 @@ div
|
|
2910
3001
|
too-much: 1.000000001
|
2911
3002
|
SASS
|
2912
3003
|
ensure
|
2913
|
-
Sass::Script::
|
3004
|
+
Sass::Script::Number.precision = old_precision
|
2914
3005
|
end
|
2915
3006
|
end
|
2916
3007
|
|
@@ -3104,154 +3195,6 @@ SASS
|
|
3104
3195
|
], e.sass_backtrace)
|
3105
3196
|
end
|
3106
3197
|
|
3107
|
-
def test_mixin_with_args_and_varargs_passed_no_var_args
|
3108
|
-
assert_equal <<CSS, render(<<SASS, :syntax => :scss)
|
3109
|
-
.foo {
|
3110
|
-
a: 1;
|
3111
|
-
b: 2;
|
3112
|
-
c: 3; }
|
3113
|
-
CSS
|
3114
|
-
@mixin three-or-more-args($a, $b, $c, $rest...) {
|
3115
|
-
a: $a;
|
3116
|
-
b: $b;
|
3117
|
-
c: $c;
|
3118
|
-
}
|
3119
|
-
|
3120
|
-
.foo {
|
3121
|
-
@include three-or-more-args($a: 1, $b: 2, $c: 3);
|
3122
|
-
}
|
3123
|
-
SASS
|
3124
|
-
|
3125
|
-
end
|
3126
|
-
|
3127
|
-
def test_debug_inspects_sass_objects
|
3128
|
-
assert_warning(<<END) {render("@debug (a: 1, b: 2)")}
|
3129
|
-
test_debug_inspects_sass_objects_inline.sass:1 DEBUG: (a: 1, b: 2)
|
3130
|
-
END
|
3131
|
-
assert_warning(<<END) {render("$map: (a: 1, b: 2); @debug $map", :syntax => :scss)}
|
3132
|
-
test_debug_inspects_sass_objects_inline.scss:1 DEBUG: (a: 1, b: 2)
|
3133
|
-
END
|
3134
|
-
end
|
3135
|
-
|
3136
|
-
def test_error_throws_sass_objects
|
3137
|
-
assert_raise_message(Sass::SyntaxError, "(a: 1, b: 2)") {render("@error (a: 1, b: 2)")}
|
3138
|
-
assert_raise_message(Sass::SyntaxError, "(a: 1, b: 2)") do
|
3139
|
-
render("$map: (a: 1, b: 2); @error $map", :syntax => :scss)
|
3140
|
-
end
|
3141
|
-
end
|
3142
|
-
|
3143
|
-
def test_default_arg_before_splat
|
3144
|
-
assert_equal <<CSS, render(<<SASS, :syntax => :scss)
|
3145
|
-
.foo-positional {
|
3146
|
-
a: 1;
|
3147
|
-
b: 2;
|
3148
|
-
positional-arguments: 3, 4;
|
3149
|
-
keyword-arguments: (); }
|
3150
|
-
|
3151
|
-
.foo-keywords {
|
3152
|
-
a: true;
|
3153
|
-
positional-arguments: ();
|
3154
|
-
keyword-arguments: (c: c, d: d); }
|
3155
|
-
CSS
|
3156
|
-
@mixin foo($a: true, $b: null, $arguments...) {
|
3157
|
-
a: $a;
|
3158
|
-
b: $b;
|
3159
|
-
positional-arguments: inspect($arguments);
|
3160
|
-
keyword-arguments: inspect(keywords($arguments));
|
3161
|
-
}
|
3162
|
-
.foo-positional {
|
3163
|
-
@include foo(1, 2, 3, 4);
|
3164
|
-
}
|
3165
|
-
.foo-keywords {
|
3166
|
-
@include foo($c: c, $d: d);
|
3167
|
-
}
|
3168
|
-
SASS
|
3169
|
-
end
|
3170
|
-
|
3171
|
-
def test_keyframes
|
3172
|
-
assert_equal <<CSS, render(<<SASS)
|
3173
|
-
@keyframes identifier {
|
3174
|
-
0% {
|
3175
|
-
top: 0;
|
3176
|
-
left: 0; }
|
3177
|
-
30% {
|
3178
|
-
top: 50px; }
|
3179
|
-
68%, 72% {
|
3180
|
-
left: 50px; }
|
3181
|
-
100% {
|
3182
|
-
top: 100px;
|
3183
|
-
left: 100%; } }
|
3184
|
-
CSS
|
3185
|
-
@keyframes identifier
|
3186
|
-
0%
|
3187
|
-
top: 0
|
3188
|
-
left: 0
|
3189
|
-
\#{"30%"}
|
3190
|
-
top: 50px
|
3191
|
-
68%, 72%
|
3192
|
-
left: 50px
|
3193
|
-
100%
|
3194
|
-
top: 100px
|
3195
|
-
left: 100%
|
3196
|
-
SASS
|
3197
|
-
end
|
3198
|
-
|
3199
|
-
def test_prefixed_keyframes
|
3200
|
-
assert_equal <<CSS, render(<<SASS)
|
3201
|
-
@-moz-keyframes identifier {
|
3202
|
-
0% {
|
3203
|
-
top: 0;
|
3204
|
-
left: 0; }
|
3205
|
-
30% {
|
3206
|
-
top: 50px; }
|
3207
|
-
68%, 72% {
|
3208
|
-
left: 50px; }
|
3209
|
-
100% {
|
3210
|
-
top: 100px;
|
3211
|
-
left: 100%; } }
|
3212
|
-
CSS
|
3213
|
-
@-moz-keyframes identifier
|
3214
|
-
0%
|
3215
|
-
top: 0
|
3216
|
-
left: 0
|
3217
|
-
\#{"30%"}
|
3218
|
-
top: 50px
|
3219
|
-
68%, 72%
|
3220
|
-
left: 50px
|
3221
|
-
100%
|
3222
|
-
top: 100px
|
3223
|
-
left: 100%
|
3224
|
-
SASS
|
3225
|
-
end
|
3226
|
-
|
3227
|
-
def test_uppercase_keyframes
|
3228
|
-
assert_equal <<CSS, render(<<SASS)
|
3229
|
-
@KEYFRAMES identifier {
|
3230
|
-
0% {
|
3231
|
-
top: 0;
|
3232
|
-
left: 0; }
|
3233
|
-
30% {
|
3234
|
-
top: 50px; }
|
3235
|
-
68%, 72% {
|
3236
|
-
left: 50px; }
|
3237
|
-
100% {
|
3238
|
-
top: 100px;
|
3239
|
-
left: 100%; } }
|
3240
|
-
CSS
|
3241
|
-
@KEYFRAMES identifier
|
3242
|
-
0%
|
3243
|
-
top: 0
|
3244
|
-
left: 0
|
3245
|
-
\#{"30%"}
|
3246
|
-
top: 50px
|
3247
|
-
68%, 72%
|
3248
|
-
left: 50px
|
3249
|
-
100%
|
3250
|
-
top: 100px
|
3251
|
-
left: 100%
|
3252
|
-
SASS
|
3253
|
-
end
|
3254
|
-
|
3255
3198
|
private
|
3256
3199
|
|
3257
3200
|
def assert_hash_has(hash, expected)
|