mirror of
				https://github.com/robertkrimen/otto
				synced 2025-10-19 19:55:30 +08:00 
			
		
		
		
	Test DefineOwnProperty (Array)
This commit is contained in:
		
							parent
							
								
									5282a5a45b
								
							
						
					
					
						commit
						ac8b526ba6
					
				|  | @ -469,3 +469,27 @@ func TestArray_reduceRight(t *testing.T) { | |||
| 	test(`[1,2,3].reduceRight(function(result, value) { return result + value }, 4)`, "10") | ||||
| 	test(`[1,2,3].reduceRight(function(result, value) { return result + value })`, "6") | ||||
| } | ||||
| 
 | ||||
| func TestArray_defineOwnProperty(t *testing.T) { | ||||
| 	Terst(t) | ||||
| 
 | ||||
| 	test := runTest() | ||||
| 	test(` | ||||
|         var abc = []; | ||||
|         Object.defineProperty(abc, "length", { | ||||
|             writable: false | ||||
|         }); | ||||
|         abc.length; | ||||
|     `, "0") | ||||
| 
 | ||||
| 	test(`raise: | ||||
|         var abc = []; | ||||
|         var exception; | ||||
|         Object.defineProperty(abc, "length", { | ||||
|             writable: false | ||||
|         }); | ||||
|         Object.defineProperty(abc, "length", { | ||||
|             writable: true | ||||
|         }); | ||||
|     `, "TypeError") | ||||
| } | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ func arrayDefineOwnProperty(self *_object, name string, descriptor _property, th | |||
| 	lengthProperty := self.getOwnProperty("length") | ||||
| 	lengthValue, valid := lengthProperty.value.(Value) | ||||
| 	if !valid { | ||||
| 		return objectDefineOwnProperty(self, name, descriptor, throw) | ||||
| 		panic("Array.length != Value{}") | ||||
| 	} | ||||
| 	length := lengthValue.value.(uint32) | ||||
| 	if name == "length" { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Robert Krimen
						Robert Krimen