From: Brion Vibber Date: Tue, 22 Nov 2011 23:10:22 +0000 (+0000) Subject: Followup r103865 and r103915 X-Git-Tag: 1.31.0-rc.0~26343 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=6b06770b6d210137c88ba5c130a0eed23e73f9de;p=lhc%2Fweb%2Fwiklou.git Followup r103865 and r103915 r103915 added a parse error for 'more than 2 decimal points' in a number; this is the wrong place to check for that. Should only check whether there's more digits or identifier chars -- identifier chars would be illegal. Added test cases for the exponent missing fails, tweaked it to be more consistent (only need to check for one e; if we have more we can lump them in with 'not digits' :) Also cleaned up no-longer-needed suppress/restore warnings around JS parser invocation --- diff --git a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php index d2bfeedfcf..d7d3cf4b76 100644 --- a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php +++ b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php @@ -89,8 +89,14 @@ class JavaScriptMinifierTest extends MediaWikiTestCase { array( "var a = 5.;", "var a=5.;" ), array( "5.0.toString();", "5.0.toString();" ), array( "5..toString();", "5..toString();" ), - array( "5...toString();", false ), array( "5.\n.toString();", '5..toString();' ), + + /* Some structures that are invalid, that we may not detect */ + //array( "5...toString();", false ), // can't detect this yet, though JSParser will throw error + array( '5e1', '5e1' ), + array( "5e", false ), // no exponent (end) + array( "5eee1", false ), // no exponent (multiple e) + array( "5e++", false ), // no exponent (other symbol) ); } @@ -101,10 +107,7 @@ class JavaScriptMinifierTest extends MediaWikiTestCase { $minified = JavaScriptMinifier::minify( $code ); // JSMin+'s parser will throw an exception if output is not valid JS. - // suppression of warnings needed for stupid crap - wfSuppressWarnings(); $parser = new JSParser(); - wfRestoreWarnings(); $parser->parse( $minified, 'minify-test.js', 1 ); $this->assertEquals( $expectedOutput, $minified, "Minified output should be in the form expected." );