Permalink
Browse files

add +=, -= functions

  • Loading branch information...
1 parent 03261ca commit ec0799473a930f28790988b0c1d6ea71bdcc0107 @smtlaissezfaire committed Feb 25, 2013
Showing with 16 additions and 0 deletions.
  1. +4 −0 lib/loop/uglify.js
  2. +12 −0 test/integration/general-spec.js
View
4 lib/loop/uglify.js
@@ -385,6 +385,10 @@ var progn = function(tree) {
});
return [ "switch", switchCondition, switchTests];
+ } else if (f.contents === "+=") {
+ return [ "assign", "+", progn(args[0]), progn(args[1]) ];
+ } else if (f.contents === "-=") {
+ return [ "assign", "-", progn(args[0]), progn(args[1]) ];
} else if (f.contents === 'break') {
return [ 'break', null ];
} else {
View
12 test/integration/general-spec.js
@@ -391,4 +391,16 @@ describe("integration spec", function() {
var expected = 'var x=[]';
assert.equal(loop.compile(source), expected);
});
+
+ it("should convert +=", function() {
+ var source = "(+= foo 10)";
+ var expected = "foo+=10";
+ assert.equal(loop.compile(source), expected);
+ });
+
+ it("should convert -=", function() {
+ var source = "(-= foo 10)";
+ var expected = "foo-=10";
+ assert.equal(loop.compile(source), expected);
+ });
});

0 comments on commit ec07994

Please sign in to comment.