wrote more of the compressor and added some tests

This commit is contained in:
Mihai Bazon
2012-08-22 15:21:58 +03:00
parent f53e139d3c
commit 159a6f048c
10 changed files with 497 additions and 19 deletions

49
test/compress/blocks.js Normal file
View File

@@ -0,0 +1,49 @@
remove_blocks: {
input: {
{;}
foo();
{};
{
{};
};
bar();
{}
}
expect: {
foo();
bar();
}
}
keep_some_blocks: {
input: {
// 1.
if (foo) {
{{{}}}
if (bar) baz();
{{}}
} else {
stuff();
}
// 2.
if (foo) {
for (var i = 0; i < 5; ++i)
if (bar) baz();
} else {
stuff();
}
}
expect: {
// 1.
if (foo) {
if (bar) baz();
} else stuff();
// 2.
if (foo) {
for (var i = 0; i < 5; ++i)
if (bar) baz();
} else stuff();
}
}