mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-31 19:53:50 +01:00 
			
		
		
		
	Make "length" coercion test more precise
This commit is contained in:
		
							parent
							
								
									3f6b961428
								
							
						
					
					
						commit
						807afd9120
					
				| @ -2,32 +2,31 @@ | |||||||
| // This code is governed by the BSD license found in the LICENSE file.
 | // This code is governed by the BSD license found in the LICENSE file.
 | ||||||
| 
 | 
 | ||||||
| /*--- | /*--- | ||||||
|  | esid: sec-regexp.prototype-@@replace | ||||||
| description: > | description: > | ||||||
|     Type coercion of `length` property of result |   Type coercion of "length" property of the value returned by RegExpExec. | ||||||
| es6id: 21.2.5.8 |  | ||||||
| info: | | info: | | ||||||
|  |   RegExp.prototype [ @@replace ] ( string, replaceValue ) | ||||||
|  | 
 | ||||||
|  |   [...] | ||||||
|  |   14. For each result in results, do | ||||||
|  |     a. Let nCaptures be ? LengthOfArrayLike(result). | ||||||
|     [...] |     [...] | ||||||
|     13. Repeat, while done is false |  | ||||||
|         a. Let result be RegExpExec(rx, S). |  | ||||||
|         [...] |  | ||||||
|     16. Repeat, for each result in results, |  | ||||||
|         a. Let nCaptures be ToLength(Get(result, "length")). |  | ||||||
|         [...] |  | ||||||
| features: [Symbol.replace] | features: [Symbol.replace] | ||||||
| ---*/ | ---*/ | ||||||
| 
 | 
 | ||||||
| var r = /./; | var r = /./; | ||||||
| var counter = 0; |  | ||||||
| var coercibleIndex = { | var coercibleIndex = { | ||||||
|   length: { |   length: { | ||||||
|     valueOf: function() { |     valueOf: function() { | ||||||
|       return 3.9; |       return 3.9; | ||||||
|     } |     }, | ||||||
|   }, |   }, | ||||||
|   0: '', |   0: '', | ||||||
|   1: 'foo', |   1: 'foo', | ||||||
|   2: 'bar', |   2: 'bar', | ||||||
|   3: 'baz' |   3: 'baz', | ||||||
|  |   index: 0, | ||||||
| }; | }; | ||||||
| r.exec = function() { | r.exec = function() { | ||||||
|   return coercibleIndex; |   return coercibleIndex; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user