<?php
-class JavaScriptMinifierTest extends MediaWikiTestCase {
+class JavaScriptMinifierTest extends PHPUnit_Framework_TestCase {
public static function provideCases() {
return array(
* At some point there was a bug that caused this comment to be ended at '* /',
* causing /M... to be left as the beginning of a regex.
*/
- array( "/**\n * Foo\n * {\n * 'bar' : {\n * //Multiple rules with configurable operators\n * 'baz' : false\n * }\n */", "" ),
+ array(
+ "/**\n * Foo\n * {\n * 'bar' : {\n * "
+ . "//Multiple rules with configurable operators\n * 'baz' : false\n * }\n */",
+ "" ),
/**
* ' Foo \' bar \
* baz \' quox ' .
*/
- array( "' Foo \\' bar \\\n baz \\' quox ' .length", "' Foo \\' bar \\\n baz \\' quox '.length" ),
- array( "\" Foo \\\" bar \\\n baz \\\" quox \" .length", "\" Foo \\\" bar \\\n baz \\\" quox \".length" ),
+ array(
+ "' Foo \\' bar \\\n baz \\' quox ' .length",
+ "' Foo \\' bar \\\n baz \\' quox '.length"
+ ),
+ array(
+ "\" Foo \\\" bar \\\n baz \\\" quox \" .length",
+ "\" Foo \\\" bar \\\n baz \\\" quox \".length"
+ ),
array( "// Foo b/ar baz", "" ),
- array( "/ Foo \\/ bar [ / \\] / ] baz / .length", "/ Foo \\/ bar [ / \\] / ] baz /.length" ),
+ array(
+ "/ Foo \\/ bar [ / \\] / ] baz / .length",
+ "/ Foo \\/ bar [ / \\] / ] baz /.length"
+ ),
// HTML comments
array( "<!-- Foo bar", "" ),
// Semicolon insertion between an expression having an inline
// comment after it, and a statement on the next line (bug 27046).
- array( "var a = this //foo bar \n for ( b = 0; c < d; b++ ) {}", "var a=this\nfor(b=0;c<d;b++){}" ),
+ array(
+ "var a = this //foo bar \n for ( b = 0; c < d; b++ ) {}",
+ "var a=this\nfor(b=0;c<d;b++){}"
+ ),
// Token separation
array( "x in y", "x in y" ),
array( "var foo=\"\\\nblah\\\n\";", "var foo=\"\\\nblah\\\n\";" ),
// Multiline quoted string followed by string with spaces
- array( "var foo=\"\\\nblah\\\n\";\nvar baz = \" foo \";\n", "var foo=\"\\\nblah\\\n\";var baz=\" foo \";" ),
+ array(
+ "var foo=\"\\\nblah\\\n\";\nvar baz = \" foo \";\n",
+ "var foo=\"\\\nblah\\\n\";var baz=\" foo \";"
+ ),
// URL in quoted string ( // is not a comment)
- array( "aNode.setAttribute('href','http://foo.bar.org/baz');", "aNode.setAttribute('href','http://foo.bar.org/baz');" ),
+ array(
+ "aNode.setAttribute('href','http://foo.bar.org/baz');",
+ "aNode.setAttribute('href','http://foo.bar.org/baz');"
+ ),
// URL in quoted string after multiline quoted string
- array( "var foo=\"\\\nblah\\\n\";\naNode.setAttribute('href','http://foo.bar.org/baz');", "var foo=\"\\\nblah\\\n\";aNode.setAttribute('href','http://foo.bar.org/baz');" ),
+ array(
+ "var foo=\"\\\nblah\\\n\";\naNode.setAttribute('href','http://foo.bar.org/baz');",
+ "var foo=\"\\\nblah\\\n\";aNode.setAttribute('href','http://foo.bar.org/baz');"
+ ),
// Division vs. regex nastiness
- array( "alert( (10+10) / '/'.charCodeAt( 0 ) + '//' );", "alert((10+10)/'/'.charCodeAt(0)+'//');" ),
+ array(
+ "alert( (10+10) / '/'.charCodeAt( 0 ) + '//' );",
+ "alert((10+10)/'/'.charCodeAt(0)+'//');"
+ ),
array( "if(1)/a /g.exec('Pa ss');", "if(1)/a /g.exec('Pa ss');" ),
// newline insertion after 1000 chars: break after the "++", not before
wfRestoreWarnings();
$parser->parse( $minified, 'minify-test.js', 1 );
- $this->assertEquals( $expectedOutput, $minified, "Minified output should be in the form expected." );
+ $this->assertEquals(
+ $expectedOutput,
+ $minified,
+ "Minified output should be in the form expected."
+ );
}
- public static function provideBug32548() {
+ public static function provideExponentLineBreaking() {
return array(
array(
// This one gets interpreted all together by the prior code;
}
/**
- * @dataProvider provideBug32548
+ * @dataProvider provideExponentLineBreaking
* @covers JavaScriptMinifier::minify
- * @todo give this test a real name explaining what is being tested here
*/
- public function testBug32548Exponent( $num ) {
+ public function testExponentLineBreaking( $num ) {
// Long line breaking was being incorrectly done between the base and
// exponent part of a number, causing a syntax error. The line should
- // instead break at the start of the number.
+ // instead break at the start of the number. (T34548)
$prefix = 'var longVarName' . str_repeat( '_', 973 ) . '=';
$suffix = ',shortVarName=0;';