mirror of
https://github.com/robertkrimen/otto
synced 2025-10-19 19:55: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 ];
|
[ ghi ];
|
||||||
`, "true")
|
`, "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) {
|
func TestFunction_toString(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,12 @@ func (runtime *_runtime) newBoundFunctionObject(target *_object, this Value, arg
|
||||||
call: newBoundCallFunction(target, this, argumentList),
|
call: newBoundCallFunction(target, this, argumentList),
|
||||||
construct: defaultConstructFunction,
|
construct: defaultConstructFunction,
|
||||||
}
|
}
|
||||||
// FIXME
|
length := int(toInt32(target.get("length")))
|
||||||
self.defineProperty("length", toValue_int(0), 0000, false)
|
length -= len(argumentList)
|
||||||
|
if length < 0 {
|
||||||
|
length = 0
|
||||||
|
}
|
||||||
|
self.defineProperty("length", toValue_int(length), 0000, false)
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user