1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00

Test DefineOwnProperty (Array)

This commit is contained in:
Robert Krimen 2013-07-21 17:37:18 -07:00
parent 5282a5a45b
commit ac8b526ba6
2 changed files with 25 additions and 1 deletions

View File

@ -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")
}

View File

@ -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" {