Forráskód Böngészése

Fixing more unit tests

Sebastien Ros 11 éve
szülő
commit
079c6a1764

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.2.2.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_2_2 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.2.3.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_2_3 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.2.4.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_2_4 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.3.1.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category","Pass")]
     public class Test_11_3_1 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.3.2.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_3_2 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.4.1.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category","Pass")]
     public class Test_11_4_1 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.4.2.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_4_2 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.4.3.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_4_3 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.4.4.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_4_4 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.4.5.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_4_5 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.4.6.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_4_6 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.4.7.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_4_7 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.4.8.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_4_8 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.4.9.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_4_9 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.5.1.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_5_1 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.5.2.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_5_2 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.5.3.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_5_3 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.6.1.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category","Pass")]
     public class Test_11_6_1 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.6.2.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_6_2 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.8.7.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_8_7 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.9.1.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_9_1 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.9.2.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_9_2 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.9.4.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_9_4 : EcmaTest
     {
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/11.9.5.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 namespace Jint.Tests.Ecma
 {
+    [Trait("Category", "Pass")]
     public class Test_11_9_5 : EcmaTest
     {
         [Fact]

+ 3 - 1
Jint.sln

@@ -1,6 +1,8 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
+# Visual Studio 2013
+VisualStudioVersion = 12.0.21005.1
+MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jint.Tests", "Jint.Tests\Jint.Tests.csproj", "{37C7D4E0-8770-4E2A-8B6D-E53087868354}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jint.Benchmark", "Jint.Benchmark\Jint.Benchmark.csproj", "{8922A952-4F82-4A97-B41C-C0A9932BFFA8}"

+ 6 - 1
Jint/Jint.csproj

@@ -11,9 +11,14 @@
     <RootNamespace>Jint</RootNamespace>
     <AssemblyName>Jint</AssemblyName>
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
-    <TargetFrameworkProfile>Profile36</TargetFrameworkProfile>
+    <TargetFrameworkProfile>Profile136</TargetFrameworkProfile>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <FileUpgradeFlags>
+    </FileUpgradeFlags>
+    <UpgradeBackupLocation>
+    </UpgradeBackupLocation>
+    <OldToolsVersion>4.0</OldToolsVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>

+ 2 - 2
Jint/Native/Array/ArrayConstructor.cs

@@ -66,11 +66,11 @@ namespace Jint.Native.Array
                     throw new JavaScriptException(Engine.RangeError);
                 }
                 
-                instance.FastAddProperty("length", length, true, false, true);
+                instance.FastAddProperty("length", length, true, false, false);
             }
             else
             {
-                instance.FastAddProperty("length", 0, true, false, true);
+                instance.FastAddProperty("length", 0, true, false, false);
                 PrototypeObject.Push(instance, arguments);
             }
 

+ 1 - 11
Jint/Native/Date/DateInstance.cs

@@ -4,7 +4,7 @@ using Jint.Runtime;
 
 namespace Jint.Native.Date
 {
-    public class DateInstance : ObjectInstance, IPrimitiveType
+    public class DateInstance : ObjectInstance
     {
         // Maximum allowed value to prevent DateTime overflow
         private static readonly double Max = (DateTime.MaxValue - new DateTime(170, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
@@ -25,16 +25,6 @@ namespace Jint.Native.Date
             }
         }
 
-        Types IPrimitiveType.Type
-        {
-            get { return Types.Number; }
-        }
-
-        object IPrimitiveType.PrimitiveValue
-        {
-            get { return PrimitiveValue; }
-        }
-
         public DateTime ToDateTime()
         {
             if (double.IsNaN(PrimitiveValue) || PrimitiveValue > Max || PrimitiveValue < Min)

+ 2 - 1
Jint/Native/Object/ObjectInstance.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using Jint.Native.Date;
 using Jint.Native.String;
 using Jint.Runtime;
 using Jint.Runtime.Descriptors;
@@ -293,7 +294,7 @@ namespace Jint.Native.Object
         /// <returns></returns>
         public object DefaultValue(Types hint)
         {
-            if ((hint == Types.String) || (hint == Types.None && this is StringInstance))
+            if ((hint == Types.String) || (hint == Types.None && this is StringInstance) || this is DateInstance)
             {
                 var toString = Get("toString");
                 var callable = toString as ICallable;

+ 10 - 10
Jint/Runtime/ExpressionIntepreter.cs

@@ -153,8 +153,8 @@ namespace Jint.Runtime
             }
             else
             {
-                var rN = TypeConverter.ToNumber(rval);
                 var lN = TypeConverter.ToNumber(lval);
+                var rN = TypeConverter.ToNumber(rval);
 
                 if (double.IsNaN(rN) || double.IsNaN(lN))
                 {
@@ -798,6 +798,11 @@ namespace Jint.Runtime
         {
             var callee = EvaluateExpression(callExpression.Callee);
 
+            object thisObject;
+
+            // todo: implement as in http://www.ecma-international.org/ecma-262/5.1/#sec-11.2.4
+            var arguments = callExpression.Arguments.Select(EvaluateExpression).Select(_engine.GetValue).ToArray();
+
             var func = _engine.GetValue(callee);
 
             if (func == Undefined.Instance)
@@ -805,11 +810,6 @@ namespace Jint.Runtime
                 throw new JavaScriptException(_engine.TypeError);
             }
 
-            object thisObject;
-
-            // todo: implement as in http://www.ecma-international.org/ecma-262/5.1/#sec-11.2.4
-            var arguments = callExpression.Arguments.Select(EvaluateExpression).Select(_engine.GetValue).ToArray();
-
             if (TypeConverter.GetType(func) != Types.Object)
             {
                 throw new JavaScriptException(_engine.TypeError);
@@ -876,8 +876,8 @@ namespace Jint.Runtime
                         throw new JavaScriptException(_engine.SyntaxError);
                     }
 
-                    var oldValue = _engine.GetValue(value);
-                    var newValue = TypeConverter.ToNumber(oldValue) + 1;
+                    var oldValue = TypeConverter.ToNumber(_engine.GetValue(value));
+                    var newValue = oldValue + 1;
                     _engine.PutValue(r, newValue);
 
                     return updateExpression.Prefix ? newValue : oldValue;
@@ -892,8 +892,8 @@ namespace Jint.Runtime
                         throw new JavaScriptException(_engine.SyntaxError);
                     }
 
-                    oldValue = _engine.GetValue(value);
-                    newValue = TypeConverter.ToNumber(oldValue) - 1;
+                    oldValue = TypeConverter.ToNumber(_engine.GetValue(value));
+                    newValue = oldValue - 1;
                     _engine.PutValue(r, newValue);
 
                     return updateExpression.Prefix ? newValue : oldValue;