Fix Date.prototype.setTime

This fixes #58
This commit is contained in:
Robert Krimen
2014-02-18 20:37:54 -08:00
parent e01dde79ed
commit 1f3aef2086
2 changed files with 20 additions and 1 deletions

View File

@@ -100,8 +100,10 @@ func builtinDate_getTime(call FunctionCall) Value {
}
func builtinDate_setTime(call FunctionCall) Value {
date := dateObjectOf(call.thisObject())
object := call.thisObject()
date := dateObjectOf(object)
date.Set(toFloat(call.Argument(0)))
object.value = date
return date.Value()
}

View File

@@ -421,3 +421,20 @@ func TestDate_setFullYear(t *testing.T) {
test(`Date.prototype.setFullYear.length`, "3")
test(`Date.prototype.setUTCFullYear.length`, "3")
}
func TestDate_setTime(t *testing.T) {
Terst(t)
defer mockTimeLocal(Time.UTC)()
test := runTest()
test(`
var abc = new Date(1999, 6, 1);
var def = new Date();
def.setTime(abc.getTime());
[ def, abc.valueOf() == def.valueOf() ];
`, "Thu, 01 Jul 1999 00:00:00 UTC,true")
test(`Date.prototype.setTime.length`, "1")
}