فهرست منبع

Fixing Error, Object and Object Prototype tests

Sebastien Ros 11 سال پیش
والد
کامیت
7a61b8013a
35فایلهای تغییر یافته به همراه89 افزوده شده و 44 حذف شده
  1. 1 0
      Jint.Tests.Ecma/Ecma/15.11.1.1.cs
  2. 1 0
      Jint.Tests.Ecma/Ecma/15.11.1.cs
  3. 1 0
      Jint.Tests.Ecma/Ecma/15.11.2.1.cs
  4. 1 0
      Jint.Tests.Ecma/Ecma/15.11.3.1.cs
  5. 1 0
      Jint.Tests.Ecma/Ecma/15.11.3.cs
  6. 1 0
      Jint.Tests.Ecma/Ecma/15.11.4.1.cs
  7. 1 0
      Jint.Tests.Ecma/Ecma/15.11.4.2.cs
  8. 1 0
      Jint.Tests.Ecma/Ecma/15.11.4.3.cs
  9. 1 0
      Jint.Tests.Ecma/Ecma/15.11.4.4.cs
  10. 1 0
      Jint.Tests.Ecma/Ecma/15.11.4.cs
  11. 1 0
      Jint.Tests.Ecma/Ecma/15.11.cs
  12. 1 0
      Jint.Tests.Ecma/Ecma/15.2.3.10.cs
  13. 1 0
      Jint.Tests.Ecma/Ecma/15.2.3.11.cs
  14. 1 0
      Jint.Tests.Ecma/Ecma/15.2.3.12.cs
  15. 1 0
      Jint.Tests.Ecma/Ecma/15.2.3.13.cs
  16. 1 0
      Jint.Tests.Ecma/Ecma/15.2.3.14.cs
  17. 1 0
      Jint.Tests.Ecma/Ecma/15.2.3.6.cs
  18. 1 0
      Jint.Tests.Ecma/Ecma/15.2.3.7.cs
  19. 1 0
      Jint.Tests.Ecma/Ecma/15.2.3.8.cs
  20. 1 0
      Jint.Tests.Ecma/Ecma/15.2.3.9.cs
  21. 1 0
      Jint.Tests.Ecma/Ecma/15.2.4.1.cs
  22. 1 0
      Jint.Tests.Ecma/Ecma/15.2.4.2.cs
  23. 1 0
      Jint.Tests.Ecma/Ecma/15.2.4.3.cs
  24. 1 0
      Jint.Tests.Ecma/Ecma/15.2.4.4.cs
  25. 1 0
      Jint.Tests.Ecma/Ecma/15.2.4.5.cs
  26. 1 0
      Jint.Tests.Ecma/Ecma/15.2.4.6.cs
  27. 1 0
      Jint.Tests.Ecma/Ecma/15.2.4.7.cs
  28. 1 0
      Jint.Tests.Ecma/Ecma/15.2.4.cs
  29. 4 4
      Jint/Native/Argument/ArgumentsObject.cs
  30. 0 1
      Jint/Native/Error/ErrorInstance.cs
  31. 4 0
      Jint/Native/Error/ErrorPrototype.cs
  32. 6 5
      Jint/Native/Json/JsonSerializer.cs
  33. 27 19
      Jint/Native/Object/ObjectConstructor.cs
  34. 17 12
      Jint/Native/Object/ObjectInstance.cs
  35. 3 3
      Jint/Native/Object/ObjectPrototype.cs

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 4 - 4
Jint/Native/Argument/ArgumentsObject.cs

@@ -31,8 +31,8 @@ namespace Jint.Native.Argument
             obj.Strict = strict;
             var map = engine.Object.Construct(Arguments.Empty);
             var mappedNamed = new List<string>();
-            var indx = len - 1;
-            while (indx >= 0)
+            var indx = 0;
+            while (indx <= len - 1)
             {
                 var indxStr = TypeConverter.ToString(indx);
                 var val = args[indx];
@@ -49,7 +49,7 @@ namespace Jint.Native.Argument
                         map.DefineOwnProperty(indxStr, new ClrAccessDescriptor(engine, g, p) { Configurable = true }, false);
                     }
                 }
-                indx--;
+                indx++;
             }
 
             // step 12
@@ -134,7 +134,7 @@ namespace Jint.Native.Argument
                             map.Put(propertyName, desc.Value.Value, throwOnError);
                         }
 
-                        if (!desc.Writable.HasValue)
+                        if (desc.Writable.HasValue && desc.Writable.Value == false)
                         {
                             map.Delete(propertyName, false);
                         }

+ 0 - 1
Jint/Native/Error/ErrorInstance.cs

@@ -9,7 +9,6 @@ namespace Jint.Native.Error
             : base(engine)
         {
             FastAddProperty("name", name, true, false, true);
-            FastAddProperty("message", "", true, false, true);
         }
 
         public override string Class

