@@ -47,6 +47,36 @@ describe('XRegExp.matchRecursive addon:', function() {
4747 expect ( XRegExp . matchRecursive ( str , '<' , '>' , 'gy' ) ) . toEqual ( [ '1' , '<<2>>' , '3' ] ) ;
4848 } ) ;
4949
50+ it ( 'should throw for unbalanced left delimiter in first match without flag g' , function ( ) {
51+ expect ( function ( ) { XRegExp . matchRecursive ( '<' , '<' , '>' ) ; } ) . toThrow ( ) ;
52+ expect ( function ( ) { XRegExp . matchRecursive ( '<<>' , '<' , '>' ) ; } ) . toThrow ( ) ;
53+ } ) ;
54+
55+ it ( 'should not throw for unbalanced left delimiter after first match without flag g' , function ( ) {
56+ expect ( function ( ) { XRegExp . matchRecursive ( '<><' , '<' , '>' ) ; } ) . not . toThrow ( ) ;
57+ } ) ;
58+
59+ it ( 'should throw for unbalanced left delimiter anywhere in string with flag g' , function ( ) {
60+ expect ( function ( ) { XRegExp . matchRecursive ( '<' , '<' , '>' , 'g' ) ; } ) . toThrow ( ) ;
61+ expect ( function ( ) { XRegExp . matchRecursive ( '<<>' , '<' , '>' , 'g' ) ; } ) . toThrow ( ) ;
62+ expect ( function ( ) { XRegExp . matchRecursive ( '<><' , '<' , '>' , 'g' ) ; } ) . toThrow ( ) ;
63+ expect ( function ( ) { XRegExp . matchRecursive ( '.<.<>><' , '<' , '>' , 'g' ) ; } ) . toThrow ( ) ;
64+ } ) ;
65+
66+ it ( 'should throw for unbalanced right delimiter in first match without flag g' , function ( ) {
67+ expect ( function ( ) { XRegExp . matchRecursive ( '>' , '<' , '>' ) ; } ) . toThrow ( ) ;
68+ } ) ;
69+
70+ it ( 'should not throw for unbalanced right delimiter after first match without flag g' , function ( ) {
71+ expect ( function ( ) { XRegExp . matchRecursive ( '<>>' , '<' , '>' ) ; } ) . not . toThrow ( ) ;
72+ } ) ;
73+
74+ it ( 'should throw for unbalanced right delimiter anywhere in string with flag g' , function ( ) {
75+ expect ( function ( ) { XRegExp . matchRecursive ( '>' , '<' , '>' , 'g' ) ; } ) . toThrow ( ) ;
76+ expect ( function ( ) { XRegExp . matchRecursive ( '<>>' , '<' , '>' , 'g' ) ; } ) . toThrow ( ) ;
77+ expect ( function ( ) { XRegExp . matchRecursive ( '.<.<>>>' , '<' , '>' , 'g' ) ; } ) . toThrow ( ) ;
78+ } ) ;
79+
5080 // TODO: Add complete specs
5181
5282 } ) ;
0 commit comments