mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00
For DefaultValue: HintString (not HintNumber) if object is a Date
This commit is contained in:
parent
01f5fae58f
commit
4abba5f6c6
10
date_test.go
10
date_test.go
|
@ -122,3 +122,13 @@ func TestDate_setYear(t *testing.T) {
|
|||
test(`new Date(12564504e5).setYear(1996)`, "846223200000")
|
||||
test(`new Date(12564504e5).setYear(2000)`, "972453600000")
|
||||
}
|
||||
|
||||
func TestDateDefaultValue(t *testing.T) {
|
||||
Terst(t)
|
||||
|
||||
test := runTest()
|
||||
test(`
|
||||
var date = new Date();
|
||||
date + 0 === date.toString() + "0";
|
||||
`, "true")
|
||||
}
|
||||
|
|
|
@ -161,7 +161,12 @@ const (
|
|||
// 8.12.8
|
||||
func (self *_object) DefaultValue(hint _defaultValueHint) Value {
|
||||
if hint == defaultValueNoHint {
|
||||
hint = defaultValueHintNumber
|
||||
if self._Date != nil {
|
||||
// Date exception
|
||||
hint = defaultValueHintString
|
||||
} else {
|
||||
hint = defaultValueHintNumber
|
||||
}
|
||||
}
|
||||
methodSequence := []string{"valueOf", "toString"}
|
||||
if hint == defaultValueHintString {
|
||||
|
|
Loading…
Reference in New Issue
Block a user