@@ -47,6 +47,36 @@ describe('XRegExp.matchRecursive addon:', function() {
47
47
expect ( XRegExp . matchRecursive ( str , '<' , '>' , 'gy' ) ) . toEqual ( [ '1' , '<<2>>' , '3' ] ) ;
48
48
} ) ;
49
49
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
+
50
80
// TODO: Add complete specs
51
81
52
82
} ) ;
0 commit comments