@@ -316,6 +316,22 @@ namespace Jint.Tests.Runtime
");
}
+ [Fact]
+ public void ShouldConvertDateToNumber()
+ {
+ RunTest(@"
+ assert(Number(new Date(0)) === 0);
+ ");
+ }
+
+ public void DatePrimitiveValueShouldBeNaN()
+ assert(isNaN(Date.prototype.valueOf()));
[Fact]
public void MathObjectIsDefined()
{
@@ -20,7 +20,8 @@ namespace Jint.Native.Date
var obj = new DatePrototype(engine)
Prototype = engine.Object.PrototypeObject,
- Extensible = true
+ Extensible = true,
+ PrimitiveValue = double.NaN
};
obj.FastAddProperty("constructor", dateConstructor, true, false, true);
@@ -295,7 +295,7 @@ namespace Jint.Native.Object
/// <returns></returns>
public JsValue DefaultValue(Types hint)
- if ((hint == Types.String) || (hint == Types.None && this is StringInstance) || this is DateInstance)
+ if (hint == Types.String || (hint == Types.None && Class == "Date"))
var toString = Get("toString").TryCast<ICallable>();
if (toString != null)
@@ -320,7 +320,7 @@ namespace Jint.Native.Object
throw new JavaScriptException(Engine.TypeError);
- if ((hint == Types.Number) || (hint == Types.None))
+ if (hint == Types.Number || hint == Types.None)
var valueOf = Get("valueOf").TryCast<ICallable>();
if (valueOf != null)