@@ -467,6 +467,36 @@ describe('Twig.js Expressions ->', function () {
467467 output . should . equal ( '23' ) ;
468468 } ) ;
469469
470+ it ( 'should support slice shorthand (full form) with negative start' , function ( ) {
471+ const testTemplate = twig ( { data : '{{ "12345"[-2:1] }}' } ) ;
472+ const output = testTemplate . render ( ) ;
473+ output . should . equal ( '4' ) ;
474+ } ) ;
475+
476+ it ( 'should support slice shorthand (full form) with negative lenght' , function ( ) {
477+ const testTemplate = twig ( { data : '{{ "12345"[2:-1] }}' } ) ;
478+ const output = testTemplate . render ( ) ;
479+ output . should . equal ( '34' ) ;
480+ } ) ;
481+
482+ it ( 'should support slice shorthand (full form) with variables as arguments' , function ( ) {
483+ const testTemplate = twig ( { data : '{{ "12345"[start:length] }}' } ) ;
484+ const output = testTemplate . render ( { start : 2 , length : 3 } ) ;
485+ output . should . equal ( '345' ) ;
486+ } ) ;
487+
488+ it ( 'should support slice shorthand (full form) with variable as argument (omit first)' , function ( ) {
489+ const testTemplate = twig ( { data : '{{ "12345"[:length] }}' } ) ;
490+ const output = testTemplate . render ( { length : 3 } ) ;
491+ output . should . equal ( '123' ) ;
492+ } ) ;
493+
494+ it ( 'should support slice shorthand (full form) variable as argument (omit last)' , function ( ) {
495+ const testTemplate = twig ( { data : '{{ "12345"[start:] }}' } ) ;
496+ const output = testTemplate . render ( { start : 2 } ) ;
497+ output . should . equal ( '345' ) ;
498+ } ) ;
499+
470500 it ( 'should support slice shorthand (omit first)' , function ( ) {
471501 const testTemplate = twig ( { data : '{{ "12345"[:2] }}' } ) ;
472502 const output = testTemplate . render ( ) ;
0 commit comments