+ 4 - 0
Jint/Native/Error/ErrorPrototype.cs

@@ -23,6 +23,10 @@ namespace Jint.Native.Error
             {
                 obj.Prototype = engine.Error.PrototypeObject;
             }
+            else
+            {
+                obj.Prototype = engine.Object.PrototypeObject;
+            }
 
             return obj;
         }

+ 6 - 5
Jint/Native/Json/JsonSerializer.cs

@@ -315,11 +315,12 @@ namespace Jint.Native.Json
             _stack.Push(value);
             var stepback = _indent;
             _indent += _gap;
-            var k = _propertyList;
-            if (k == null)
-            {
-                k = value.Properties.Where(x => x.Value.Enumerable.Value.AsBoolean()).Select(x => x.Key).ToList();
-            }
+            
+            var k = _propertyList ?? value.Properties
+                .Where(x => x.Value.Enumerable.HasValue && x.Value.Enumerable.Value == true)
+                .Select(x => x.Key)
+                .ToList();
+
             var partial = new List<string>();
             foreach (var p in k)
             {

+ 27 - 19
Jint/Native/Object/ObjectConstructor.cs

@@ -38,15 +38,15 @@ namespace Jint.Native.Object
             FastAddProperty("getOwnPropertyDescriptor", new ClrFunctionInstance(Engine, GetOwnPropertyDescriptor, 2), true, false, true);
             FastAddProperty("getOwnPropertyNames", new ClrFunctionInstance(Engine, GetOwnPropertyNames, 1), true, false, true);
             FastAddProperty("create", new ClrFunctionInstance(Engine, Create, 2), true, false, true);
-            FastAddProperty("defineProperty", new ClrFunctionInstance(Engine, DefineProperty), true, false, true);
-            FastAddProperty("defineProperties", new ClrFunctionInstance(Engine, DefineProperties), true, false, true);
+            FastAddProperty("defineProperty", new ClrFunctionInstance(Engine, DefineProperty, 3), true, false, true);
+            FastAddProperty("defineProperties", new ClrFunctionInstance(Engine, DefineProperties, 2), true, false, true);
             FastAddProperty("seal", new ClrFunctionInstance(Engine, Seal, 1), true, false, true);
             FastAddProperty("freeze", new ClrFunctionInstance(Engine, Freeze, 1), true, false, true);
             FastAddProperty("preventExtensions", new ClrFunctionInstance(Engine, PreventExtensions, 1), true, false, true);
             FastAddProperty("isSealed", new ClrFunctionInstance(Engine, IsSealed, 1), true, false, true);
             FastAddProperty("isFrozen", new ClrFunctionInstance(Engine, IsFrozen, 1), true, false, true);
             FastAddProperty("isExtensible", new ClrFunctionInstance(Engine, IsExtensible, 1), true, false, true);
-            FastAddProperty("keys", new ClrFunctionInstance(Engine, Keys), true, false, true);
+            FastAddProperty("keys", new ClrFunctionInstance(Engine, Keys, 1), true, false, true);
         }
 
         public ObjectPrototype PrototypeObject { get; private set; }
@@ -268,21 +268,21 @@ namespace Jint.Native.Object
             }
 
             var keys = o.Properties.Keys.ToArray();
-            foreach (var key in keys)
+            foreach (var p in keys)
             {
-                var prop = o.Properties[key];
-                if (prop.IsDataDescriptor())
+                var desc = o.GetOwnProperty(p);
+                if (desc.IsDataDescriptor())
                 {
-                    if (prop.Writable.HasValue)
+                    if (desc.Writable.HasValue && desc.Writable.Value.AsBoolean())
                     {
-                        prop.Writable = JsValue.False;
+                        desc.Writable = JsValue.False;
                     }
                 }
-                if (prop.Configurable.HasValue && prop.Configurable.Value.AsBoolean())
+                if (desc.Configurable.HasValue && desc.Configurable.Value.AsBoolean())
                 {
-                    prop.Configurable = JsValue.False;
+                    desc.Configurable = JsValue.False;
                 }
-                o.DefineOwnProperty(key, prop, true);
+                o.DefineOwnProperty(p, desc, true);
             }
             
             o.Extensible = false;
@@ -338,22 +338,23 @@ namespace Jint.Native.Object
                 throw new JavaScriptException(Engine.TypeError);
             }
 
-            foreach (var prop in o.Properties)
+            foreach (var p in o.Properties.Keys)
             {
-                if (prop.Value.IsDataDescriptor())
+                var desc = o.GetOwnProperty(p);
+                if (desc.IsDataDescriptor())
                 {
-                    if (prop.Value.Writable.HasValue)
+                    if (desc.Writable.HasValue && desc.Writable.Value.AsBoolean())
                     {
                         return false;
                     }
                 }
-                if (prop.Value.Configurable.HasValue && prop.Value.Configurable.Value.AsBoolean())
+                if (desc.Configurable.HasValue && desc.Configurable.Value.AsBoolean())
                 {
                     return false;
                 }
             }
 
