Permalink
Browse files

Merge pull request #33 from agriffis/master

Fix visitors when node.init is a UnaryOp
  • Loading branch information...
rspivak committed May 20, 2012
2 parents 9029d72 + 1a2e6e7 commit 0f7b87bf5bd2c4444022f941db581f52554f530e
Showing with 9 additions and 2 deletions.
  1. +6 −0 src/slimit/tests/test_minifier.py
  2. +2 −1 src/slimit/visitors/ecmavisitor.py
  3. +1 −1 src/slimit/visitors/minvisitor.py
@@ -380,6 +380,12 @@ def assertMinified(self, source, expected):
# function call in FOR init
('for(o(); i < 3; i++) {}', 'for(o();i<3;i++){}'),
+ # unary increment operator in FOR init
+ ('for(i++; i < 3; i++) {}', 'for(i++;i<3;i++){}'),
+
+ # unary decrement operator in FOR init
+ ('for(i--; i < 3; i++) {}', 'for(i--;i<3;i++){}'),
+
# https://github.com/rspivak/slimit/issues/32
("""
Name.prototype = {
@@ -137,7 +137,8 @@ def visit_For(self, node):
s += self.visit(node.init)
if node.init is None:
s += ' ; '
- elif isinstance(node.init, (ast.Assign, ast.Comma, ast.FunctionCall)):
+ elif isinstance(node.init, (ast.Assign, ast.Comma, ast.FunctionCall,
+ ast.UnaryOp)):
s += '; '
else:
s += ' '
@@ -163,7 +163,7 @@ def visit_For(self, node):
if node.init is None:
s += ';'
elif isinstance(node.init, (ast.Assign, ast.Comma, ast.Conditional,
- ast.FunctionCall)):
+ ast.FunctionCall, ast.UnaryOp)):
s += ';'
else:
s += ''

0 comments on commit 0f7b87b

Please sign in to comment.