@@ -38,7 +38,6 @@ const run = assert => {
38
38
let string = 'ABB\u0041BABAB' ;
39
39
assert . same ( string . match ( object ) [ 0 ] , 'AB' , 'S15.5.4.10_A1_T10' ) ;
40
40
object = { toString ( ) { throw new Error ( 'intostr' ) ; } } ;
41
- string = 'ABB\u0041BABAB' ;
42
41
try {
43
42
string . match ( object ) ;
44
43
assert . avoid ( 'S15.5.4.10_A1_T11 #1 lead to throwing exception' ) ;
@@ -53,7 +52,6 @@ const run = assert => {
53
52
throw new Error ( 'intostr' ) ;
54
53
} ,
55
54
} ;
56
- string = 'ABB\u0041BABAB' ;
57
55
try {
58
56
string . match ( object ) ;
59
57
assert . avoid ( 'S15.5.4.10_A1_T12 #1 lead to throwing exception' ) ;
@@ -90,13 +88,11 @@ const run = assert => {
90
88
assert . same ( string . match ( / \d / g) [ i ] , matches [ i ] , 'S15.5.4.10_A2_T3 #2' ) ;
91
89
}
92
90
matches = [ '12' , '34' , '56' , '78' , '90' ] ;
93
- string = '123456abcde7890' ;
94
91
assert . same ( string . match ( / \d { 2 } / g) . length , 5 , 'S15.5.4.10_A2_T4 #1' ) ;
95
92
for ( let i = 0 , { length } = matches ; i < length ; ++ i ) {
96
93
assert . same ( string . match ( / \d { 2 } / g) [ i ] , matches [ i ] , 'S15.5.4.10_A2_T4 #2' ) ;
97
94
}
98
95
matches = [ 'ab' , 'cd' ] ;
99
- string = '123456abcde7890' ;
100
96
assert . same ( string . match ( / \D { 2 } / g) . length , 2 , 'S15.5.4.10_A2_T5 #1' ) ;
101
97
for ( let i = 0 , { length } = matches ; i < length ; ++ i ) {
102
98
assert . same ( string . match ( / \D { 2 } / g) [ i ] , matches [ i ] , 'S15.5.4.10_A2_T5 #2' ) ;
@@ -108,7 +104,6 @@ const run = assert => {
108
104
assert . same ( string . match ( / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / ) . length , 3 , 'S15.5.4.10_A2_T6 #4' ) ;
109
105
assert . same ( string . match ( / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / ) . index , 14 , 'S15.5.4.10_A2_T6 #5' ) ;
110
106
assert . same ( string . match ( / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / ) . input , string , 'S15.5.4.10_A2_T6 #6' ) ;
111
- string = 'Boston, Mass. 02134' ;
112
107
assert . same ( string . match ( / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / g) . length , 1 , 'S15.5.4.10_A2_T7 #1' ) ;
113
108
assert . same ( string . match ( / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / g) [ 0 ] , '02134' , 'S15.5.4.10_A2_T7 #2' ) ;
114
109
/* IE8- buggy here (empty string instead of `undefined`), but we don't polyfill base `.match` logic
@@ -153,35 +148,25 @@ const run = assert => {
153
148
regexp = / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / g;
154
149
assert . same ( string . match ( regexp ) . length , 1 , 'S15.5.4.10_A2_T12 #1' ) ;
155
150
assert . same ( string . match ( regexp ) [ 0 ] , '02134' , 'S15.5.4.10_A2_T12 #2' ) ;
156
- regexp = / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / g;
157
151
regexp . lastIndex = 0 ;
158
- string = 'Boston, MA 02134' ;
159
152
assert . same ( string . match ( regexp ) . length , 1 , 'S15.5.4.10_A2_T13 #1' ) ;
160
153
assert . same ( string . match ( regexp ) [ 0 ] , '02134' , 'S15.5.4.10_A2_T13 #2' ) ;
161
- string = 'Boston, MA 02134' ;
162
- regexp = / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / g;
163
154
regexp . lastIndex = string . length ;
164
155
assert . same ( string . match ( regexp ) . length , 1 , 'S15.5.4.10_A2_T14 #1' ) ;
165
156
assert . same ( string . match ( regexp ) [ 0 ] , '02134' , 'S15.5.4.10_A2_T14 #2' ) ;
166
- string = 'Boston, MA 02134' ;
167
- regexp = / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / g;
168
157
regexp . lastIndex = string . lastIndexOf ( '0' ) ;
169
158
assert . same ( string . match ( regexp ) . length , 1 , 'S15.5.4.10_A2_T15 #1' ) ;
170
159
assert . same ( string . match ( regexp ) [ 0 ] , '02134' , 'S15.5.4.10_A2_T15 #2' ) ;
171
- string = 'Boston, MA 02134' ;
172
- regexp = / ( \d { 5 } ) ( [ - ] ? \d { 4 } ) ? $ / g;
173
160
regexp . lastIndex = string . lastIndexOf ( '0' ) + 1 ;
174
161
assert . same ( string . match ( regexp ) . length , 1 , 'S15.5.4.10_A2_T16 #1' ) ;
175
162
assert . same ( string . match ( regexp ) [ 0 ] , '02134' , 'S15.5.4.10_A2_T16 #2' ) ;
176
163
regexp = / 0 ./ ;
177
- let number = 10203040506070809000 ;
164
+ const number = 10203040506070809000 ;
178
165
assert . same ( '' . match . call ( number , regexp ) [ 0 ] , '02' , 'S15.5.4.10_A2_T17 #1' ) ;
179
166
assert . same ( '' . match . call ( number , regexp ) . length , 1 , 'S15.5.4.10_A2_T17 #2' ) ;
180
167
assert . same ( '' . match . call ( number , regexp ) . index , 1 , 'S15.5.4.10_A2_T17 #3' ) ;
181
168
assert . same ( '' . match . call ( number , regexp ) . input , String ( number ) , 'S15.5.4.10_A2_T17 #4' ) ;
182
- regexp = / 0 ./ ;
183
169
regexp . lastIndex = 0 ;
184
- number = 10203040506070809000 ;
185
170
assert . same ( '' . match . call ( number , regexp ) [ 0 ] , '02' , 'S15.5.4.10_A2_T18 #1' ) ;
186
171
assert . same ( '' . match . call ( number , regexp ) . length , 1 , 'S15.5.4.10_A2_T18 #2' ) ;
187
172
assert . same ( '' . match . call ( number , regexp ) . index , 1 , 'S15.5.4.10_A2_T18 #3' ) ;
0 commit comments