File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -405,6 +405,39 @@ def mapper(x, y):
405405 assert xs .subscriptions == [subscribe (200 , 290 )]
406406 assert invoked [0 ] == 3
407407
408+ def test_starmap_with_index_completed (self ):
409+ scheduler = TestScheduler ()
410+ invoked = [0 ]
411+ xs = scheduler .create_hot_observable (
412+ on_next (180 , (5 , 50 )),
413+ on_next (210 , (4 , 40 )),
414+ on_next (240 , (3 , 30 )),
415+ on_next (290 , (2 , 20 )),
416+ on_next (350 , (1 , 10 )),
417+ on_completed (400 ),
418+ on_next (410 , (- 1 , - 10 )),
419+ on_completed (420 ),
420+ on_error (430 , "ex" ),
421+ )
422+
423+ def factory ():
424+ def projection (x , y , index ):
425+ invoked [0 ] += 1
426+ return (x + 1 ) + (y + 10 ) + (index * 100 )
427+
428+ return xs .pipe (ops .starmap_indexed (projection ))
429+
430+ results = scheduler .start (factory )
431+ assert results .messages == [
432+ on_next (210 , 55 ),
433+ on_next (240 , 144 ),
434+ on_next (290 , 233 ),
435+ on_next (350 , 322 ),
436+ on_completed (400 ),
437+ ]
438+ assert xs .subscriptions == [subscribe (200 , 400 )]
439+ assert invoked [0 ] == 4
440+
408441
409442if __name__ == "__main__" :
410443 unittest .main ()
You can’t perform that action at this time.
0 commit comments