Skip to content

Commit 30eca77

Browse files
gibson042rwaldron
authored andcommittedSep 13, 2021
Add assertion messages
1 parent 1a65577 commit 30eca77

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed
 

‎test/built-ins/RegExp/prototype/exec/failure-lastindex-set.js

+23-9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var R_g = /./g, R_y = /./y, R_gy = /./gy;
2929

3030
var S = "test";
3131

32+
var lastIndex;
3233
var bigLastIndexes = [
3334
Infinity,
3435
Number.MAX_VALUE,
@@ -43,15 +44,28 @@ var bigLastIndexes = [
4344
5
4445
];
4546
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;
4951

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);
5361

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");
5771
}

0 commit comments

Comments
 (0)
Please sign in to comment.