@@ -339,6 +339,43 @@ describe('parser', function() {
339
339
expect ( scope . $eval ( "'abcd'|substring:1:3|uppercase" ) ) . toEqual ( "BC" ) ;
340
340
} ) ;
341
341
342
+ it ( 'should parse filters as method parameters' , function ( ) {
343
+ $filterProvider . register ( 'substring' , valueFn ( function ( input , start , end ) {
344
+ return input . substring ( start , end ) ;
345
+ } ) ) ;
346
+
347
+ scope . offset = 3 ;
348
+
349
+ scope . echo1 = function ( substring ) {
350
+ return substring ;
351
+ } ;
352
+
353
+ expect ( scope . $eval ( "echo1(('abcd'|substring:1:offset))" ) ) . toEqual ( "bc" ) ;
354
+ expect ( scope . $eval ( "echo1('abcd'|substring:1:offset)" ) ) . toEqual ( "bc" ) ;
355
+
356
+ scope . echo2 = function ( lowercaseSubstring , uppercaseSubstring ) {
357
+ return lowercaseSubstring + uppercaseSubstring ;
358
+ } ;
359
+
360
+ expect ( scope . $eval ( "echo2(('abcd'|substring:1:offset),('abcd'|substring:1:3|uppercase))" ) ) . toEqual ( "bcBC" ) ;
361
+ expect ( scope . $eval ( "echo2('abcd'|substring:1:offset,'abcd'|substring:1:3|uppercase)" ) ) . toEqual ( "bcBC" ) ;
362
+
363
+ expect ( scope . $eval ( "echo2('',('abcd'|substring:1:3|uppercase))" ) ) . toEqual ( "BC" ) ;
364
+ expect ( scope . $eval ( "echo2('','abcd'|substring:1:3|uppercase)" ) ) . toEqual ( "BC" ) ;
365
+
366
+ expect ( scope . $eval ( "echo2(null,('abcd'|substring:1:3|uppercase))" ) ) . toEqual ( "nullBC" ) ;
367
+ expect ( scope . $eval ( "echo2(null,'abcd'|substring:1:3|uppercase)" ) ) . toEqual ( "nullBC" ) ;
368
+
369
+ expect ( scope . $eval ( "echo2(undefined,('abcd'|substring:1:3|uppercase))" ) ) . toEqual ( "undefinedBC" ) ;
370
+ expect ( scope . $eval ( "echo2(undefined,'abcd'|substring:1:3|uppercase)" ) ) . toEqual ( "undefinedBC" ) ;
371
+
372
+ expect ( scope . $eval ( "echo2(('abcd'|substring:1:offset),null)" ) ) . toEqual ( "bcnull" ) ;
373
+ expect ( scope . $eval ( "echo2('abcd'|substring:1:offset,null)" ) ) . toEqual ( "bcnull" ) ;
374
+
375
+ expect ( scope . $eval ( "echo2(('abcd'|substring:1:offset),undefined)" ) ) . toEqual ( "bcundefined" ) ;
376
+ expect ( scope . $eval ( "echo2('abcd'|substring:1:offset,undefined)" ) ) . toEqual ( "bcundefined" ) ;
377
+ } ) ;
378
+
342
379
it ( 'should access scope' , function ( ) {
343
380
scope . a = 123 ;
344
381
scope . b = { c : 456 } ;
0 commit comments