diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-03-03 15:32:15 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-03-05 19:51:15 +0100 |
commit | 8f0b3ab9c752a729819f285d5944d58007b8718d (patch) | |
tree | e8d02de294b9c1100d675f76e60e3fef0ea66043 /tests/scripts/python | |
parent | 1451e12c78565019f83c065cc0c582ef495dabe8 (diff) | |
download | weechat-8f0b3ab9c752a729819f285d5944d58007b8718d.zip |
tests/scripts: fix representation of `None` Python value in generated scripts
Diffstat (limited to 'tests/scripts/python')
-rwxr-xr-x | tests/scripts/python/unparse.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/scripts/python/unparse.py b/tests/scripts/python/unparse.py index ca8a98e28..5e22db7d3 100755 --- a/tests/scripts/python/unparse.py +++ b/tests/scripts/python/unparse.py @@ -406,6 +406,8 @@ class UnparsePerl(UnparsePython): """Add an AST Constant in output.""" if isinstance(node.value, str): self.add('"%s"' % node.s.replace('$', '\\$').replace('@', '\\@')) + elif node.value is None: + self.add('undef') else: self.add(repr(node.s)) @@ -547,6 +549,8 @@ class UnparseRuby(UnparsePython): """Add an AST Constant in output.""" if isinstance(node.value, str): self.add('"%s"' % node.s.replace('#{', '\\#{')) + elif node.value is None: + self.add('nil') else: self.add(repr(node.s)) @@ -654,6 +658,13 @@ class UnparseLua(UnparsePython): node.right, ) + def _ast_constant(self, node): + """Add an AST Constant in output.""" + if node.value is None: + self.add('nil') + else: + self.add(repr(node.s)) + def _ast_dict(self, node): """Add an AST Dict in output.""" self.add( @@ -811,6 +822,8 @@ class UnparseTcl(UnparsePython): """Add an AST Constant in output.""" if isinstance(node.value, str): self.add('"%s"' % node.s.replace('$', '\\$')) + elif node.value is None: + self.add('$::weechat::WEECHAT_NULL') else: self.add(repr(node.s)) @@ -1003,6 +1016,8 @@ class UnparseGuile(UnparsePython): """Add an AST Constant in output.""" if isinstance(node.s, str): self.add('"%s"' % node.s) + elif node.value is None: + self.add('#nil') else: self.add(repr(node.s)) @@ -1129,6 +1144,13 @@ class UnparseJavascript(UnparsePython): '}', ) + def _ast_constant(self, node): + """Add an AST Constant in output.""" + if node.value is None: + self.add('null') + else: + self.add(repr(node.s)) + def _ast_functiondef(self, node): """Add an AST FunctionDef in output.""" self.add( @@ -1233,6 +1255,8 @@ class UnparsePhp(UnparsePython): """Add an AST Constant in output.""" if isinstance(node.s, str): self.add('"%s"' % node.s.replace('$', '\\$')) + elif node.value is None: + self.add('NULL') else: self.add(repr(node.s)) |