merbjedi-haml 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/FAQ +138 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +332 -0
- data/REVISION +1 -0
- data/Rakefile +184 -0
- data/VERSION +1 -0
- data/bin/css2sass +7 -0
- data/bin/haml +9 -0
- data/bin/html2haml +7 -0
- data/bin/sass +8 -0
- data/extra/haml-mode.el +434 -0
- data/extra/sass-mode.el +98 -0
- data/init.rb +8 -0
- data/lib/haml.rb +1025 -0
- data/lib/haml/buffer.rb +255 -0
- data/lib/haml/engine.rb +268 -0
- data/lib/haml/error.rb +22 -0
- data/lib/haml/exec.rb +395 -0
- data/lib/haml/filters.rb +276 -0
- data/lib/haml/helpers.rb +465 -0
- data/lib/haml/helpers/action_view_extensions.rb +45 -0
- data/lib/haml/helpers/action_view_mods.rb +181 -0
- data/lib/haml/html.rb +218 -0
- data/lib/haml/precompiler.rb +896 -0
- data/lib/haml/shared.rb +45 -0
- data/lib/haml/template.rb +51 -0
- data/lib/haml/template/patch.rb +58 -0
- data/lib/haml/template/plugin.rb +72 -0
- data/lib/haml/util.rb +77 -0
- data/lib/haml/version.rb +47 -0
- data/lib/sass.rb +1062 -0
- data/lib/sass/css.rb +388 -0
- data/lib/sass/engine.rb +501 -0
- data/lib/sass/environment.rb +33 -0
- data/lib/sass/error.rb +35 -0
- data/lib/sass/plugin.rb +203 -0
- data/lib/sass/plugin/merb.rb +56 -0
- data/lib/sass/plugin/rails.rb +24 -0
- data/lib/sass/repl.rb +44 -0
- data/lib/sass/script.rb +38 -0
- data/lib/sass/script/bool.rb +13 -0
- data/lib/sass/script/color.rb +97 -0
- data/lib/sass/script/funcall.rb +28 -0
- data/lib/sass/script/functions.rb +122 -0
- data/lib/sass/script/lexer.rb +144 -0
- data/lib/sass/script/literal.rb +60 -0
- data/lib/sass/script/number.rb +231 -0
- data/lib/sass/script/operation.rb +30 -0
- data/lib/sass/script/parser.rb +142 -0
- data/lib/sass/script/string.rb +42 -0
- data/lib/sass/script/unary_operation.rb +21 -0
- data/lib/sass/script/variable.rb +20 -0
- data/lib/sass/tree/attr_node.rb +64 -0
- data/lib/sass/tree/comment_node.rb +30 -0
- data/lib/sass/tree/debug_node.rb +22 -0
- data/lib/sass/tree/directive_node.rb +50 -0
- data/lib/sass/tree/file_node.rb +27 -0
- data/lib/sass/tree/for_node.rb +29 -0
- data/lib/sass/tree/if_node.rb +27 -0
- data/lib/sass/tree/mixin_def_node.rb +18 -0
- data/lib/sass/tree/mixin_node.rb +34 -0
- data/lib/sass/tree/node.rb +97 -0
- data/lib/sass/tree/rule_node.rb +120 -0
- data/lib/sass/tree/variable_node.rb +24 -0
- data/lib/sass/tree/while_node.rb +20 -0
- data/rails/init.rb +1 -0
- data/test/benchmark.rb +99 -0
- data/test/haml/engine_test.rb +852 -0
- data/test/haml/helper_test.rb +224 -0
- data/test/haml/html2haml_test.rb +92 -0
- data/test/haml/markaby/standard.mab +52 -0
- data/test/haml/mocks/article.rb +6 -0
- data/test/haml/results/content_for_layout.xhtml +15 -0
- data/test/haml/results/eval_suppressed.xhtml +9 -0
- data/test/haml/results/filters.xhtml +62 -0
- data/test/haml/results/helpers.xhtml +93 -0
- data/test/haml/results/helpful.xhtml +10 -0
- data/test/haml/results/just_stuff.xhtml +68 -0
- data/test/haml/results/list.xhtml +12 -0
- data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
- data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
- data/test/haml/results/original_engine.xhtml +20 -0
- data/test/haml/results/partial_layout.xhtml +5 -0
- data/test/haml/results/partials.xhtml +21 -0
- data/test/haml/results/render_layout.xhtml +3 -0
- data/test/haml/results/silent_script.xhtml +74 -0
- data/test/haml/results/standard.xhtml +42 -0
- data/test/haml/results/tag_parsing.xhtml +23 -0
- data/test/haml/results/very_basic.xhtml +5 -0
- data/test/haml/results/whitespace_handling.xhtml +89 -0
- data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
- data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
- data/test/haml/rhtml/action_view.rhtml +62 -0
- data/test/haml/rhtml/standard.rhtml +54 -0
- data/test/haml/template_test.rb +204 -0
- data/test/haml/templates/_av_partial_1.haml +9 -0
- data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
- data/test/haml/templates/_av_partial_2.haml +5 -0
- data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
- data/test/haml/templates/_layout.erb +3 -0
- data/test/haml/templates/_layout_for_partial.haml +3 -0
- data/test/haml/templates/_partial.haml +8 -0
- data/test/haml/templates/_text_area.haml +3 -0
- data/test/haml/templates/action_view.haml +47 -0
- data/test/haml/templates/action_view_ugly.haml +47 -0
- data/test/haml/templates/breakage.haml +8 -0
- data/test/haml/templates/content_for_layout.haml +10 -0
- data/test/haml/templates/eval_suppressed.haml +11 -0
- data/test/haml/templates/filters.haml +66 -0
- data/test/haml/templates/helpers.haml +95 -0
- data/test/haml/templates/helpful.haml +11 -0
- data/test/haml/templates/just_stuff.haml +83 -0
- data/test/haml/templates/list.haml +12 -0
- data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
- data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
- data/test/haml/templates/original_engine.haml +17 -0
- data/test/haml/templates/partial_layout.haml +3 -0
- data/test/haml/templates/partialize.haml +1 -0
- data/test/haml/templates/partials.haml +12 -0
- data/test/haml/templates/render_layout.haml +2 -0
- data/test/haml/templates/silent_script.haml +40 -0
- data/test/haml/templates/standard.haml +42 -0
- data/test/haml/templates/standard_ugly.haml +42 -0
- data/test/haml/templates/tag_parsing.haml +21 -0
- data/test/haml/templates/very_basic.haml +4 -0
- data/test/haml/templates/whitespace_handling.haml +87 -0
- data/test/linked_rails.rb +12 -0
- data/test/sass/css2sass_test.rb +193 -0
- data/test/sass/engine_test.rb +752 -0
- data/test/sass/functions_test.rb +96 -0
- data/test/sass/more_results/more1.css +9 -0
- data/test/sass/more_results/more1_with_line_comments.css +26 -0
- data/test/sass/more_results/more_import.css +29 -0
- data/test/sass/more_templates/_more_partial.sass +2 -0
- data/test/sass/more_templates/more1.sass +23 -0
- data/test/sass/more_templates/more_import.sass +11 -0
- data/test/sass/plugin_test.rb +208 -0
- data/test/sass/results/alt.css +4 -0
- data/test/sass/results/basic.css +9 -0
- data/test/sass/results/compact.css +5 -0
- data/test/sass/results/complex.css +87 -0
- data/test/sass/results/compressed.css +1 -0
- data/test/sass/results/expanded.css +19 -0
- data/test/sass/results/import.css +29 -0
- data/test/sass/results/line_numbers.css +49 -0
- data/test/sass/results/mixins.css +95 -0
- data/test/sass/results/multiline.css +24 -0
- data/test/sass/results/nested.css +22 -0
- data/test/sass/results/parent_ref.css +13 -0
- data/test/sass/results/script.css +16 -0
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/test/sass/results/subdir/subdir.css +3 -0
- data/test/sass/results/units.css +11 -0
- data/test/sass/script_test.rb +152 -0
- data/test/sass/templates/_partial.sass +2 -0
- data/test/sass/templates/alt.sass +16 -0
- data/test/sass/templates/basic.sass +23 -0
- data/test/sass/templates/bork.sass +2 -0
- data/test/sass/templates/bork2.sass +2 -0
- data/test/sass/templates/compact.sass +17 -0
- data/test/sass/templates/complex.sass +309 -0
- data/test/sass/templates/compressed.sass +15 -0
- data/test/sass/templates/expanded.sass +17 -0
- data/test/sass/templates/import.sass +11 -0
- data/test/sass/templates/importee.sass +19 -0
- data/test/sass/templates/line_numbers.sass +13 -0
- data/test/sass/templates/mixins.sass +76 -0
- data/test/sass/templates/multiline.sass +20 -0
- data/test/sass/templates/nested.sass +25 -0
- data/test/sass/templates/parent_ref.sass +25 -0
- data/test/sass/templates/script.sass +101 -0
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/test/sass/templates/subdir/subdir.sass +6 -0
- data/test/sass/templates/units.sass +11 -0
- data/test/test_helper.rb +21 -0
- metadata +273 -0
@@ -0,0 +1 @@
|
|
1
|
+
#main{width:15em;color:#0000ff}#main p{border-style:dotted;border-width:2px}#main .cool{width:100px}#left{font-size:2em;font-weight:bold;float:left}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#main {
|
2
|
+
width: 15em;
|
3
|
+
color: #0000ff;
|
4
|
+
}
|
5
|
+
#main p {
|
6
|
+
border-style: dotted;
|
7
|
+
/* Nested comment
|
8
|
+
* More nested stuff */
|
9
|
+
border-width: 2px;
|
10
|
+
}
|
11
|
+
#main .cool {
|
12
|
+
width: 100px;
|
13
|
+
}
|
14
|
+
|
15
|
+
#left {
|
16
|
+
font-size: 2em;
|
17
|
+
font-weight: bold;
|
18
|
+
float: left;
|
19
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
imported { otherconst: hello; myconst: goodbye; pre-mixin: here; }
|
2
|
+
|
3
|
+
body { font: Arial; background: blue; }
|
4
|
+
|
5
|
+
#page { width: 700px; height: 100; }
|
6
|
+
#page #header { height: 300px; }
|
7
|
+
#page #header h1 { font-size: 50px; color: blue; }
|
8
|
+
|
9
|
+
#content.user.show #container.top #column.left { width: 100px; }
|
10
|
+
#content.user.show #container.top #column.right { width: 600px; }
|
11
|
+
#content.user.show #container.bottom { background: brown; }
|
12
|
+
|
13
|
+
midrule { inthe: middle; }
|
14
|
+
|
15
|
+
body { font: Arial; background: blue; }
|
16
|
+
|
17
|
+
#page { width: 700px; height: 100; }
|
18
|
+
#page #header { height: 300px; }
|
19
|
+
#page #header h1 { font-size: 50px; color: blue; }
|
20
|
+
|
21
|
+
#content.user.show #container.top #column.left { width: 100px; }
|
22
|
+
#content.user.show #container.top #column.right { width: 600px; }
|
23
|
+
#content.user.show #container.bottom { background: brown; }
|
24
|
+
|
25
|
+
@import url(basic.css);
|
26
|
+
@import url(../results/complex.css);
|
27
|
+
#foo { background-color: #baf; }
|
28
|
+
|
29
|
+
nonimported { myconst: hello; otherconst: goodbye; post-mixin: here; }
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/* line 1, ../templates/line_numbers.sass */
|
2
|
+
foo {
|
3
|
+
bar: baz; }
|
4
|
+
|
5
|
+
/* line 6, ../templates/importee.sass */
|
6
|
+
imported {
|
7
|
+
otherconst: 12;
|
8
|
+
myconst: goodbye; }
|
9
|
+
/* line 5, ../templates/line_numbers.sass */
|
10
|
+
imported squggle {
|
11
|
+
blat: bang; }
|
12
|
+
|
13
|
+
/* line 3, ../templates/basic.sass */
|
14
|
+
body {
|
15
|
+
font: Arial;
|
16
|
+
background: blue; }
|
17
|
+
|
18
|
+
/* line 7, ../templates/basic.sass */
|
19
|
+
#page {
|
20
|
+
width: 700px;
|
21
|
+
height: 100; }
|
22
|
+
/* line 10, ../templates/basic.sass */
|
23
|
+
#page #header {
|
24
|
+
height: 300px; }
|
25
|
+
/* line 12, ../templates/basic.sass */
|
26
|
+
#page #header h1 {
|
27
|
+
font-size: 50px;
|
28
|
+
color: blue; }
|
29
|
+
|
30
|
+
/* line 18, ../templates/basic.sass */
|
31
|
+
#content.user.show #container.top #column.left {
|
32
|
+
width: 100px; }
|
33
|
+
/* line 20, ../templates/basic.sass */
|
34
|
+
#content.user.show #container.top #column.right {
|
35
|
+
width: 600px; }
|
36
|
+
/* line 22, ../templates/basic.sass */
|
37
|
+
#content.user.show #container.bottom {
|
38
|
+
background: brown; }
|
39
|
+
|
40
|
+
/* line 13, ../templates/importee.sass */
|
41
|
+
midrule {
|
42
|
+
inthe: middle; }
|
43
|
+
|
44
|
+
/* line 12, ../templates/line_numbers.sass */
|
45
|
+
umph {
|
46
|
+
foo: bar; }
|
47
|
+
/* line 18, ../templates/importee.sass */
|
48
|
+
umph baz {
|
49
|
+
blat: bang; }
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#main {
|
2
|
+
width: 15em;
|
3
|
+
color: #0000ff;
|
4
|
+
}
|
5
|
+
#main p {
|
6
|
+
border-top-width: 2px;
|
7
|
+
border-top-color: #ffcc00;
|
8
|
+
border-left-width: 1px;
|
9
|
+
border-left-color: #000;
|
10
|
+
-moz-border-radius: 10px;
|
11
|
+
border-style: dotted;
|
12
|
+
border-width: 2px;
|
13
|
+
}
|
14
|
+
#main .cool {
|
15
|
+
width: 100px;
|
16
|
+
}
|
17
|
+
|
18
|
+
#left {
|
19
|
+
border-top-width: 2px;
|
20
|
+
border-top-color: #ffcc00;
|
21
|
+
border-left-width: 1px;
|
22
|
+
border-left-color: #000;
|
23
|
+
-moz-border-radius: 10px;
|
24
|
+
font-size: 2em;
|
25
|
+
font-weight: bold;
|
26
|
+
float: left;
|
27
|
+
}
|
28
|
+
|
29
|
+
#right {
|
30
|
+
border-top-width: 2px;
|
31
|
+
border-top-color: #ffcc00;
|
32
|
+
border-left-width: 1px;
|
33
|
+
border-left-color: #000;
|
34
|
+
-moz-border-radius: 10px;
|
35
|
+
color: #f00;
|
36
|
+
font-size: 20px;
|
37
|
+
float: right;
|
38
|
+
}
|
39
|
+
|
40
|
+
.bordered {
|
41
|
+
border-top-width: 2px;
|
42
|
+
border-top-color: #ffcc00;
|
43
|
+
border-left-width: 1px;
|
44
|
+
border-left-color: #000;
|
45
|
+
-moz-border-radius: 10px;
|
46
|
+
}
|
47
|
+
|
48
|
+
.complex {
|
49
|
+
color: #f00;
|
50
|
+
font-size: 20px;
|
51
|
+
text-decoration: none;
|
52
|
+
}
|
53
|
+
.complex:after {
|
54
|
+
content: ".";
|
55
|
+
display: block;
|
56
|
+
height: 0;
|
57
|
+
clear: both;
|
58
|
+
visibility: hidden;
|
59
|
+
}
|
60
|
+
* html .complex {
|
61
|
+
height: 1px;
|
62
|
+
color: #f00;
|
63
|
+
font-size: 20px;
|
64
|
+
}
|
65
|
+
|
66
|
+
.more-complex {
|
67
|
+
color: #f00;
|
68
|
+
font-size: 20px;
|
69
|
+
text-decoration: none;
|
70
|
+
display: inline;
|
71
|
+
-webkit-nonsense-top-right: 1px;
|
72
|
+
-webkit-nonsense-bottom-left: 1px;
|
73
|
+
}
|
74
|
+
.more-complex:after {
|
75
|
+
content: ".";
|
76
|
+
display: block;
|
77
|
+
height: 0;
|
78
|
+
clear: both;
|
79
|
+
visibility: hidden;
|
80
|
+
}
|
81
|
+
* html .more-complex {
|
82
|
+
height: 1px;
|
83
|
+
color: #f00;
|
84
|
+
font-size: 20px;
|
85
|
+
}
|
86
|
+
.more-complex a:hover {
|
87
|
+
text-decoration: underline;
|
88
|
+
color: #f00;
|
89
|
+
font-size: 20px;
|
90
|
+
border-top-width: 2px;
|
91
|
+
border-top-color: #ffcc00;
|
92
|
+
border-left-width: 1px;
|
93
|
+
border-left-color: #000;
|
94
|
+
-moz-border-radius: 10px;
|
95
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#main,
|
2
|
+
#header {
|
3
|
+
height: 50px; }
|
4
|
+
#main div,
|
5
|
+
#header div {
|
6
|
+
width: 100px; }
|
7
|
+
#main div a span,
|
8
|
+
#main div em span,
|
9
|
+
#header div a span,
|
10
|
+
#header div em span {
|
11
|
+
color: pink; }
|
12
|
+
|
13
|
+
#one div.nested,
|
14
|
+
#one span.nested,
|
15
|
+
#one p.nested,
|
16
|
+
#two div.nested,
|
17
|
+
#two span.nested,
|
18
|
+
#two p.nested,
|
19
|
+
#three div.nested,
|
20
|
+
#three span.nested,
|
21
|
+
#three p.nested {
|
22
|
+
font-weight: bold;
|
23
|
+
border-color: red;
|
24
|
+
display: block; }
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#main {
|
2
|
+
width: 15em;
|
3
|
+
color: #0000ff; }
|
4
|
+
#main p {
|
5
|
+
border-style: dotted;
|
6
|
+
/* Nested comment
|
7
|
+
* More nested stuff */
|
8
|
+
border-width: 2px; }
|
9
|
+
#main .cool {
|
10
|
+
width: 100px; }
|
11
|
+
|
12
|
+
#left {
|
13
|
+
font-size: 2em;
|
14
|
+
font-weight: bold;
|
15
|
+
float: left; }
|
16
|
+
|
17
|
+
#right .header {
|
18
|
+
border-style: solid; }
|
19
|
+
#right .body {
|
20
|
+
border-style: dotted; }
|
21
|
+
#right .footer {
|
22
|
+
border-style: dashed; }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
a { color: #000; }
|
2
|
+
a:hover { color: #f00; }
|
3
|
+
|
4
|
+
p, div { width: 100em; }
|
5
|
+
p foo, div foo { width: 10em; }
|
6
|
+
p:hover, p bar, div:hover, div bar { height: 20em; }
|
7
|
+
|
8
|
+
#cool { border-style: solid; border-width: 2em; }
|
9
|
+
.ie7 #cool, .ie6 #cool { content: string(Totally not cool.); }
|
10
|
+
.firefox #cool { content: string(Quite cool.); }
|
11
|
+
|
12
|
+
.wow, .snazzy { font-family: fantasy; }
|
13
|
+
.wow:hover, .wow:visited, .snazzy:hover, .snazzy:visited { font-weight: bold; }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#main { content: Hello!; qstr: Quo"ted"!; hstr: Hyph-en!; width: 30em; background-color: #000; color: #ffffaa; short-color: #112233; named-color: olive; con: foo bar(9 hi there boom); con2: noquo quo; }
|
2
|
+
#main #sidebar { background-color: #00ff98; num-normal: 10; num-dec: 10.2; num-dec0: 99; num-neg: -10; esc: 10 +12; many: 6; order: 7; complex: #4c9db1hi16; }
|
3
|
+
|
4
|
+
#plus { num-num: 7; num-num-un: 25em; num-num-un2: 23em; num-num-neg: 9.87; num-str: 100px; num-col: #b7b7b7; num-perc: 31%; str-str: hi there; str-str2: hi there; str-col: 14em solid #112233; str-num: times: 13; col-num: #ff7b9d; col-col: #5173ff; }
|
5
|
+
|
6
|
+
#minus { num-num: 900; col-num: #f9f9f4; col-col: #000035; unary-num: -1; unary-const: 10; unary-paren: -11; unary-two: 12; unary-many: 12; unary-crazy: -15; }
|
7
|
+
|
8
|
+
#times { num-num: 7; num-col: #7496b8; col-num: #092345; col-col: #243648; }
|
9
|
+
|
10
|
+
#div { num-num: 3.333; num-num2: 3.333; col-num: #092345; col-col: #0b0d0f; comp: 1px; }
|
11
|
+
|
12
|
+
#mod { num-num: 2; col-col: #0f0e05; col-num: #020001; }
|
13
|
+
|
14
|
+
#const { escaped-quote: !foo; default: Hello! !important; }
|
15
|
+
|
16
|
+
#regression { a: 4; }
|
@@ -0,0 +1 @@
|
|
1
|
+
#pi { width: 314px; }
|
@@ -0,0 +1,152 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
3
|
+
require 'sass/engine'
|
4
|
+
|
5
|
+
class SassScriptTest < Test::Unit::TestCase
|
6
|
+
include Sass::Script
|
7
|
+
|
8
|
+
def test_color_checks_input
|
9
|
+
assert_raise(Sass::SyntaxError, "Color values must be between 0 and 255") {Color.new([1, 2, -1])}
|
10
|
+
assert_raise(Sass::SyntaxError, "Color values must be between 0 and 255") {Color.new([256, 2, 3])}
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_string_escapes
|
14
|
+
assert_equal '"', resolve("\"\\\"\"")
|
15
|
+
assert_equal "\\", resolve("\"\\\\\"")
|
16
|
+
assert_equal "\\02fa", resolve("\"\\02fa\"")
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_color_names
|
20
|
+
assert_equal "white", resolve("white")
|
21
|
+
assert_equal "white", resolve("#ffffff")
|
22
|
+
assert_equal "#fffffe", resolve("white - #000001")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_implicit_strings
|
26
|
+
silence_warnings do
|
27
|
+
assert_equal Sass::Script::String.new("foo"), eval("foo")
|
28
|
+
assert_equal Sass::Script::String.new("foo bar"), eval("foo bar")
|
29
|
+
assert_equal Sass::Script::String.new("foo/bar"), eval("foo/bar")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_interpolation
|
34
|
+
assert_equal "foo bar baz bang", resolve('"foo #{"#{"ba" + "r"} baz"} bang"')
|
35
|
+
assert_equal 'foo #{bar baz} bang', resolve('"foo \#{#{"ba" + "r"} baz} bang"')
|
36
|
+
assert_equal 'foo #{baz bang', resolve('"foo #{"\#{" + "baz"} bang"')
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_rule_interpolation
|
40
|
+
assert_equal(<<CSS, render(<<SASS))
|
41
|
+
foo bar baz bang {
|
42
|
+
a: b; }
|
43
|
+
CSS
|
44
|
+
foo \#{"\#{"ba" + "r"} baz"} bang
|
45
|
+
a: b
|
46
|
+
SASS
|
47
|
+
assert_equal(<<CSS, render(<<SASS))
|
48
|
+
foo \#{bar baz} bang {
|
49
|
+
a: b; }
|
50
|
+
CSS
|
51
|
+
foo \\\#{\#{"ba" + "r"} baz} bang
|
52
|
+
a: b
|
53
|
+
SASS
|
54
|
+
assert_equal(<<CSS, render(<<SASS))
|
55
|
+
foo \#{baz bang {
|
56
|
+
a: b; }
|
57
|
+
CSS
|
58
|
+
foo \#{"\\\#{" + "baz"} bang
|
59
|
+
a: b
|
60
|
+
SASS
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_warning_reporting
|
64
|
+
assert_warning(<<WARN) {eval("foo")}
|
65
|
+
DEPRECATION WARNING:
|
66
|
+
On line 1, character 1 of 'test_warning_reporting_inline.sass'
|
67
|
+
Implicit strings have been deprecated and will be removed in version 2.4.
|
68
|
+
'foo' was not quoted. Please add double quotes (e.g. "foo").
|
69
|
+
WARN
|
70
|
+
assert_warning(<<WARN) {eval("1 + foo")}
|
71
|
+
DEPRECATION WARNING:
|
72
|
+
On line 1, character 5 of 'test_warning_reporting_inline.sass'
|
73
|
+
Implicit strings have been deprecated and will be removed in version 2.4.
|
74
|
+
'foo' was not quoted. Please add double quotes (e.g. "foo").
|
75
|
+
WARN
|
76
|
+
assert_warning(<<WARN) {render("@if 1 + foo")}
|
77
|
+
DEPRECATION WARNING:
|
78
|
+
On line 1, character 9 of 'test_warning_reporting_inline.sass'
|
79
|
+
Implicit strings have been deprecated and will be removed in version 2.4.
|
80
|
+
'foo' was not quoted. Please add double quotes (e.g. "foo").
|
81
|
+
WARN
|
82
|
+
|
83
|
+
# Regression
|
84
|
+
assert_warning(<<WARN) {render("@if if")}
|
85
|
+
DEPRECATION WARNING:
|
86
|
+
On line 1, character 5 of 'test_warning_reporting_inline.sass'
|
87
|
+
Implicit strings have been deprecated and will be removed in version 2.4.
|
88
|
+
'if' was not quoted. Please add double quotes (e.g. "if").
|
89
|
+
WARN
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_inaccessible_functions
|
93
|
+
assert_warning <<WARN do
|
94
|
+
DEPRECATION WARNING:
|
95
|
+
On line 2, character 6 of 'test_inaccessible_functions_inline.sass'
|
96
|
+
Implicit strings have been deprecated and will be removed in version 2.4.
|
97
|
+
'to_s' was not quoted. Please add double quotes (e.g. "to_s").
|
98
|
+
WARN
|
99
|
+
assert_equal "send(to_s)", resolve("send(to_s)", :line => 2)
|
100
|
+
end
|
101
|
+
assert_equal "public_instance_methods()", resolve("public_instance_methods()")
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_ruby_equality
|
105
|
+
assert_equal eval('"foo"'), eval('"foo"')
|
106
|
+
assert_equal eval('1'), eval('1.0')
|
107
|
+
assert_not_equal eval('1'), eval('"1"')
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def resolve(str, opts = {}, environment = {})
|
113
|
+
munge_filename opts
|
114
|
+
eval(str, opts, environment).to_s
|
115
|
+
end
|
116
|
+
|
117
|
+
def eval(str, opts = {}, environment = {})
|
118
|
+
munge_filename opts
|
119
|
+
Sass::Script.parse(str, opts[:line] || 1,
|
120
|
+
opts[:offset] || 0, opts[:filename]).perform(environment)
|
121
|
+
end
|
122
|
+
|
123
|
+
def render(sass, options = {})
|
124
|
+
munge_filename options
|
125
|
+
Sass::Engine.new(sass, options).render
|
126
|
+
end
|
127
|
+
|
128
|
+
def assert_warning(message)
|
129
|
+
the_real_stderr, $stderr = $stderr, StringIO.new
|
130
|
+
yield
|
131
|
+
assert_equal message.strip, $stderr.string.strip
|
132
|
+
ensure
|
133
|
+
$stderr = the_real_stderr
|
134
|
+
end
|
135
|
+
|
136
|
+
def silence_warnings
|
137
|
+
the_real_stderr, $stderr = $stderr, StringIO.new
|
138
|
+
yield
|
139
|
+
ensure
|
140
|
+
$stderr = the_real_stderr
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_number_printing
|
144
|
+
assert_equal "1", eval("1")
|
145
|
+
assert_equal "1", eval("1.0")
|
146
|
+
assert_equal "1.121", eval("1.1214")
|
147
|
+
assert_equal "1.122", eval("1.1215")
|
148
|
+
assert_equal "Infinity", eval("1.0/0.0")
|
149
|
+
assert_equal "-Infinity", eval("-1.0/0.0")
|
150
|
+
assert_equal "NaN", eval("0.0/0.0")
|
151
|
+
end
|
152
|
+
end
|