Permalink
Browse files

Merge pull request #38 from lelit/issue-37

Fix issue #37, handle simple identifier in FOR init
  • Loading branch information...
2 parents f9b8b22 + 19389e0 commit f87504e917b1bddae16b47ed274182ceef067076 @rspivak committed Oct 6, 2012
View
@@ -1,5 +1,8 @@
Change History
==============
+0.7.x (unreleased)
+- Bug fix (simple identifier in FOR init): https://github.com/rspivak/slimit/issues/37
+
0.7.4 (2012-06-5)
------------------
- Bug fix: https://github.com/rspivak/slimit/issues/34
@@ -391,6 +391,9 @@ def assertMinified(self, source, expected):
# unary decrement operator in FOR init
('for(i--; i < 3; i++) {}', 'for(i--;i<3;i++){}'),
+ # issue-37, simple identifier in FOR init
+ ('for(i; i < 3; i++) {}', 'for(i;i<3;i++){}'),
+
# https://github.com/rspivak/slimit/issues/32
("""
Name.prototype = {
@@ -195,6 +195,18 @@ class ASITestCase(unittest.TestCase):
}
"""),
+
+ ("""
+ var i;
+ for (i; i < length; i++) {
+ }
+ """,
+ """
+ var i;
+ for (i; i < length; i++) {
+
+ }
+ """),
]
def test_throw_statement(self):
@@ -138,7 +138,7 @@ def visit_For(self, node):
if node.init is None:
s += ' ; '
elif isinstance(node.init, (ast.Assign, ast.Comma, ast.FunctionCall,
- ast.UnaryOp)):
+ ast.UnaryOp, ast.Identifier)):
s += '; '
else:
s += ' '
@@ -163,7 +163,8 @@ def visit_For(self, node):
if node.init is None:
s += ';'
elif isinstance(node.init, (ast.Assign, ast.Comma, ast.Conditional,
- ast.FunctionCall, ast.UnaryOp)):
+ ast.FunctionCall, ast.UnaryOp,
+ ast.Identifier)):
s += ';'
else:
s += ''

0 comments on commit f87504e

Please sign in to comment.