Update the javascript diff driver's function pattern.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/src/userdiff.h b/src/userdiff.h
index 523f2f8..91c1f42 100644
--- a/src/userdiff.h
+++ b/src/userdiff.h
@@ -191,9 +191,9 @@ PATTERNS("php",
"|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
PATTERNS("javascript",
- "^[ \t]*(function[ \t][a-zA-Z_][^\\{]*)\n"
- "^[ \t]*(var[ \t]+[a-zA-Z_][a-zA-Z0-9_]*[ \t]*=[ \t]*function[ \t\\(][^\\{]*)\n"
- "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*[ \t]*:[ \t]*function[ \t\\(][^\\{]*)",
+ "([a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z0-9_$]+)*[ \t]*=[ \t]*function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)\n"
+ "([a-zA-Z_$][a-zA-Z0-9_$]*[ \t]*:[ \t]*function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)\n"
+ "[^a-zA-Z0-9_\\$](function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)",
/* -- */
"[a-zA-Z_][a-zA-Z0-9_]*"
"|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?"
diff --git a/tests/resources/userdiff/expected/driver/diff.javascript b/tests/resources/userdiff/expected/driver/diff.javascript
index 44ea9cf..4cefe5c 100644
--- a/tests/resources/userdiff/expected/driver/diff.javascript
+++ b/tests/resources/userdiff/expected/driver/diff.javascript
@@ -2,7 +2,7 @@ diff --git a/files/file.javascript b/files/file.javascript
index 0965b37..5391797 100644
--- a/files/file.javascript
+++ b/files/file.javascript
-@@ -4,4 +4,3 @@
+@@ -4,4 +4,3 @@ function(require, exports, module)
var Key = require("./key")
- , Direction = require("./direction")
- , Image = require("./image");
@@ -15,12 +15,12 @@ index 0965b37..5391797 100644
+ this.pixelX = 10;
+ this.pixelY = 10;
-@@ -82,3 +81,3 @@ function Player(game)
+@@ -82,3 +81,3 @@ Player.prototype.moveUp = function()
Player.prototype.moveLeft = function() {
- this.x -= 1;
+ this.x -= 5;
this.direction = Direction.LEFT;
-@@ -106,3 +105,3 @@ function Player(game)
+@@ -106,3 +105,3 @@ Player.prototype.draw = function(context)
- context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY - 16, 32, 48);
+ context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY, 32, 48);