@@ -23,7 +23,7 @@ void main() {
23
23
ExpressionVisitor visitor;
24
24
25
25
beforeEach (inject ((Logger _logger, Parser _parser) {
26
- context = {} ;
26
+ context = new TestContext () ;
27
27
var getterFactory = new DynamicFieldGetterFactory ();
28
28
changeDetector = new DirtyCheckingChangeDetector (getterFactory);
29
29
watchGrp = new RootWatchGroup (getterFactory, changeDetector, context);
@@ -217,8 +217,8 @@ void main() {
217
217
// should fire on initial adding
218
218
expect (watchGrp.fieldCost).toEqual (0 );
219
219
expect (changeDetector.count).toEqual (0 );
220
- var watch = watchGrp.watch (parse ('a.b ' ), (v, p) => logger (v));
221
- expect (watch.expression).toEqual ('a.b ' );
220
+ var watch = watchGrp.watch (parse ('a["b"] ' ), (v, p) => logger (v));
221
+ expect (watch.expression).toEqual ('[](a, "b") ' );
222
222
expect (watchGrp.fieldCost).toEqual (2 );
223
223
expect (changeDetector.count).toEqual (2 );
224
224
watchGrp.detectChanges ();
@@ -260,8 +260,8 @@ void main() {
260
260
// should fire on initial adding
261
261
expect (watchGrp.fieldCost).toEqual (0 );
262
262
var watch = watchGrp.watch (parse ('user' ), (v, p) => logger (v));
263
- var watchFirst = watchGrp.watch (parse ('user. first' ), (v, p) => logger (v));
264
- var watchLast = watchGrp.watch (parse ('user. last' ), (v, p) => logger (v));
263
+ var watchFirst = watchGrp.watch (parse ('user[" first"] ' ), (v, p) => logger (v));
264
+ var watchLast = watchGrp.watch (parse ('user[" last"] ' ), (v, p) => logger (v));
265
265
expect (watchGrp.fieldCost).toEqual (3 );
266
266
267
267
watchGrp.detectChanges ();
@@ -290,7 +290,7 @@ void main() {
290
290
291
291
FunctionApply fn = new LoggingFunctionApply (logger);
292
292
var watch = watchGrp.watch (
293
- new PureFunctionAST ('add' , fn, [parse ('a. val' )]),
293
+ new PureFunctionAST ('add' , fn, [parse ('a[" val"] ' )]),
294
294
(v, p) => logger (v)
295
295
);
296
296
@@ -316,7 +316,7 @@ void main() {
316
316
var watch = watchGrp.watch (
317
317
new PureFunctionAST ('add' ,
318
318
(a, b) { logger ('+' ); return a+ b; },
319
- [parse ('a. val' ), parse ('b. val' )]
319
+ [parse ('a[" val"] ' ), parse ('b[" val"] ' )]
320
320
),
321
321
(v, p) => logger (v)
322
322
);
@@ -361,7 +361,7 @@ void main() {
361
361
var watch = watchGrp.watch (
362
362
new ClosureAST ('sum' ,
363
363
(a, b) { logger ('+' ); return innerState+ a+ b; },
364
- [parse ('a. val' ), parse ('b. val' )]
364
+ [parse ('a[" val"] ' ), parse ('b[" val"] ' )]
365
365
),
366
366
(v, p) => logger (v)
367
367
);
@@ -414,11 +414,11 @@ void main() {
414
414
415
415
var a_plus_b = new PureFunctionAST ('add1' ,
416
416
(a, b) { logger ('$a +$b ' ); return a + b; },
417
- [parse ('a. val' ), parse ('b. val' )]);
417
+ [parse ('a[" val"] ' ), parse ('b[" val"] ' )]);
418
418
419
419
var a_plus_b_plus_c = new PureFunctionAST ('add2' ,
420
420
(b, c) { logger ('$b +$c ' ); return b + c; },
421
- [a_plus_b, parse ('c. val' )]);
421
+ [a_plus_b, parse ('c[" val"] ' )]);
422
422
423
423
var watch = watchGrp.watch (a_plus_b_plus_c, (v, p) => logger (v));
424
424
@@ -762,8 +762,8 @@ void main() {
762
762
});
763
763
764
764
it ('should support custom context' , () {
765
- expect (eval ('x' , { 'x' : 42 } )).toBe (42 );
766
- expect (eval ('x' , { 'x' : 87 } )).toBe (87 );
765
+ expect (eval ('x' , new Context ( 42 ) )).toBe (42 );
766
+ expect (eval ('x' , new Context ( 87 ) )).toBe (87 );
767
767
});
768
768
769
769
it ('should support named arguments for scope calls' , () {
@@ -857,10 +857,10 @@ void main() {
857
857
watchGrp.watch (countMethod, (v, p) => logger ('0a' ));
858
858
expectOrder (['0a' ]);
859
859
860
- var child1a = watchGrp.newGroup ({'my' : myClass});
861
- var child1b = watchGrp.newGroup ({'my' : myClass});
862
- var child2 = child1a.newGroup ({'my' : myClass});
863
- var child3 = child2.newGroup ({'my' : myClass});
860
+ var child1a = watchGrp.newGroup (new ContextLocals (context, {'my' : myClass}) );
861
+ var child1b = watchGrp.newGroup (new ContextLocals (context, {'my' : myClass}) );
862
+ var child2 = child1a.newGroup (new ContextLocals (context, {'my' : myClass}) );
863
+ var child3 = child2.newGroup (new ContextLocals (context, {'my' : myClass}) );
864
864
child1a.watch (countMethod, (v, p) => logger ('1a' ));
865
865
expectOrder (['0a' , '1a' ]);
866
866
child1b.watch (countMethod, (v, p) => logger ('1b' ));
@@ -888,7 +888,7 @@ void main() {
888
888
context['my' ] = myClass;
889
889
AST countMethod = new MethodAST (parse ('my' ), 'count' , []);
890
890
var ra = watchGrp.watch (countMethod, (v, p) => logger ('a' ));
891
- var child = watchGrp.newGroup ({'my' : myClass});
891
+ var child = watchGrp.newGroup (new ContextLocals (context, {'my' : myClass}) );
892
892
var cb = child.watch (countMethod, (v, p) => logger ('b' ));
893
893
894
894
expectOrder (['a' , 'b' ]);
@@ -975,3 +975,8 @@ class LoggingFunctionApply extends FunctionApply {
975
975
LoggingFunctionApply (this .logger);
976
976
apply (List args) => logger (args);
977
977
}
978
+
979
+ class Context {
980
+ var x;
981
+ Context (this .x);
982
+ }
0 commit comments