mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00
Fix .length property of functions via .bind
This commit is contained in:
parent
a36c19873f
commit
2d6125ee2c
|
@ -210,6 +210,13 @@ func TestFunction_bind(t *testing.T) {
|
|||
}
|
||||
[ ghi ];
|
||||
`, "true")
|
||||
|
||||
test(`
|
||||
var abc = function (def, ghi) {};
|
||||
var jkl = abc.bind({});
|
||||
var mno = abc.bind({}, 1, 2);
|
||||
[ jkl.length, mno.length ];
|
||||
`, "2,0")
|
||||
}
|
||||
|
||||
func TestFunction_toString(t *testing.T) {
|
||||
|
|
|
@ -38,8 +38,12 @@ func (runtime *_runtime) newBoundFunctionObject(target *_object, this Value, arg
|
|||
call: newBoundCallFunction(target, this, argumentList),
|
||||
construct: defaultConstructFunction,
|
||||
}
|
||||
// FIXME
|
||||
self.defineProperty("length", toValue_int(0), 0000, false)
|
||||
length := int(toInt32(target.get("length")))
|
||||
length -= len(argumentList)
|
||||
if length < 0 {
|
||||
length = 0
|
||||
}
|
||||
self.defineProperty("length", toValue_int(length), 0000, false)
|
||||
return self
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user