haml-edge 2.3.209 → 2.3.210
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +2 -0
- data/EDGE_GEM_VERSION +1 -1
- data/Rakefile +24 -2
- data/VERSION +1 -1
- data/lib/haml/exec.rb +11 -4
- data/lib/haml/filters.rb +3 -0
- data/lib/haml/helpers/action_view_extensions.rb +4 -2
- data/lib/haml/helpers/action_view_mods.rb +6 -4
- data/lib/haml/helpers.rb +2 -10
- data/lib/haml/html.rb +0 -1
- data/lib/haml/precompiler.rb +37 -30
- data/lib/haml/railtie.rb +6 -2
- data/lib/haml/root.rb +4 -0
- data/lib/haml/template.rb +2 -0
- data/lib/haml/util/subset_map.rb +101 -0
- data/lib/haml/util.rb +74 -0
- data/lib/haml.rb +5 -2
- data/lib/sass/engine.rb +36 -31
- data/lib/sass/files.rb +1 -1
- data/lib/sass/plugin/staleness_checker.rb +9 -9
- data/lib/sass/plugin.rb +21 -0
- data/lib/sass/script/color.rb +4 -3
- data/lib/sass/script/css_lexer.rb +11 -1
- data/lib/sass/script/css_parser.rb +4 -1
- data/lib/sass/script/funcall.rb +9 -0
- data/lib/sass/script/interpolation.rb +21 -0
- data/lib/sass/script/lexer.rb +30 -13
- data/lib/sass/script/node.rb +1 -1
- data/lib/sass/script/number.rb +4 -5
- data/lib/sass/script/parser.rb +13 -14
- data/lib/sass/script/string.rb +8 -2
- data/lib/sass/script/string_interpolation.rb +27 -4
- data/lib/sass/script.rb +1 -2
- data/lib/sass/scss/css_parser.rb +5 -3
- data/lib/sass/scss/parser.rb +146 -64
- data/lib/sass/scss/rx.rb +9 -1
- data/lib/sass/scss/sass_parser.rb +11 -0
- data/lib/sass/scss/script_lexer.rb +2 -0
- data/lib/sass/scss/static_parser.rb +48 -0
- data/lib/sass/scss.rb +3 -0
- data/lib/sass/selector/abstract_sequence.rb +40 -0
- data/lib/sass/selector/comma_sequence.rb +80 -0
- data/lib/sass/selector/sequence.rb +194 -0
- data/lib/sass/selector/simple.rb +107 -0
- data/lib/sass/selector/simple_sequence.rb +161 -0
- data/lib/sass/selector.rb +353 -0
- data/lib/sass/tree/comment_node.rb +1 -0
- data/lib/sass/tree/debug_node.rb +1 -0
- data/lib/sass/tree/directive_node.rb +1 -0
- data/lib/sass/tree/extend_node.rb +60 -0
- data/lib/sass/tree/for_node.rb +1 -0
- data/lib/sass/tree/if_node.rb +2 -0
- data/lib/sass/tree/import_node.rb +2 -0
- data/lib/sass/tree/mixin_def_node.rb +1 -0
- data/lib/sass/tree/mixin_node.rb +21 -5
- data/lib/sass/tree/node.rb +59 -12
- data/lib/sass/tree/prop_node.rb +20 -21
- data/lib/sass/tree/root_node.rb +8 -17
- data/lib/sass/tree/rule_node.rb +49 -100
- data/lib/sass/tree/variable_node.rb +1 -0
- data/lib/sass/tree/warn_node.rb +1 -0
- data/lib/sass/tree/while_node.rb +1 -0
- data/lib/sass.rb +1 -0
- data/test/haml/engine_test.rb +185 -3
- data/test/haml/helper_test.rb +25 -2
- data/test/haml/template_test.rb +2 -2
- data/test/haml/templates/helpers.haml +13 -0
- data/test/haml/util/subset_map_test.rb +91 -0
- data/test/haml/util_test.rb +25 -0
- data/test/sass/conversion_test.rb +23 -3
- data/test/sass/engine_test.rb +50 -7
- data/test/sass/extend_test.rb +1045 -0
- data/test/sass/results/complex.css +0 -1
- data/test/sass/results/script.css +1 -1
- data/test/sass/script_conversion_test.rb +16 -0
- data/test/sass/script_test.rb +37 -4
- data/test/sass/scss/css_test.rb +17 -3
- data/test/sass/scss/rx_test.rb +1 -1
- data/test/sass/scss/scss_test.rb +30 -0
- data/test/sass/templates/complex.sass +0 -2
- data/test/test_helper.rb +5 -0
- metadata +17 -3
@@ -0,0 +1,91 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
3
|
+
|
4
|
+
class SubsetMapTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@ssm = Haml::Util::SubsetMap.new
|
7
|
+
@ssm[Set[1, 2]] = "Foo"
|
8
|
+
@ssm[Set["fizz", "fazz"]] = "Bar"
|
9
|
+
|
10
|
+
@ssm[Set[:foo, :bar]] = "Baz"
|
11
|
+
@ssm[Set[:foo, :bar, :baz]] = "Bang"
|
12
|
+
|
13
|
+
@ssm[Set[:bip, :bop, :blip]] = "Qux"
|
14
|
+
@ssm[Set[:bip, :bop]] = "Thram"
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_equal_keys
|
18
|
+
assert_equal [["Foo", Set[1, 2]]], @ssm.get(Set[1, 2])
|
19
|
+
assert_equal [["Bar", Set["fizz", "fazz"]]], @ssm.get(Set["fizz", "fazz"])
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_subset_keys
|
23
|
+
assert_equal [["Foo", Set[1, 2]]], @ssm.get(Set[1, 2, "fuzz"])
|
24
|
+
assert_equal [["Bar", Set["fizz", "fazz"]]], @ssm.get(Set["fizz", "fazz", 3])
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_superset_keys
|
28
|
+
assert_equal [], @ssm.get(Set[1])
|
29
|
+
assert_equal [], @ssm.get(Set[2])
|
30
|
+
assert_equal [], @ssm.get(Set["fizz"])
|
31
|
+
assert_equal [], @ssm.get(Set["fazz"])
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_disjoint_keys
|
35
|
+
assert_equal [], @ssm.get(Set[3, 4])
|
36
|
+
assert_equal [], @ssm.get(Set["fuzz", "frizz"])
|
37
|
+
assert_equal [], @ssm.get(Set["gran", 15])
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_semi_disjoint_keys
|
41
|
+
assert_equal [], @ssm.get(Set[2, 3])
|
42
|
+
assert_equal [], @ssm.get(Set["fizz", "fuzz"])
|
43
|
+
assert_equal [], @ssm.get(Set[1, "fazz"])
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_empty_key_set
|
47
|
+
assert_raise(ArgumentError) {@ssm[Set[]] = "Fail"}
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_empty_key_get
|
51
|
+
assert_equal [], @ssm.get(Set[])
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_multiple_subsets
|
55
|
+
assert_equal [["Foo", Set[1, 2]], ["Bar", Set["fizz", "fazz"]]], @ssm.get(Set[1, 2, "fizz", "fazz"])
|
56
|
+
assert_equal [["Foo", Set[1, 2]], ["Bar", Set["fizz", "fazz"]]], @ssm.get(Set[1, 2, 3, "fizz", "fazz", "fuzz"])
|
57
|
+
|
58
|
+
assert_equal [["Baz", Set[:foo, :bar]]], @ssm.get(Set[:foo, :bar])
|
59
|
+
assert_equal [["Baz", Set[:foo, :bar]], ["Bang", Set[:foo, :bar, :baz]]], @ssm.get(Set[:foo, :bar, :baz])
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_bracket_bracket
|
63
|
+
assert_equal ["Foo"], @ssm[Set[1, 2, "fuzz"]]
|
64
|
+
assert_equal ["Baz", "Bang"], @ssm[Set[:foo, :bar, :baz]]
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_order_preserved
|
68
|
+
@ssm[Set[10, 11, 12]] = 1
|
69
|
+
@ssm[Set[10, 11]] = 2
|
70
|
+
@ssm[Set[11]] = 3
|
71
|
+
@ssm[Set[11, 12]] = 4
|
72
|
+
@ssm[Set[9, 10, 11, 12, 13]] = 5
|
73
|
+
@ssm[Set[10, 13]] = 6
|
74
|
+
|
75
|
+
assert_equal(
|
76
|
+
[[1, Set[10, 11, 12]], [2, Set[10, 11]], [3, Set[11]], [4, Set[11, 12]],
|
77
|
+
[5, Set[9, 10, 11, 12, 13]], [6, Set[10, 13]]],
|
78
|
+
@ssm.get(Set[9, 10, 11, 12, 13]))
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_multiple_equal_values
|
82
|
+
@ssm[Set[11, 12]] = 1
|
83
|
+
@ssm[Set[12, 13]] = 2
|
84
|
+
@ssm[Set[13, 14]] = 1
|
85
|
+
@ssm[Set[14, 15]] = 1
|
86
|
+
|
87
|
+
assert_equal(
|
88
|
+
[[1, Set[11, 12]], [2, Set[12, 13]], [1, Set[13, 14]], [1, Set[14, 15]]],
|
89
|
+
@ssm.get(Set[11, 12, 13, 14, 15]))
|
90
|
+
end
|
91
|
+
end
|
data/test/haml/util_test.rb
CHANGED
@@ -66,6 +66,24 @@ class UtilTest < Test::Unit::TestCase
|
|
66
66
|
merge_adjacent_strings(["foo ", "bar ", "baz", :bang, "biz", " bop", 12]))
|
67
67
|
end
|
68
68
|
|
69
|
+
def test_intersperse
|
70
|
+
assert_equal(["foo", " ", "bar", " ", "baz"],
|
71
|
+
intersperse(%w[foo bar baz], " "))
|
72
|
+
assert_equal([], intersperse([], " "))
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_substitute
|
76
|
+
assert_equal(["foo", "bar", "baz", 3, 4],
|
77
|
+
substitute([1, 2, 3, 4], [1, 2], ["foo", "bar", "baz"]))
|
78
|
+
assert_equal([1, "foo", "bar", "baz", 4],
|
79
|
+
substitute([1, 2, 3, 4], [2, 3], ["foo", "bar", "baz"]))
|
80
|
+
assert_equal([1, 2, "foo", "bar", "baz"],
|
81
|
+
substitute([1, 2, 3, 4], [3, 4], ["foo", "bar", "baz"]))
|
82
|
+
|
83
|
+
assert_equal([1, "foo", "bar", "baz", 2, 3, 4],
|
84
|
+
substitute([1, 2, 2, 2, 3, 4], [2, 2], ["foo", "bar", "baz"]))
|
85
|
+
end
|
86
|
+
|
69
87
|
def test_strip_string_array
|
70
88
|
assert_equal(["foo ", " bar ", " baz"],
|
71
89
|
strip_string_array([" foo ", " bar ", " baz "]))
|
@@ -75,6 +93,13 @@ class UtilTest < Test::Unit::TestCase
|
|
75
93
|
strip_string_array([" foo ", " bar ", :baz]))
|
76
94
|
end
|
77
95
|
|
96
|
+
def test_paths
|
97
|
+
assert_equal([[1, 3, 5], [2, 3, 5], [1, 4, 5], [2, 4, 5]],
|
98
|
+
paths([[1, 2], [3, 4], [5]]))
|
99
|
+
assert_equal([[]], paths([]))
|
100
|
+
assert_equal([[1, 2, 3]], paths([[1], [2], [3]]))
|
101
|
+
end
|
102
|
+
|
78
103
|
def test_silence_warnings
|
79
104
|
old_stderr, $stderr = $stderr, StringIO.new
|
80
105
|
warn "Out"
|
@@ -183,7 +183,7 @@ SASS
|
|
183
183
|
def test_multiline_properties
|
184
184
|
assert_scss_to_sass <<SASS, <<SCSS
|
185
185
|
foo bar
|
186
|
-
baz: bip
|
186
|
+
baz: bip bam boon
|
187
187
|
SASS
|
188
188
|
foo bar {
|
189
189
|
baz:
|
@@ -194,7 +194,7 @@ SCSS
|
|
194
194
|
|
195
195
|
assert_scss_to_scss <<OUT, <<IN
|
196
196
|
foo bar {
|
197
|
-
baz: bip
|
197
|
+
baz: bip bam boon; }
|
198
198
|
OUT
|
199
199
|
foo bar {
|
200
200
|
baz:
|
@@ -915,7 +915,7 @@ SCSS
|
|
915
915
|
assert_selector_renders['> E']
|
916
916
|
assert_selector_renders['+ E']
|
917
917
|
assert_selector_renders['~ E']
|
918
|
-
assert_selector_renders['
|
918
|
+
assert_selector_renders['> > E']
|
919
919
|
|
920
920
|
assert_selector_renders['E*']
|
921
921
|
assert_selector_renders['E*.foo']
|
@@ -1031,6 +1031,26 @@ div
|
|
1031
1031
|
SASS
|
1032
1032
|
end
|
1033
1033
|
|
1034
|
+
def test_sass2_var_in_property_interpolation
|
1035
|
+
assert_sass_to_scss <<SCSS, <<SASS
|
1036
|
+
foo {
|
1037
|
+
a: b \#{$c} d; }
|
1038
|
+
SCSS
|
1039
|
+
foo
|
1040
|
+
a: b \#{!c} d
|
1041
|
+
SASS
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
def test_sass2_var_in_selector_interpolation
|
1045
|
+
assert_sass_to_scss <<SCSS, <<SASS
|
1046
|
+
foo-\#{$c} {
|
1047
|
+
a: b; }
|
1048
|
+
SCSS
|
1049
|
+
foo-\#{!c}
|
1050
|
+
a: b
|
1051
|
+
SASS
|
1052
|
+
end
|
1053
|
+
|
1034
1054
|
private
|
1035
1055
|
|
1036
1056
|
def assert_sass_to_sass(sass, options = {})
|
data/test/sass/engine_test.rb
CHANGED
@@ -592,6 +592,36 @@ END
|
|
592
592
|
assert_equal("@a{b:c;#d{e:f}g:h}\n", render(to_render, :style => :compressed))
|
593
593
|
end
|
594
594
|
|
595
|
+
def test_property_hacks
|
596
|
+
assert_equal(<<CSS, render(<<SASS))
|
597
|
+
foo {
|
598
|
+
_name: val;
|
599
|
+
*name: val;
|
600
|
+
#name: val;
|
601
|
+
.name: val;
|
602
|
+
name: val; }
|
603
|
+
CSS
|
604
|
+
foo
|
605
|
+
_name: val
|
606
|
+
*name: val
|
607
|
+
#name: val
|
608
|
+
.name: val
|
609
|
+
name: val
|
610
|
+
SASS
|
611
|
+
end
|
612
|
+
|
613
|
+
def test_properties_with_space_after_colon
|
614
|
+
assert_equal <<CSS, render(<<SASS)
|
615
|
+
foo {
|
616
|
+
bar: baz;
|
617
|
+
bizz: bap; }
|
618
|
+
CSS
|
619
|
+
foo
|
620
|
+
bar : baz
|
621
|
+
bizz : bap
|
622
|
+
SASS
|
623
|
+
end
|
624
|
+
|
595
625
|
def test_line_annotations
|
596
626
|
assert_equal(<<CSS, render(<<SASS, :line_comments => true, :style => :compact))
|
597
627
|
/* line 2, test_line_annotations_inline.sass */
|
@@ -980,6 +1010,19 @@ a-\#{$a}
|
|
980
1010
|
SASS
|
981
1011
|
end
|
982
1012
|
|
1013
|
+
def test_complex_property_interpolation
|
1014
|
+
assert_equal(<<CSS, render(<<SASS))
|
1015
|
+
a-1 {
|
1016
|
+
b-2 3-fizzap18: c-3; }
|
1017
|
+
CSS
|
1018
|
+
$a: 1
|
1019
|
+
$b: 2
|
1020
|
+
$c: 3
|
1021
|
+
a-\#{$a}
|
1022
|
+
b-\#{$b $c}-\#{fizzap + ($c + 15)}: c-\#{$a + $b}
|
1023
|
+
SASS
|
1024
|
+
end
|
1025
|
+
|
983
1026
|
def test_if_directive
|
984
1027
|
assert_equal("a {\n b: 1; }\n", render(<<SASS))
|
985
1028
|
$var: true
|
@@ -994,16 +1037,16 @@ SASS
|
|
994
1037
|
def test_for
|
995
1038
|
assert_equal(<<CSS, render(<<SASS))
|
996
1039
|
a-0 {
|
997
|
-
|
1040
|
+
two-i: 0; }
|
998
1041
|
|
999
1042
|
a-1 {
|
1000
|
-
|
1043
|
+
two-i: 2; }
|
1001
1044
|
|
1002
1045
|
a-2 {
|
1003
|
-
|
1046
|
+
two-i: 4; }
|
1004
1047
|
|
1005
1048
|
a-3 {
|
1006
|
-
|
1049
|
+
two-i: 6; }
|
1007
1050
|
|
1008
1051
|
b-1 {
|
1009
1052
|
j-1: 0; }
|
@@ -1020,7 +1063,7 @@ CSS
|
|
1020
1063
|
$a: 3
|
1021
1064
|
@for $i from 0 to $a + 1
|
1022
1065
|
a-\#{$i}
|
1023
|
-
|
1066
|
+
two-i: 2 * $i
|
1024
1067
|
|
1025
1068
|
@for $j from 1 through 4
|
1026
1069
|
b-\#{$j}
|
@@ -1348,7 +1391,7 @@ SASS
|
|
1348
1391
|
|
1349
1392
|
def test_attribute_selector_with_spaces
|
1350
1393
|
assert_equal(<<CSS, render(<<SASS))
|
1351
|
-
a b[foo
|
1394
|
+
a b[foo=bar] {
|
1352
1395
|
c: d; }
|
1353
1396
|
CSS
|
1354
1397
|
a
|
@@ -1542,7 +1585,7 @@ SASS
|
|
1542
1585
|
|
1543
1586
|
def test_interpolation_doesnt_deep_unquote_strings
|
1544
1587
|
assert_equal(<<CSS, render(<<SASS))
|
1545
|
-
.foo-"bar" "baz" {
|
1588
|
+
.foo- "bar" "baz" {
|
1546
1589
|
a: b; }
|
1547
1590
|
CSS
|
1548
1591
|
.foo-\#{"bar" "baz"}
|