@@ -209,18 +209,40 @@ def addplusplus(a, b, c=0):
209209
210210def test_tokens ():
211211 # Function without return value.
212- def sideeffect (n ):
213- n [0 ] += 2
212+ def extend (box ):
213+ box .extend ([1 , 2 ])
214+
215+ def increment (box ):
216+ for i in range (len (box )):
217+ box [i ] += 1
214218
215219 # Designate `a`, `b` as token inp/out arguments.
216220 graph = compose ('mygraph' )(
217221 operation (
218- name = 'sideeffect' ,
219- needs = ['n' , modifiers .token ('a' )],
220- provides = [modifiers .token ('b' )])(sideeffect )
222+ name = 'extend' ,
223+ needs = ['box' , modifiers .token ('a' )],
224+ provides = [modifiers .token ('b' )])(extend ),
225+ operation (
226+ name = 'increment' ,
227+ needs = ['box' , modifiers .token ('b' )],
228+ provides = modifiers .token ('c' ))(increment ),
229+ )
230+
231+ assert graph ({'box' : [0 ]})['box' ] == [1 , 2 , 3 ]
232+
233+ # Reverse order of functions.
234+ graph = compose ('mygraph' )(
235+ operation (
236+ name = 'increment' ,
237+ needs = ['box' , modifiers .token ('a' )],
238+ provides = modifiers .token ('b' ))(increment ),
239+ operation (
240+ name = 'extend' ,
241+ needs = ['box' , modifiers .token ('b' )],
242+ provides = [modifiers .token ('c' )])(extend ),
221243 )
222244
223- assert graph ({'n ' : [0 ]})['n ' ] == [2 ]
245+ assert graph ({'box ' : [0 ]})['box ' ] == [1 , 1 , 2 ]
224246
225247
226248def test_deleted_optional ():
0 commit comments