-            if (o.Extensible)
+            if (o.Extensible == false)
             {
                 return true;
             }
@@ -382,12 +383,19 @@ namespace Jint.Native.Object
                 throw new JavaScriptException(Engine.TypeError);
             }
 
-            var n = o.Properties.Values.Count(x => x.Enumerable.HasValue && x.Enumerable.Value.AsBoolean());
+            var enumerableProperties = o.Properties
+                .Where(x => x.Value.Enumerable.HasValue && x.Value.Enumerable.Value.AsBoolean())
+                .ToArray();
+            var n = enumerableProperties.Length;
             var array = Engine.Array.Construct(new JsValue[] {n});
             var index = 0;
-            foreach (var prop in o.Properties.Where(x => x.Value.Enumerable.HasValue && x.Value.Enumerable.Value.AsBoolean()))
+            foreach (var prop in enumerableProperties)
             {
-                array.DefineOwnProperty(index.ToString(), new PropertyDescriptor(prop.Key, true, true, true), false);
+                var p = prop.Key;
+                array.DefineOwnProperty(
+                    TypeConverter.ToString(index), 
+                    new PropertyDescriptor(p, true, true, true), 
+                    false);
                 index++;
             }
             return array;

+ 17 - 12
Jint/Native/Object/ObjectInstance.cs

@@ -376,11 +376,19 @@ namespace Jint.Native.Object
                 {
                     if (desc.IsGenericDescriptor() || desc.IsDataDescriptor())
                     {
-                        Properties[propertyName] = new PropertyDescriptor(desc);
+                        Properties[propertyName] = new PropertyDescriptor(desc)
+                        {
+                            Value = desc.Value.HasValue ? desc.Value : JsValue.Undefined,
+                            Writable = desc.Writable.HasValue ? desc.Writable : false
+                        };
                     }
                     else
                     {
-                        Properties[propertyName] = new PropertyDescriptor(desc);
+                        Properties[propertyName] = new PropertyDescriptor(desc)
+                        {
+                            Enumerable = desc.Enumerable.HasValue ? desc.Enumerable : false,
+                            Configurable = desc.Configurable.HasValue ? desc.Configurable : false,
+                        };
                     }
                 }
 
@@ -388,12 +396,14 @@ namespace Jint.Native.Object
             }
 
             // Step 5
-            if (!current.Configurable.HasValue && !current.Enumerable.HasValue && !(current.IsDataDescriptor() && current.Writable.HasValue))
+            if (!current.Configurable.HasValue && 
+                !current.Enumerable.HasValue &&
+                !current.Writable.HasValue &&
+                !current.Get.HasValue &&
+                !current.Set.HasValue &&
+                !current.Value.HasValue)
             {
-                if (!desc.IsDataDescriptor())
-                {
-                    return true;
-                }
+                return true;
             }
 
             // Step 6
@@ -544,11 +554,6 @@ namespace Jint.Native.Object
                             }
                         }
                     }
-
-                    if (!desc.Writable.HasValue && current.Writable.HasValue)
-                    {
-                        desc.Enumerable = current.Enumerable;
-                    }
                 }
                 else if (current.IsAccessorDescriptor() && desc.IsAccessorDescriptor())
                 {

+ 3 - 3
Jint/Native/Object/ObjectPrototype.cs

@@ -24,9 +24,9 @@ namespace Jint.Native.Object
             FastAddProperty("toString", new ClrFunctionInstance(Engine, ToObjectString), true, false, true);
             FastAddProperty("toLocaleString", new ClrFunctionInstance(Engine, ToLocaleString), true, false, true);
             FastAddProperty("valueOf", new ClrFunctionInstance(Engine, ValueOf), true, false, true);
-            FastAddProperty("hasOwnProperty", new ClrFunctionInstance(Engine, HasOwnProperty), true, false, true);
-            FastAddProperty("isPrototypeOf", new ClrFunctionInstance(Engine, IsPrototypeOf), true, false, true);
-            FastAddProperty("propertyIsEnumerable", new ClrFunctionInstance(Engine, PropertyIsEnumerable), true, false, true);
+            FastAddProperty("hasOwnProperty", new ClrFunctionInstance(Engine, HasOwnProperty, 1), true, false, true);
+            FastAddProperty("isPrototypeOf", new ClrFunctionInstance(Engine, IsPrototypeOf, 1), true, false, true);
+            FastAddProperty("propertyIsEnumerable", new ClrFunctionInstance(Engine, PropertyIsEnumerable, 1), true, false, true);
         }
 
         private JsValue PropertyIsEnumerable(JsValue thisObject, JsValue[] arguments)