File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ def visit(self, node):
35
35
def visit (self , node ):
36
36
return str (node )
37
37
38
+ @visitor (Enum )
39
+ def visit (self , node ):
40
+ return str (node .name )
41
+
38
42
def indent_str (self , newLine = True ):
39
43
res = ' ' * self .currentIndent
40
44
if newLine :
Original file line number Diff line number Diff line change 1
- from luaparser .utils import tests
1
+ from luaparser .utils import tests
2
2
from luaparser import ast
3
3
from luaparser .astnodes import *
4
4
import textwrap
@@ -73,3 +73,47 @@ def test_cont_int_3(self):
73
73
tree = ast .parse (textwrap .dedent (r'x.a' ))
74
74
exp = Chunk (Block ([Index (idx = Name ('a' ), value = Name ('x' ))]))
75
75
self .assertEqual (exp , tree )
76
+
77
+ # luaparser.utils.visitor.VisitorException: No visitor found for class <enum 'StringDelimiter'> #11
78
+ def test_cont_int_4 (self ):
79
+ tree = ast .parse (textwrap .dedent (r'''
80
+ local function sayHello()
81
+ print('hello world !')
82
+ end
83
+ sayHello()
84
+ ''' ))
85
+ pretty_str = ast .to_pretty_str (tree )
86
+ exp = textwrap .dedent (r'''
87
+ Chunk: {} 4 keys
88
+ body: {} 4 keys
89
+ Block: {} 4 keys
90
+ body: [] 2 items
91
+ 0: {} 1 key
92
+ LocalFunction: {} 6 keys
93
+ start_char: 1
94
+ stop_char: 56
95
+ name: {} 4 keys
96
+ Name: {} 4 keys
97
+ id: 'sayHello'
98
+ args: [] 0 item
99
+ body: {} 4 keys
100
+ Block: {} 4 keys
101
+ stop_char: 56
102
+ body: [] 1 item
103
+ 0: {} 1 key
104
+ Call: {} 5 keys
105
+ func: {} 4 keys
106
+ Name: {} 4 keys
107
+ id: 'print'
108
+ args: [] 1 item
109
+ 0: {} 1 key
110
+ String: {} 5 keys
111
+ s: 'hello world !'
112
+ delimiter: SINGLE_QUOTE
113
+ 1: {} 1 key
114
+ Call: {} 5 keys
115
+ func: {} 4 keys
116
+ Name: {} 4 keys
117
+ id: 'sayHello'
118
+ args: [] 0 item''' )
119
+ self .assertEqual (exp , pretty_str )
You can’t perform that action at this time.
0 commit comments