@@ -246,7 +246,7 @@ function addVows(tests) {
246
246
}
247
247
248
248
this . addListener ( "end" , function ( honored , broken , errored ) {
249
- var topic , vow , env ;
249
+ var topic ;
250
250
251
251
vows . remaining += remaining ;
252
252
@@ -309,15 +309,18 @@ function addVows(tests) {
309
309
Object . keys ( ctx . tests ) . filter ( function ( k ) {
310
310
return ctx . tests [ k ] && k !== 'topic' ;
311
311
} ) . forEach ( function ( item ) {
312
+ // Create a new evaluation context,
313
+ // inheriting from the parent one.
314
+ var env = Object . create ( ctx . env ) ;
315
+
312
316
// Holds the current test or context
313
- vow = Object . create ( {
317
+ var vow = Object . create ( {
314
318
callback : ctx . tests [ item ] ,
315
319
context : ctx . name ,
316
320
description : item ,
317
321
binding : ctx . env ,
318
322
promise : promise
319
323
} ) ;
320
- env = Object . create ( ctx . env ) ;
321
324
322
325
// If we encounter a function, add it to the callbacks
323
326
// of the `topic` function, so it'll get called once the
@@ -331,11 +334,11 @@ function addVows(tests) {
331
334
// before calling the inner context. Else, just run the inner context
332
335
// synchronously.
333
336
if ( topic ) {
334
- topic . addListener ( "success" , function ( vow , ctx , env ) {
337
+ topic . addListener ( "success" , function ( ctx ) {
335
338
return function ( val ) {
336
339
return run ( new ( Context ) ( vow , ctx , env ) , lastTopic ) ;
337
340
} ;
338
- } ( vow , ctx , env ) ) ;
341
+ } ( ctx ) ) ;
339
342
} else {
340
343
run ( new ( Context ) ( vow , ctx , env ) , lastTopic ) ;
341
344
}
0 commit comments