#NEWLINE# def test_aggregate( self ) : #NEWLINE# #INDENT# f = ( lambda current , next_element : ( current + next_element ) ) #NEWLINE# l = seq ( [ 1 , 2 , 3 , 4 ] ) #NEWLINE# self . assertEqual ( l . aggregate ( l ) , 10 ) #NEWLINE# self . assertEqual ( l . aggregate ( 0 , f ) , 10 ) #NEWLINE# self . assertEqual ( l . aggregate ( 0 , f , ( lambda x : ( 2 * x ) ) ) , 20 ) #NEWLINE# l = seq ( [ 'a' , 'b' , 'c' ] ) #NEWLINE# self . assertEqual ( l . aggregate ( f ) , 'abc' ) #NEWLINE# self . assertEqual ( l . aggregate ( '' , f ) , 'abc' ) #NEWLINE# self . assertEqual ( l . aggregate ( '' , f , ( lambda x : x . upper ( ) ) ) , 'ABC' ) #NEWLINE# self . assertEqual ( l . aggregate ( f ) , 'abc' ) #NEWLINE# self . assertEqual ( l . aggregate ( 'z' , f ) , 'zabc' ) #NEWLINE# self . assertEqual ( l . aggregate ( 'z' , f , ( lambda x : x . upper ( ) ) ) , 'ZABC' ) #NEWLINE# with self . assertRaises ( ValueError ) : #NEWLINE# #INDENT# l . aggregate ( ) #NEWLINE# #UNINDENT# with self . assertRaises ( ValueError ) : #NEWLINE# #INDENT# l . aggregate ( None , None , None , None )