#NEWLINE# def test_while_sometimes_true( self ) : #NEWLINE# #INDENT# scheduler = TestScheduler ( ) #NEWLINE# xs = scheduler . create_cold_observable ( on_next ( 50 , 1 ) , on_next ( 100 , 2 ) , on_next ( 150 , 3 ) , on_next ( 200 , 4 ) , on_completed ( 250 ) ) #NEWLINE# n = [ 0 ] #NEWLINE# def create( ) : #NEWLINE# #INDENT# def predicate( x ) : #NEWLINE# #INDENT# n [ 0 ] += 1 #NEWLINE# return ( n [ 0 ] < 3 ) #NEWLINE# #UNINDENT# return Observable . while_do ( predicate , xs ) #NEWLINE# #UNINDENT# results = scheduler . start ( create ) #NEWLINE# results . messages . assert_equal ( on_next ( 250 , 1 ) , on_next ( 300 , 2 ) , on_next ( 350 , 3 ) , on_next ( 400 , 4 ) , on_next ( 500 , 1 ) , on_next ( 550 , 2 ) , on_next ( 600 , 3 ) , on_next ( 650 , 4 ) , on_completed ( 700 ) ) #NEWLINE# xs . subscriptions . assert_equal ( subscribe ( 200 , 450 ) , subscribe ( 450 , 700 ) )