sass 3.3.0.alpha.256 → 3.3.0.alpha.353
Sign up to get free protection for your applications and to get access to all the features.
- data/REVISION +1 -1
- data/Rakefile +21 -1
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/lib/sass.rb +6 -3
- data/lib/sass/cache_stores/base.rb +1 -1
- data/lib/sass/cache_stores/chain.rb +2 -1
- data/lib/sass/cache_stores/filesystem.rb +2 -6
- data/lib/sass/cache_stores/memory.rb +1 -1
- data/lib/sass/cache_stores/null.rb +2 -2
- data/lib/sass/callbacks.rb +1 -0
- data/lib/sass/css.rb +6 -6
- data/lib/sass/engine.rb +60 -34
- data/lib/sass/environment.rb +3 -1
- data/lib/sass/error.rb +5 -5
- data/lib/sass/exec.rb +52 -25
- data/lib/sass/features.rb +0 -2
- data/lib/sass/importers/deprecated_path.rb +1 -1
- data/lib/sass/importers/filesystem.rb +8 -6
- data/lib/sass/logger/base.rb +3 -3
- data/lib/sass/logger/log_level.rb +4 -6
- data/lib/sass/media.rb +2 -2
- data/lib/sass/plugin.rb +4 -2
- data/lib/sass/plugin/compiler.rb +28 -15
- data/lib/sass/plugin/configuration.rb +15 -7
- data/lib/sass/plugin/merb.rb +1 -1
- data/lib/sass/plugin/staleness_checker.rb +24 -8
- data/lib/sass/repl.rb +3 -3
- data/lib/sass/script.rb +2 -1
- data/lib/sass/script/css_lexer.rb +8 -3
- data/lib/sass/script/css_parser.rb +6 -2
- data/lib/sass/script/functions.rb +164 -109
- data/lib/sass/script/lexer.rb +30 -20
- data/lib/sass/script/parser.rb +66 -37
- data/lib/sass/script/tree/funcall.rb +23 -14
- data/lib/sass/script/tree/interpolation.rb +5 -1
- data/lib/sass/script/tree/list_literal.rb +5 -4
- data/lib/sass/script/tree/map_literal.rb +1 -1
- data/lib/sass/script/tree/node.rb +2 -2
- data/lib/sass/script/tree/operation.rb +2 -1
- data/lib/sass/script/tree/selector.rb +3 -2
- data/lib/sass/script/tree/string_interpolation.rb +2 -1
- data/lib/sass/script/tree/variable.rb +4 -3
- data/lib/sass/script/value/base.rb +12 -14
- data/lib/sass/script/value/color.rb +35 -16
- data/lib/sass/script/value/helpers.rb +146 -0
- data/lib/sass/script/value/list.rb +24 -5
- data/lib/sass/script/value/map.rb +1 -1
- data/lib/sass/script/value/null.rb +13 -3
- data/lib/sass/script/value/number.rb +44 -35
- data/lib/sass/script/value/string.rb +2 -2
- data/lib/sass/scss/css_parser.rb +2 -1
- data/lib/sass/scss/parser.rb +143 -93
- data/lib/sass/scss/rx.rb +4 -4
- data/lib/sass/scss/script_lexer.rb +1 -0
- data/lib/sass/scss/script_parser.rb +1 -0
- data/lib/sass/scss/static_parser.rb +5 -5
- data/lib/sass/selector.rb +5 -2
- data/lib/sass/selector/abstract_sequence.rb +1 -1
- data/lib/sass/selector/comma_sequence.rb +16 -14
- data/lib/sass/selector/sequence.rb +38 -24
- data/lib/sass/selector/simple.rb +4 -4
- data/lib/sass/selector/simple_sequence.rb +21 -11
- data/lib/sass/source/map.rb +7 -2
- data/lib/sass/source/range.rb +1 -1
- data/lib/sass/supports.rb +3 -3
- data/lib/sass/tree/debug_node.rb +1 -1
- data/lib/sass/tree/function_node.rb +2 -1
- data/lib/sass/tree/if_node.rb +1 -1
- data/lib/sass/tree/import_node.rb +3 -4
- data/lib/sass/tree/prop_node.rb +4 -2
- data/lib/sass/tree/rule_node.rb +5 -2
- data/lib/sass/tree/visitors/base.rb +6 -6
- data/lib/sass/tree/visitors/check_nesting.rb +12 -9
- data/lib/sass/tree/visitors/convert.rb +34 -28
- data/lib/sass/tree/visitors/cssize.rb +4 -3
- data/lib/sass/tree/visitors/deep_copy.rb +1 -0
- data/lib/sass/tree/visitors/perform.rb +31 -16
- data/lib/sass/tree/visitors/to_css.rb +34 -16
- data/lib/sass/util.rb +88 -37
- data/lib/sass/util/multibyte_string_scanner.rb +2 -0
- data/lib/sass/util/ordered_hash.rb +20 -18
- data/lib/sass/util/subset_map.rb +3 -2
- data/lib/sass/util/test.rb +0 -1
- data/lib/sass/version.rb +9 -5
- data/test/rubocop_extensions.rb +70 -0
- data/test/sass/functions_test.rb +20 -1
- data/test/sass/importer_test.rb +2 -1
- data/test/sass/script_test.rb +4 -0
- data/test/sass/source_map_test.rb +1 -1
- data/test/sass/util_test.rb +49 -0
- data/test/sass/value_helpers_test.rb +181 -0
- metadata +13 -9
data/lib/sass/util/subset_map.rb
CHANGED
@@ -72,7 +72,8 @@ module Sass
|
|
72
72
|
# @see #[]
|
73
73
|
def get(set)
|
74
74
|
res = set.map do |k|
|
75
|
-
|
75
|
+
subsets = @hash[k]
|
76
|
+
next unless subsets
|
76
77
|
subsets.map do |subenum, subset, index|
|
77
78
|
next unless subset.subset?(set)
|
78
79
|
[index, subenum]
|
@@ -83,7 +84,7 @@ module Sass
|
|
83
84
|
res.uniq!
|
84
85
|
res.sort!
|
85
86
|
res.map! {|i, s| [@vals[i], s]}
|
86
|
-
|
87
|
+
res
|
87
88
|
end
|
88
89
|
|
89
90
|
# Same as \{#get}, but doesn't return the subsets of the argument
|
data/lib/sass/util/test.rb
CHANGED
data/lib/sass/version.rb
CHANGED
@@ -14,7 +14,8 @@ module Sass
|
|
14
14
|
# The `:name` key has the name of the version.
|
15
15
|
# The `:string` key contains a human-readable string representation of the version.
|
16
16
|
# The `:number` key is the major, minor, and teeny keys separated by periods.
|
17
|
-
# The `:date` key, which is not guaranteed to be defined, is the `DateTime`
|
17
|
+
# The `:date` key, which is not guaranteed to be defined, is the `DateTime`
|
18
|
+
# at which this release was cut.
|
18
19
|
# If Sass is checked out from Git, the `:rev` key will have the revision hash.
|
19
20
|
# For example:
|
20
21
|
#
|
@@ -43,6 +44,8 @@ module Sass
|
|
43
44
|
# }
|
44
45
|
#
|
45
46
|
# @return [{Symbol => String/Fixnum}] The version hash
|
47
|
+
# @comment
|
48
|
+
# rubocop:disable ClassVars
|
46
49
|
def version
|
47
50
|
return @@version if defined?(@@version)
|
48
51
|
|
@@ -56,7 +59,7 @@ module Sass
|
|
56
59
|
:name => name
|
57
60
|
}
|
58
61
|
|
59
|
-
if date = version_date
|
62
|
+
if (date = version_date)
|
60
63
|
@@version[:date] = date
|
61
64
|
end
|
62
65
|
|
@@ -69,7 +72,7 @@ module Sass
|
|
69
72
|
@@version[:number] = numbers.join('.')
|
70
73
|
@@version[:string] = @@version[:number].dup
|
71
74
|
|
72
|
-
if rev = revision_number
|
75
|
+
if (rev = revision_number)
|
73
76
|
@@version[:rev] = rev
|
74
77
|
unless rev[0] == ?(
|
75
78
|
@@version[:string] << "." << rev[0...7]
|
@@ -79,6 +82,7 @@ module Sass
|
|
79
82
|
@@version[:string] << " (#{name})"
|
80
83
|
@@version
|
81
84
|
end
|
85
|
+
# rubocop:enable ClassVars
|
82
86
|
|
83
87
|
private
|
84
88
|
|
@@ -104,12 +108,12 @@ module Sass
|
|
104
108
|
return sha
|
105
109
|
end
|
106
110
|
end
|
107
|
-
|
111
|
+
nil
|
108
112
|
end
|
109
113
|
|
110
114
|
def version_date
|
111
115
|
return unless File.exists?(scope('VERSION_DATE'))
|
112
|
-
|
116
|
+
DateTime.parse(File.read(scope('VERSION_DATE')).strip)
|
113
117
|
end
|
114
118
|
end
|
115
119
|
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "rubocop/cop/style/surrounding_space"
|
2
|
+
|
3
|
+
module Rubocop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# Common functionality for checking surrounding space.
|
7
|
+
# This is monkeypatching an existing class.
|
8
|
+
class SpaceAroundBlockBraces < Cop
|
9
|
+
MSG_RIGHT_SPACE = "Space found to the left of '}'."
|
10
|
+
MSG_LEFT_SPACE = "Space found to the right of '{'."
|
11
|
+
def investigate(processed_source)
|
12
|
+
return unless processed_source.ast
|
13
|
+
@processed_source = processed_source
|
14
|
+
|
15
|
+
processed_source.tokens.each_cons(2) do |t1, t2|
|
16
|
+
next if ([t1.pos, t2.pos] - positions_not_to_check).size < 2
|
17
|
+
|
18
|
+
type1, type2 = t1.type, t2.type
|
19
|
+
check(t1, t2, MSG_LEFT) if type2 == :tLCURLY
|
20
|
+
if type1 == :tLCURLY
|
21
|
+
if type2 == :tPIPE && cop_config['NoSpaceBeforeBlockParameters']
|
22
|
+
check_no_space(t1, t2, MSG_PIPE)
|
23
|
+
elsif cop_config['NoSpaceAfterOpeningCurly']
|
24
|
+
check_no_space(t1, t2, MSG_LEFT_SPACE)
|
25
|
+
else
|
26
|
+
check(t1, t2, MSG_LEFT)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
if type2 == :tRCURLY
|
30
|
+
if cop_config['NoSpaceBeforeClosingCurly']
|
31
|
+
check_no_space(t1, t2, MSG_RIGHT_SPACE)
|
32
|
+
else
|
33
|
+
check(t1, t2, MSG_RIGHT)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def check_no_space(t1, t2, msg)
|
40
|
+
convention(nil, t1.pos, msg) if space_between?(t1, t2)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# This is monkeypatching an existing class.
|
45
|
+
class RedundantReturn < Cop
|
46
|
+
def check(node)
|
47
|
+
return unless node
|
48
|
+
|
49
|
+
if node.type == :return
|
50
|
+
convention(node, :keyword)
|
51
|
+
elsif node.type == :begin
|
52
|
+
expressions = *node
|
53
|
+
last_expr = expressions.last
|
54
|
+
|
55
|
+
if last_expr && last_expr.type == :return
|
56
|
+
if cop_config['AllowMultipleReturnValues']
|
57
|
+
return if last_expr.children.size > 1
|
58
|
+
end
|
59
|
+
convention(last_expr, :keyword)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Rubocop::Config.default_configuration["SpaceAroundBlockBraces"]["NoSpaceBeforeClosingCurly"] = false
|
69
|
+
Rubocop::Config.default_configuration["SpaceAroundBlockBraces"]["NoSpaceAfterOpeningCurly"] = false
|
70
|
+
Rubocop::Config.default_configuration["RedundantReturn"]["AllowMultipleReturnValues"] = false
|
data/test/sass/functions_test.rb
CHANGED
@@ -163,7 +163,7 @@ class SassFunctionTest < Test::Unit::TestCase
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def test_min
|
166
|
-
|
166
|
+
assert_equal("1", evaluate("min(1, 2, 3)"))
|
167
167
|
assert_equal("1", evaluate("min(3px, 2px, 1)"))
|
168
168
|
assert_equal("4em", evaluate("min(4em)"))
|
169
169
|
assert_equal("10cm", evaluate("min(10cm, 6in)"))
|
@@ -1038,6 +1038,7 @@ MSG
|
|
1038
1038
|
assert_equal("3", evaluate("nth(1 2 3, -1)"))
|
1039
1039
|
assert_equal("1", evaluate("nth(1 2 3, -3)"))
|
1040
1040
|
assert_equal("3", evaluate("nth((1, 2, 3), 3)"))
|
1041
|
+
assert_equal("3", evaluate("nth($list: (1, 2, 3), $n: 3)"))
|
1041
1042
|
assert_equal("foo", evaluate("nth(foo, 1)"))
|
1042
1043
|
assert_equal("bar baz", evaluate("nth(foo (bar baz) bang, 2)"))
|
1043
1044
|
assert_error_message("List index 0 must be a non-zero integer for `nth'", "nth(foo, 0)")
|
@@ -1052,6 +1053,24 @@ MSG
|
|
1052
1053
|
assert_equal("bar baz", evaluate("nth((foo: bar, bar: baz), 2)"))
|
1053
1054
|
end
|
1054
1055
|
|
1056
|
+
def test_set_nth
|
1057
|
+
assert_equal("a 2 3", evaluate("set-nth(1 2 3, 1, a)"))
|
1058
|
+
assert_equal("1 a 3", evaluate("set-nth(1 2 3, 2, a)"))
|
1059
|
+
assert_equal("1 2 a", evaluate("set-nth(1 2 3, -1, a)"))
|
1060
|
+
assert_equal("a 2 3", evaluate("set-nth(1 2 3, -3, a)"))
|
1061
|
+
assert_equal("a 2 3", evaluate("set-nth($list: 1 2 3, $n: -3, $value: a)"))
|
1062
|
+
assert_equal("1, 2, a", evaluate("set-nth((1, 2, 3), 3, a)"))
|
1063
|
+
assert_equal("a", evaluate("set-nth(foo, 1, a)"))
|
1064
|
+
assert_equal("foo, a b, baz", evaluate("set-nth((foo, bar, baz), 2, (a b))"))
|
1065
|
+
assert_error_message("List index 0 must be a non-zero integer for `set-nth'", "set-nth(foo, 0, a)")
|
1066
|
+
assert_error_message("List index is -10 but list is only 1 item long for `set-nth'", "set-nth(foo, -10, a)")
|
1067
|
+
assert_error_message("List index 1.5 must be a non-zero integer for `set-nth'", "set-nth(foo, 1.5, a)")
|
1068
|
+
assert_error_message("List index is 5 but list is only 4 items long for `set-nth'", "set-nth(1 2 3 4, 5, a)")
|
1069
|
+
assert_error_message("List index is 2 but list is only 1 item long for `set-nth'", "set-nth(foo, 2, a)")
|
1070
|
+
assert_error_message("List index is 1 but list has no items for `set-nth'", "set-nth((), 1, a)")
|
1071
|
+
assert_error_message("$n: \"foo\" is not a number for `set-nth'", "set-nth(1 2 3, foo, a)")
|
1072
|
+
end
|
1073
|
+
|
1055
1074
|
def test_join
|
1056
1075
|
assert_equal("1 2 3", evaluate("join(1 2, 3)"))
|
1057
1076
|
assert_equal("1 2 3", evaluate("join(1, 2 3)"))
|
data/test/sass/importer_test.rb
CHANGED
data/test/sass/script_test.rb
CHANGED
@@ -753,7 +753,7 @@ CSS
|
|
753
753
|
start_positions = {}
|
754
754
|
text.split("\n").each_with_index do |line_text, line|
|
755
755
|
line += 1 # lines shoud be 1-based
|
756
|
-
while match = line_text.match(ANNOTATION_REGEX)
|
756
|
+
while (match = line_text.match(ANNOTATION_REGEX))
|
757
757
|
closing = !match[1].empty?
|
758
758
|
name = match[2]
|
759
759
|
match_offsets = match.offset(0)
|
data/test/sass/util_test.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require File.dirname(__FILE__) + '/../test_helper'
|
3
3
|
require 'pathname'
|
4
|
+
require 'tmpdir'
|
4
5
|
|
5
6
|
class UtilTest < Test::Unit::TestCase
|
6
7
|
include Sass::Util
|
@@ -351,4 +352,52 @@ class UtilTest < Test::Unit::TestCase
|
|
351
352
|
assert_equal vlq, vlq_from_decimal_array
|
352
353
|
assert_equal decimal_array, decimal_array_from_vlq
|
353
354
|
end
|
355
|
+
|
356
|
+
def test_atomic_writes
|
357
|
+
# when using normal writes, this test fails about 90% of the time.
|
358
|
+
filename = File.join(Dir.tmpdir, "test_atomic")
|
359
|
+
5.times do
|
360
|
+
writes_to_perform = %w(1 2 3 4 5 6 7 8 9).map {|i| "#{i}\n" * 100_000}
|
361
|
+
threads = writes_to_perform.map do |to_write|
|
362
|
+
Thread.new do
|
363
|
+
# To see this test fail with a normal write,
|
364
|
+
# change to the standard file open mechanism:
|
365
|
+
# open(filename, "w") do |f|
|
366
|
+
atomic_create_and_write_file(filename) do |f|
|
367
|
+
f.write(to_write)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
loop do
|
372
|
+
contents = File.exist?(filename) ? File.read(filename) : nil
|
373
|
+
next if contents.nil? || contents.size == 0
|
374
|
+
unless writes_to_perform.include?(contents)
|
375
|
+
if contents.size != writes_to_perform.first.size
|
376
|
+
fail "Incomplete write detected: was #{contents.size} characters, " +
|
377
|
+
"should have been #{writes_to_perform.first.size}"
|
378
|
+
else
|
379
|
+
fail "Corrupted read/write detected"
|
380
|
+
end
|
381
|
+
end
|
382
|
+
break if threads.all? {|t| !t.alive?}
|
383
|
+
end
|
384
|
+
threads.each {|t| t.join}
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
class FakeError < RuntimeError; end
|
389
|
+
|
390
|
+
def test_atomic_writes_handles_exceptions
|
391
|
+
filename = File.join(Dir.tmpdir, "test_atomic_exception")
|
392
|
+
FileUtils.rm_f(filename)
|
393
|
+
tmp_filename = nil
|
394
|
+
assert_raises FakeError do
|
395
|
+
atomic_create_and_write_file(filename) do |f|
|
396
|
+
tmp_filename = f.path
|
397
|
+
raise FakeError.new "Borken"
|
398
|
+
end
|
399
|
+
end
|
400
|
+
assert !File.exist?(filename)
|
401
|
+
assert !File.exist?(tmp_filename)
|
402
|
+
end
|
354
403
|
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
3
|
+
|
4
|
+
class ValueHelpersTest < Test::Unit::TestCase
|
5
|
+
include Sass::Script
|
6
|
+
include Sass::Script::Value::Helpers
|
7
|
+
|
8
|
+
def test_bool
|
9
|
+
assert_same Value::Bool::TRUE, bool(true)
|
10
|
+
assert_same Value::Bool::FALSE, bool(false)
|
11
|
+
assert_same Value::Bool::FALSE, bool(nil)
|
12
|
+
assert_same Value::Bool::TRUE, bool(Object.new)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_hex_color_with_three_digits
|
16
|
+
color = hex_color("F07")
|
17
|
+
assert_equal 255, color.red
|
18
|
+
assert_equal 0, color.green
|
19
|
+
assert_equal 119, color.blue
|
20
|
+
assert_equal 1, color.alpha
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_hex_color_without_hash
|
24
|
+
color_without_hash = hex_color("FF007F")
|
25
|
+
assert_equal 255, color_without_hash.red
|
26
|
+
assert_equal 0, color_without_hash.green
|
27
|
+
assert_equal 127, color_without_hash.blue
|
28
|
+
assert_equal 1, color_without_hash.alpha
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_hex_color_with_hash
|
32
|
+
color_with_hash = hex_color("#FF007F")
|
33
|
+
assert_equal 255, color_with_hash.red
|
34
|
+
assert_equal 0, color_with_hash.green
|
35
|
+
assert_equal 127, color_with_hash.blue
|
36
|
+
assert_equal 1, color_with_hash.alpha
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_malformed_hex_color
|
40
|
+
assert_raises ArgumentError do
|
41
|
+
hex_color("green")
|
42
|
+
end
|
43
|
+
assert_raises ArgumentError do
|
44
|
+
hex_color("#abcd")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def test_hex_color_with_alpha
|
50
|
+
color_with_alpha = hex_color("FF007F", 0.5)
|
51
|
+
assert_equal 0.5, color_with_alpha.alpha
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_hex_color_alpha_enforces_0_to_1
|
55
|
+
assert_raises ArgumentError do
|
56
|
+
hex_color("FF007F", 50)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_hsl_color_without_alpha
|
61
|
+
no_alpha = hsl_color(1, 0.5, 1)
|
62
|
+
assert_equal 1, no_alpha.hue
|
63
|
+
assert_equal 0.5, no_alpha.saturation
|
64
|
+
assert_equal 1, no_alpha.lightness
|
65
|
+
assert_equal 1, no_alpha.alpha
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_hsl_color_with_alpha
|
69
|
+
has_alpha = hsl_color(1, 0.5, 1, 0.5)
|
70
|
+
assert_equal 1, has_alpha.hue
|
71
|
+
assert_equal 0.5, has_alpha.saturation
|
72
|
+
assert_equal 1, has_alpha.lightness
|
73
|
+
assert_equal 0.5, has_alpha.alpha
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_rgb_color_without_alpha
|
77
|
+
no_alpha = rgb_color(255, 0, 0)
|
78
|
+
assert_equal 255, no_alpha.red
|
79
|
+
assert_equal 0, no_alpha.green
|
80
|
+
assert_equal 0, no_alpha.blue
|
81
|
+
assert_equal 1, no_alpha.alpha
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_rgb_color_with_alpha
|
85
|
+
has_alpha = rgb_color(255, 255, 255, 0.5)
|
86
|
+
assert_equal 255, has_alpha.red
|
87
|
+
assert_equal 255, has_alpha.green
|
88
|
+
assert_equal 255, has_alpha.blue
|
89
|
+
assert_equal 0.5, has_alpha.alpha
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_number
|
93
|
+
n = number(1)
|
94
|
+
assert_equal 1, n.value
|
95
|
+
assert_equal "1", n.to_sass
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_number_with_single_unit
|
99
|
+
n = number(1, "px")
|
100
|
+
assert_equal 1, n.value
|
101
|
+
assert_equal "1px", n.to_sass
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_number_with_singal_numerator_and_denominator
|
105
|
+
ratio = number(1, "px/em")
|
106
|
+
assert_equal "1px/em", ratio.to_sass
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_number_with_many_numerator_and_denominator_units
|
110
|
+
complex = number(1, "px*in/em*%")
|
111
|
+
assert_equal "1in*px/%*em", complex.to_sass
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_number_with_many_numerator_and_denominator_units_with_spaces
|
115
|
+
complex = number(1, "px * in / em * %")
|
116
|
+
assert_equal "1in*px/%*em", complex.to_sass
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_number_with_malformed_units
|
120
|
+
assert_raises ArgumentError do
|
121
|
+
number(1, "px/em/%")
|
122
|
+
end
|
123
|
+
assert_raises ArgumentError do
|
124
|
+
number(1, "/")
|
125
|
+
end
|
126
|
+
assert_raises ArgumentError do
|
127
|
+
number(1, "px/")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_space_list
|
132
|
+
l = list(number(1, "px"), hex_color("#f71"), :space)
|
133
|
+
l.options = {}
|
134
|
+
assert_kind_of Sass::Script::Value::List, l
|
135
|
+
assert_equal "1px #ff7711", l.to_sass
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_comma_list
|
139
|
+
l = list(number(1, "px"), hex_color("#f71"), :comma)
|
140
|
+
l.options = {}
|
141
|
+
assert_kind_of Sass::Script::Value::List, l
|
142
|
+
assert_equal "1px, #ff7711", l.to_sass
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_missing_list_type
|
146
|
+
assert_raises ArgumentError do
|
147
|
+
list(number(1, "px"), hex_color("#f71"))
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_null
|
152
|
+
assert_kind_of Sass::Script::Value::Null, null
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_quoted_string
|
156
|
+
s = quoted_string("sassy string")
|
157
|
+
s.options = {}
|
158
|
+
assert_kind_of Sass::Script::Value::String, s
|
159
|
+
assert_equal "sassy string", s.value
|
160
|
+
assert_equal :string, s.type
|
161
|
+
assert_equal '"sassy string"', s.to_sass
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_identifier
|
165
|
+
s = identifier("a-sass-ident")
|
166
|
+
s.options = {}
|
167
|
+
assert_kind_of Sass::Script::Value::String, s
|
168
|
+
assert_equal "a-sass-ident", s.value
|
169
|
+
assert_equal :identifier, s.type
|
170
|
+
assert_equal "a-sass-ident", s.to_sass
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_unquoted_string
|
174
|
+
s = unquoted_string("a-sass-ident")
|
175
|
+
s.options = {}
|
176
|
+
assert_kind_of Sass::Script::Value::String, s
|
177
|
+
assert_equal "a-sass-ident", s.value
|
178
|
+
assert_equal :identifier, s.type
|
179
|
+
assert_equal "a-sass-ident", s.to_sass
|
180
|
+
end
|
181
|
+
end
|