Follow-up r103915: We need to increment $end before the strcspn.
authorPlatonides <platonides@users.mediawiki.org>
Tue, 22 Nov 2011 18:10:25 +0000 (18:10 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Tue, 22 Nov 2011 18:10:25 +0000 (18:10 +0000)
Adjusting the tests, since it is now adding the newline after the number.

includes/libs/JavaScriptMinifier.php
tests/phpunit/includes/libs/JavaScriptMinifierTest.php

index 94e89d3..d34473f 100644 (file)
@@ -511,6 +511,7 @@ class JavaScriptMinifier {
                                        if ( $exponent > 1 ) {
                                                return self::parseError($s, $end, 'Number with several E' );
                                        }
+                                       $end++;
                                        
                                        // + sign is optional; - sign is required.
                                        $end += strspn( $s, '-+', $end );
@@ -518,7 +519,7 @@ class JavaScriptMinifier {
                                        if ( !$len ) {
                                                return self::parseError($s, $pos, 'No decimal digits after e, how many zeroes should be added?' );
                                        }
-                                       $end += $len + 1;
+                                       $end += $len;
                                }
                        } elseif( isset( $opChars[$ch] ) ) {
                                // Punctuation character. Search for the longest matching operator.
index c78b412..5952e43 100644 (file)
@@ -114,7 +114,7 @@ class JavaScriptMinifierTest extends MediaWikiTestCase {
                $suffix = ',shortVarName=0;';
 
                $input = $prefix . $num . $suffix;
-               $expected = $prefix . "\n" . $num . $suffix;
+               $expected = $prefix . $num . "\n" . $suffix;
 
                $minified = JavaScriptMinifier::minify( $input );