Commits

Ben Firshman committed 6437220

Broken pass

  • Participants
  • Parent commits 040011a

Comments (0)

Files changed (3)

kugelblitz/tests/__init__.py

     def test_aug_assign(self):
         self.assertCompilesTo('x += 1', 'x += 1;')
     
+    def test_pass(self):
+        self.assertCompilesTo(
+            """
+            def x():
+                pass
+            """,
+            """
+            var x = function () { };
+            """
+        )
+        self.assertCompilesTo(
+            """
+            if x:
+                pass
+            """,
+            """
+            if (x) { };
+            """
+        )
+    
     def test_complex_class(self):
         self.assertCompilesTo(
             """

kugelblitz/translator/__init__.py

             
             ast.Global: None,
             ast.Expr: ExprTranslator,
-            ast.Pass: None,
             ast.Break: None,
             ast.Continue: None,
             

kugelblitz/translator/toplevel.py

         s = []
         for node in body:
             translator = self.get_translator(node)
-            if isinstance(node, (ast.If,)):
+            if isinstance(node, ast.Pass):
+                continue
+            elif isinstance(node, ast.If):
                 s.append(translator.translate())
             else:
                 s.append('%s;' % translator.translate())