Permalink
Browse files

Fixes #53 (github) handles division following line break

  • Loading branch information...
1 parent d67feea commit 6f5721d2db7f290a4528ea4c0b0be21621f670bc @mrclay committed Apr 1, 2013
View
@@ -268,11 +268,11 @@ protected function action($command)
*/
protected function isRegexpLiteral()
{
- if (false !== strpos("(,=:[!&|?+-~*\n{", $this->a)) {
+ if (false !== strpos("(,=:[!&|?+-~*{;", $this->a)) {
// we obviously aren't dividing
return true;
}
- if (' ' === $this->a) {
+ if ($this->a === ' ' || $this->a === "\n") {
$length = strlen($this->output);
if ($length < 2) { // weird edge case
return true;
@@ -1,5 +1,3 @@
!function(){}(window)
-!function(){}(window)
-
-x = / [/] /;
+!function(){}(window)
@@ -1,3 +1,2 @@
!function(){}(window)
-!function(){}(window)
-x=/ [/] /;
+!function(){}(window)
@@ -1,4 +0,0 @@
-
-function testIssue74() {
- return /'/;
-}
@@ -1 +0,0 @@
-function testIssue74(){return /'/;}
@@ -1 +0,0 @@
-function testIssue74(){return /'/}
@@ -0,0 +1,20 @@
+function testIssue74() {
+ return /'/;
+}
+
+!function(s) {
+ return /^[£$€?.]/.test(s);
+}();
+
+typeof
+ / ' /;
+
+x = / [/] /;
+
+1
+
+/ foo;
+
+(2)
+
+/ foo;
@@ -0,0 +1,3 @@
+function testIssue74(){return /'/;}
+!function(s){return /^[£$€?.]/.test(s);}();typeof
+/ ' /;x=/ [/] /;1/foo;(2)/foo;
@@ -47,10 +47,10 @@ function test_JSMin()
}
}
- $src = file_get_contents($thisDir . '/_test_files/js/issue74.js');
- $minExpected = file_get_contents($thisDir . '/_test_files/js/issue74.min.js');
+ $src = file_get_contents($thisDir . '/_test_files/js/regexes.js');
+ $minExpected = file_get_contents($thisDir . '/_test_files/js/regexes.min.js');
$minOutput = JSMin::minify($src);
- assertTrue($minExpected == $minOutput, 'JSMin : Quotes in RegExp literals (Issue 74)');
+ assertTrue($minExpected == $minOutput, 'JSMin : Identify RegExp literals');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " .countBytes($minOutput). " bytes\n\n{$minOutput}\n\n";
echo "---Expected: " .countBytes($minExpected). " bytes\n\n{$minExpected}\n\n";

0 comments on commit 6f5721d

Please sign in to comment.