From 5ce4ecfced94a9c797189012c144a024938d1664 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 14 Mar 2011 13:55:42 +0000 Subject: [PATCH] Per Nikerabbit, add some minifier tests for historic failure cases that I had lying around --- .../includes/libs/JavaScriptMinifierTest.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php index 82de53d1b3..3f2209d394 100644 --- a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php +++ b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php @@ -57,7 +57,20 @@ class JavaScriptMinifierTest extends MediaWikiTestCase { array( "x:{}/ x/g", "x:{}/ x/g" ), array( "switch(x){case y?z:{}/ x/g:{}/ x/g;}", "switch(x){case y?z:{}/x/g:{}/ x/g;}" ), array( "function x(){}/ x/g", "function x(){}/ x/g" ), - array( "+function x(){}/ x/g", "+function x(){}/x/g" ) + array( "+function x(){}/ x/g", "+function x(){}/x/g" ), + + // Tests for things that broke in the past + // Multiline quoted string + 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 \";" ), + // 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');" ), + // 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');" ), + // Division vs. regex nastiness + 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');" ), ); } -- 2.20.1