This repository has been archived by the owner on Apr 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testsuite.in
157 lines (122 loc) · 4.76 KB
/
testsuite.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
START_MARKER
test_true([[ programp(Tools.Sass.Compiler) ]])
test_true([[ Tools.Sass.libsass_version() != "" ]])
test_do([[
Tools.Sass.Compiler c = Tools.Sass.Compiler();
c->set_options(([ "include_path" : "./",
"output_style" : Tools.Sass.STYLE_COMPRESSED ]));
add_constant("sassc", c);
add_constant("sassopt", c->set_options);
add_constant("scss_str", #"
$color: #0087cc;
a {
color: $color
}
");
]])
dnl *** Should raise errors
test_eval_error([[ sassopt(([ "include_path" : 1 ])) ]])
test_eval_error([[ sassopt(([ "output_style" : 1024 ])) ]])
test_eval_error([[ sassopt(([ "output_style" : "foo" ])) ]])
test_eval_error([[ sassopt(([ "source_map_file" : 1 ])) ]])
test_eval_error([[ sassopt(([ "source_map_embed" : "yes" ])) ]])
test_eval_error([[ sassopt(([ "source_map_root" : 1 ])) ]])
test_eval_error([[ sassopt(([ "omit_source_map_url" : "y" ])) ]])
test_eval_error([[ sassopt(([ "source_comments" : "y" ])) ]])
test_eval_error([[ sassopt(([ "precision" : "y" ])) ]])
test_eval_error([[ sassopt(([ "unknown_opt" : "y" ])) ]])
dnl *** End: Should raise errors
test_do([[
sassopt(([ "include_path" : "./",
"output_style" : Tools.Sass.STYLE_COMPRESSED ]));
]])
test_eq(sassc->include_path, "./")
dnl *** Simple compile_string tests
test_eq([[ sassc->output_style ]], Tools.Sass.STYLE_COMPRESSED)
test_eq([[ sassc->compile_string(scss_str)->css ]], "a{color:#0087cc}\n")
test_eq([[ sassc->output_style = Tools.Sass.STYLE_COMPACT,
sassc->compile_string(scss_str)->css ]], "a { color: #0087cc; }\n")
test_eq([[ sassc->output_style = Tools.Sass.STYLE_NESTED,
sassc->compile_string(scss_str)->css ]], "a {\n"
" color: #0087cc; }\n")
test_eq([[ sassc->output_style = Tools.Sass.STYLE_EXPANDED,
sassc->compile_string(scss_str)->css ]], "a {\n"
" color: #0087cc;\n"
"}\n")
dnl *** End: Simple compile_string tests
dnl *** Create some simple files and write them to disk, and compile them
dnl without writing the CSS and MAP to disk.
test_do([[
string vars = #"
$color: #fff;
$font: Arial;
@mixin fun() {
&::before {
color: $color;
}
}
";
string style = #"
// Comment
@import 'testvars';
html {
font-family: $font;
body {
@include fun();
}
}
";
Stdio.write_file("_testvars.scss", vars);
Stdio.write_file("teststyle.scss", style);
mapping(string(8bit):string(8bit)) r =
sassc->compile_file("teststyle.scss");
add_constant("scss_comp_file", r);
]])
dnl *** Expected result of the first compile_file test.
define(scss_expected_style_1,
"html {\n"
" font-family: Arial;\n"
"}\n"
"\n"
"html body::before {\n"
" color: #fff;\n"
"}\n")
test_eq([[ scss_comp_file->map ]], 0)
test_eq([[ scss_comp_file->css ]], scss_expected_style_1)
define(compile_to_disk, [[ test_do([[
sassc->source_map_file = "teststyle.css.map";
sassc->compile_file("teststyle.scss", "teststyle.css");
string s = Stdio.read_file("teststyle.css");
mapping m = Standards.JSON.decode(Stdio.read_file("teststyle.css.map"));
add_constant("scss_comp_file", s);
add_constant("scss_comp_map", m);
]]) ]])
compile_to_disk()
define(scss_expected_style_2, scss_expected_style_1
"\n"
"/*# sourceMappingURL=teststyle.css.map */")
test_eq([[ scss_comp_file ]], scss_expected_style_2)
test_eq([[ scss_comp_map->file ]], "teststyle.css")
test_equal([[ scss_comp_map->sources ]], ({ "teststyle.scss","_testvars.scss" }))
dnl *** Removing this test temporarily since the output seems to vary heavily
dnl *** which might have to with which libsass version is being used.
dnl test_eq([[ scss_comp_map->mappings ]],
dnl [[ "AAIM,AAAA,IAAI,CAAC;EACH,WAAW,ECHL,KAAK;CDQZ;;AAND,ACCE,IDDE,"
dnl "CAGF,IAAI,ACFH,QAAQ,CAAC;EACR,KAAK,EALD,IAAI;CAMT" ]])
test_do([[ sassc->source_comments = true; ]])
compile_to_disk();
test_true([[ sscanf(scss_comp_file, "%*s/* line %*d, %*s.scss */") == 3 ]])
dnl *** Clean up
test_do([[
rm("_testvars.scss");
rm("teststyle.scss");
rm("teststyle.css");
rm("teststyle.css.map");
add_constant("scss_comp_file");
add_constant("scss_comp_map");
add_constant("scss_str");
add_constant("sassopt");
add_constant("sassc");
]])
dnl *** End clean up
END_MARKER