JavaScriptMinifier: Add test case for T201606
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 10 Aug 2018 20:03:01 +0000 (21:03 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 10 Aug 2018 20:04:58 +0000 (21:04 +0100)
Bug: T201606
Change-Id: I2058765c7f1cfb9e2d644f19e780926d01b9b68c

tests/phpunit/includes/libs/JavaScriptMinifierTest.php

index 6105678..03a4438 100644 (file)
@@ -203,6 +203,33 @@ class JavaScriptMinifierTest extends PHPUnit\Framework\TestCase {
                );
        }
 
+       /**
+        * @covers JavaScriptMinifier::minify
+        */
+       public function testReturnLineBreak() {
+               // Regression test for T201606.
+               $lineFill = str_repeat( 'x', 993 );
+               $code = <<<JAVASCRIPT
+call( function () {
+       try {
+       } catch (e) {
+               push = {
+                       apply: 1 ? 0 : {}
+               };
+       }
+       {$lineFill}
+       return name === 'input';
+} );
+JAVASCRIPT;
+               $this->assertSame(
+                       "call(function(){try{}catch(e){push={apply:1?0:{}};}"
+                               // FIXME: Token `name` must be on line 2 instead of line 3
+                               . "\n$lineFill return"
+                               . "\nname==='input';});",
+                       JavaScriptMinifier::minify( $code )
+               );
+       }
+
        public static function provideExponentLineBreaking() {
                return [
                        [