From: alexlamsl Date: Mon, 29 Feb 2016 18:44:22 +0000 (+0800) Subject: incorporate tests from PHPTAL X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=fcccd865b9dd7eef55a619c5f75740450609d279;p=html-minifier.git incorporate tests from PHPTAL fixes #18 --- diff --git a/tests/minifier.js b/tests/minifier.js index c15365b..4d7fecf 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -1818,4 +1818,105 @@ equal(minify(input, options), output); }); + test('tests from PHPTAL', function() { + [ + // trailing

removed by minifier, but not by PHPTAL + ['

foo bar baz', '

foo \t bar\n\n\n baz

'], + ['

foo bar

  \tfoo\t   \nbar   
', '

foo \t\n bar

  \tfoo\t   \nbar   
'], + /* needs to handle whitespace within and around + ['

foo bar baz', '

foo bar baz

'], + ['

foo bar baz', '

foo bar baz

'], + ['

foo bar baz', '

foo bar baz

'], + ['

foo bar baz', '

foo bar baz

'], + */ + ['

foo
', '

foo

'], + // PHPTAL remove whitespace after 'foo' - problematic if is used as icon font + ['

foo ', '

foo

'], + ['

foo ', '

foo

'], + // comments removed by minifier, but not by PHPTAL + ['

foo', '

foo

'], + ['
a
b
c
d
e
', '
a
b
c
d
e
'], + // unary slashes removed by minifier, but not by PHPTAL + ['
', '
'], + ['
x
', '
x
'], + ['
x y
', '
x y
'], + ['
y
', '
y
'], + ['
', '
'], + ['
x
', '
x
'], + ['
x y
', '
x y
'], + ['
y
', '
y
'], + ['
', '
'], + ['
x
', '
x
'], + ['
x y
', '
x y
'], + ['
y
', '
y
'], + ['', ''], + // optional tags removed by minifier, but not by PHPTAL + // parser cannot handle ', + '\n' + + ' \n' + + ' \n' + + ' ' + ], + ['

test 123

456

  • x
', '

test 123

456

  • x
'], + ['

test 123

 456 

x

', '

test 123

 456 

x

'], + /* minifier does not assume
  • as "display: inline" + ['
    ', '
    '], + */ + ['xxxx
    foo
    ', ' x x x x
    foo
    '], + ['', ' '], + /* minifier does not reorder attributes + ['x', 'x'], + ['', ''], + */ + ['
    \n\n\ntest
    ', '
    \n\n\ntest
    '], + /* single line-break preceding
     is redundant, assuming 
     is block element
    +      ['
    test
    ', '
    \ntest
    '], + */ + // optional attribute quotes removed by minifier, but not by PHPTAL + ['', ''], + /* minifier does not optimise in HTML5 mode + ['', ''], + */ + /* minifier does not optimise ', + '' + ], + */ + ['', ''] + /* trim "title" attribute value in + [ + 'Foo

    x xu


    foo', + ' Foo \n' + + '\n' + + '

    \n' + + ' x xu\n' + + '

    \n' + + '
    \n' + + 'foo ' + ] + */ + ].forEach(function(tokens) { + equal(minify(tokens[1], { + collapseBooleanAttributes: true, + collapseWhitespace: true, + removeAttributeQuotes: true, + removeCDATASectionsFromCDATA: true, + removeComments: true, + removeCommentsFromCDATA: true, + removeEmptyAttributes: true, + removeOptionalTags: true, + removeRedundantAttributes: true, + removeScriptTypeAttributes: true, + removeStyleLinkTypeAttributes: true, + removeTagWhitespace: true, + useShortDoctype: true + }), tokens[0]); + }); + }); + })(typeof exports === 'undefined' ? window : exports);