@@ -29,6 +29,7 @@ var R_g = /./g, R_y = /./y, R_gy = /./gy;
29
29
30
30
var S = "test" ;
31
31
32
+ var lastIndex ;
32
33
var bigLastIndexes = [
33
34
Infinity ,
34
35
Number . MAX_VALUE ,
@@ -43,15 +44,28 @@ var bigLastIndexes = [
43
44
5
44
45
] ;
45
46
for ( var i = 0 ; i < bigLastIndexes . length ; i ++ ) {
46
- R_g . lastIndex = bigLastIndexes [ i ] ;
47
- R_y . lastIndex = bigLastIndexes [ i ] ;
48
- R_gy . lastIndex = bigLastIndexes [ i ] ;
47
+ lastIndex = bigLastIndexes [ i ] ;
48
+ R_g . lastIndex = lastIndex ;
49
+ R_y . lastIndex = lastIndex ;
50
+ R_gy . lastIndex = lastIndex ;
49
51
50
- assert . sameValue ( R_g . exec ( S ) , null ) ;
51
- assert . sameValue ( R_y . exec ( S ) , null ) ;
52
- assert . sameValue ( R_gy . exec ( S ) , null ) ;
52
+ assert . sameValue ( R_g . exec ( S ) , null ,
53
+ "global RegExp instance must fail to match against '" + S +
54
+ "' at lastIndex " + lastIndex ) ;
55
+ assert . sameValue ( R_y . exec ( S ) , null ,
56
+ "sticky RegExp instance must fail to match against '" + S +
57
+ "' at lastIndex " + lastIndex ) ;
58
+ assert . sameValue ( R_gy . exec ( S ) , null ,
59
+ "global sticky RegExp instance must fail to match against '" + S +
60
+ "' at lastIndex " + lastIndex ) ;
53
61
54
- assert . sameValue ( R_g . lastIndex , 0 ) ;
55
- assert . sameValue ( R_y . lastIndex , 0 ) ;
56
- assert . sameValue ( R_gy . lastIndex , 0 ) ;
62
+ assert . sameValue ( R_g . lastIndex , 0 ,
63
+ "global RegExp instance lastIndex must be reset after " + lastIndex +
64
+ " exceeds string length" ) ;
65
+ assert . sameValue ( R_y . lastIndex , 0 ,
66
+ "sticky RegExp instance lastIndex must be reset after " + lastIndex +
67
+ " exceeds string length" ) ;
68
+ assert . sameValue ( R_gy . lastIndex , 0 ,
69
+ "global sticky RegExp instance lastIndex must be reset after " + lastIndex +
70
+ " exceeds string length" ) ;
57
71
}
0 commit comments