@@ -311,6 +311,43 @@ describe('parser', function() {
311
311
expect ( scope . $eval ( "'abcd'|substring:1:3|uppercase" ) ) . toEqual ( "BC" ) ;
312
312
} ) ;
313
313
314
+ it ( 'should parse filters as method parameters' , function ( ) {
315
+ $filterProvider . register ( 'substring' , valueFn ( function ( input , start , end ) {
316
+ return input . substring ( start , end ) ;
317
+ } ) ) ;
318
+
319
+ scope . offset = 3 ;
320
+
321
+ scope . echo1 = function ( substring ) {
322
+ return substring ;
323
+ } ;
324
+
325
+ expect ( scope . $eval ( "echo1(('abcd'|substring:1:offset))" ) ) . toEqual ( "bc" ) ;
326
+ expect ( scope . $eval ( "echo1('abcd'|substring:1:offset)" ) ) . toEqual ( "bc" ) ;
327
+
328
+ scope . echo2 = function ( lowercaseSubstring , uppercaseSubstring ) {
329
+ return lowercaseSubstring + uppercaseSubstring ;
330
+ } ;
331
+
332
+ expect ( scope . $eval ( "echo2(('abcd'|substring:1:offset),('abcd'|substring:1:3|uppercase))" ) ) . toEqual ( "bcBC" ) ;
333
+ expect ( scope . $eval ( "echo2('abcd'|substring:1:offset,'abcd'|substring:1:3|uppercase)" ) ) . toEqual ( "bcBC" ) ;
334
+
335
+ expect ( scope . $eval ( "echo2('',('abcd'|substring:1:3|uppercase))" ) ) . toEqual ( "BC" ) ;
336
+ expect ( scope . $eval ( "echo2('','abcd'|substring:1:3|uppercase)" ) ) . toEqual ( "BC" ) ;
337
+
338
+ expect ( scope . $eval ( "echo2(null,('abcd'|substring:1:3|uppercase))" ) ) . toEqual ( "nullBC" ) ;
339
+ expect ( scope . $eval ( "echo2(null,'abcd'|substring:1:3|uppercase)" ) ) . toEqual ( "nullBC" ) ;
340
+
341
+ expect ( scope . $eval ( "echo2(undefined,('abcd'|substring:1:3|uppercase))" ) ) . toEqual ( "undefinedBC" ) ;
342
+ expect ( scope . $eval ( "echo2(undefined,'abcd'|substring:1:3|uppercase)" ) ) . toEqual ( "undefinedBC" ) ;
343
+
344
+ expect ( scope . $eval ( "echo2(('abcd'|substring:1:offset),null)" ) ) . toEqual ( "bcnull" ) ;
345
+ expect ( scope . $eval ( "echo2('abcd'|substring:1:offset,null)" ) ) . toEqual ( "bcnull" ) ;
346
+
347
+ expect ( scope . $eval ( "echo2(('abcd'|substring:1:offset),undefined)" ) ) . toEqual ( "bcundefined" ) ;
348
+ expect ( scope . $eval ( "echo2('abcd'|substring:1:offset,undefined)" ) ) . toEqual ( "bcundefined" ) ;
349
+ } ) ;
350
+
314
351
it ( 'should access scope' , function ( ) {
315
352
scope . a = 123 ;
316
353
scope . b = { c : 456 } ;
0 commit comments