Index: trunk/phase3/tests/phpunit/includes/libs/JavaScriptMinifierTest.php |
— | — | @@ -102,4 +102,40 @@ |
103 | 103 | |
104 | 104 | $this->assertEquals( $expectedOutput, $minified, "Minified output should be in the form expected." ); |
105 | 105 | } |
| 106 | + |
| 107 | + /** |
| 108 | + * @dataProvider provideBug32548 |
| 109 | + */ |
| 110 | + function testBug32548Exponent($num) { |
| 111 | + // Long line breaking was being incorrectly done between the base and |
| 112 | + // exponent part of a number, causing a syntax error. The line should |
| 113 | + // instead break at the start of the number. |
| 114 | + $prefix = 'var longVarName' . str_repeat('_', 973) . '='; |
| 115 | + $suffix = ',shortVarName=0;'; |
| 116 | + |
| 117 | + $input = $prefix . $num . $suffix; |
| 118 | + $expected = $prefix . "\n" . $num . $suffix; |
| 119 | + |
| 120 | + $minified = JavaScriptMinifier::minify( $input ); |
| 121 | + |
| 122 | + $this->assertEquals( $expected, $minified, "Line breaks must not occur in middle of exponent"); |
| 123 | + } |
| 124 | + |
| 125 | + function provideBug32548() { |
| 126 | + return array( |
| 127 | + array( |
| 128 | + // This one gets interpreted all together by the prior code; |
| 129 | + // no break at the 'E' happens. |
| 130 | + '1.23456789E55', |
| 131 | + ), |
| 132 | + array( |
| 133 | + // This one breaks under the bad code; splits between 'E' and '+' |
| 134 | + '1.23456789E+5', |
| 135 | + ), |
| 136 | + array( |
| 137 | + // This one breaks under the bad code; splits between 'E' and '-' |
| 138 | + '1.23456789E-5', |
| 139 | + ), |
| 140 | + ); |
| 141 | + } |
106 | 142 | } |