@@ -142,7 +142,8 @@ def test_multiselect_subexpressions(self):
142142
143143 def test_multiselect_with_all_quoted_keys (self ):
144144 parsed = self .parser .parse ('foo.{"bar": bar.baz, "qux": qux}' )
145- result = parsed .search ({'foo' : {'bar' : {'baz' : 'CORRECT' }, 'qux' : 'qux' }})
145+ result = parsed .search (
146+ {'foo' : {'bar' : {'baz' : 'CORRECT' }, 'qux' : 'qux' }})
146147 self .assertEqual (result , {"bar" : "CORRECT" , "qux" : "qux" })
147148
148149 def test_function_call_with_and_statement (self ):
@@ -165,6 +166,38 @@ def test_root_node(self):
165166 ]
166167 })
167168
169+ def test_index_expression_index (self ):
170+ self .assert_parsed_ast (
171+ '[0]' ,
172+ {
173+ 'type' : 'index_expression' ,
174+ 'children' : [
175+ {'type' : 'identity' , 'children' : []},
176+ {'type' : 'index' , 'value' : 0 , 'children' : []}
177+ ]
178+ })
179+
180+ def test_index_expression_compound_index (self ):
181+ self .assert_parsed_ast (
182+ 'foo[0]' ,
183+ {
184+ 'type' : 'index_expression' ,
185+ 'children' : [
186+ {'type' : 'field' , 'value' : 'foo' , 'children' : []},
187+ {'type' : 'index' , 'value' : 0 , 'children' : []}
188+ ]
189+ })
190+
191+ def test_index_expression_flatten (self ):
192+ self .assert_parsed_ast (
193+ '[]' ,
194+ {'type' : 'index_expression' ,
195+ 'children' : [
196+ {'type' : 'identity' , 'children' : []},
197+ {'type' : 'flatten' , 'children' : []}
198+ ]
199+ })
200+
168201
169202class TestErrorMessages (unittest .TestCase ):
170203
@@ -352,6 +385,7 @@ def test_trailing_merged_operator(self):
352385 ["five" , "six" ], ["seven" , "eight" ],
353386 ["nine" ], ["ten" ]])
354387
388+
355389class TestTernaryOperatorExpressions (unittest .TestCase ):
356390 def setUp (self ):
357391 self .parser = parser .Parser ()
@@ -412,6 +446,7 @@ def test_thread_safety_of_cache(self):
412446 '' .join (random .choice (string .ascii_letters ) for _ in range (3 ))
413447 for _ in range (2000 )
414448 ]
449+
415450 def worker ():
416451 p = parser .Parser ()
417452 for expression in expressions :
0 commit comments