Browse Source

Passing more unit tests

Sebastien Ros 11 years ago
parent
commit
e17adc30ab

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 1 - 1
Jint/Native/Array/ArrayPrototype.cs

@@ -26,7 +26,7 @@ namespace Jint.Native.Array
                 };
 
             obj.FastAddProperty("length", 0, true, false, false);
-            obj.FastAddProperty("constructor", arrayConstructor, false, false, false);
+            obj.FastAddProperty("constructor", arrayConstructor, true, false, true);
 
             return obj;
         }

+ 1 - 1
Jint/Native/Boolean/BooleanPrototype.cs

@@ -19,7 +19,7 @@ namespace Jint.Native.Boolean
             obj.PrimitiveValue = false;
             obj.Extensible = true;
 
-            obj.FastAddProperty("constructor", booleanConstructor, false, false, false);
+            obj.FastAddProperty("constructor", booleanConstructor, true, false, true);
 
             return obj;
         }

+ 1 - 1
Jint/Native/Error/ErrorPrototype.cs

@@ -17,7 +17,7 @@ namespace Jint.Native.Error
         public static ErrorPrototype CreatePrototypeObject(Engine engine, ErrorConstructor errorConstructor, string name)
         {
             var obj = new ErrorPrototype(engine, name) { Extensible = true };
-            obj.FastAddProperty("constructor", errorConstructor, false, false, false);
+            obj.FastAddProperty("constructor", errorConstructor, true, false, true);
 
             if (name != "Error")
             {

+ 1 - 1
Jint/Native/Function/FunctionPrototype.cs

@@ -32,7 +32,7 @@ namespace Jint.Native.Function
 
         public void Configure()
         {
-            FastAddProperty("constructor", Engine.Function, false, false, false);
+            FastAddProperty("constructor", Engine.Function, true, false, true);
             FastAddProperty("toString", new ClrFunctionInstance<object, object>(Engine, ToString), true, false, true);
             FastAddProperty("apply", new ClrFunctionInstance<object, object>(Engine, Apply), true, false, true);
             FastAddProperty("call", new ClrFunctionInstance<object, object>(Engine, Call, 1), true, false, true);

+ 3 - 4
Jint/Native/Function/ScriptFunctionInstance.cs

@@ -37,15 +37,14 @@ namespace Jint.Native.Function
 
             var proto = engine.Object.Construct(Arguments.Empty);
             proto.DefineOwnProperty("constructor", new DataDescriptor(this) { Writable = true, Enumerable = false, Configurable = true }, false);
-            DefineOwnProperty("prototype", new DataDescriptor(proto) { Writable = true, Enumerable = false, Configurable = true }, false);
-
+            DefineOwnProperty("prototype", new DataDescriptor(proto) { Writable = true, Enumerable = false, Configurable = false }, false);
             DefineOwnProperty("name", new DataDescriptor(_functionDeclaration.Id), false);
             
             if (strict)
             {
                 var thrower = engine.Function.ThrowTypeError;
-                DefineOwnProperty("caller", new AccessorDescriptor(thrower) { Enumerable = false, Configurable = false }, false);
-                DefineOwnProperty("arguments", new AccessorDescriptor(thrower) { Enumerable = false, Configurable = false }, false);
+                DefineOwnProperty("caller", new AccessorDescriptor(thrower, thrower) { Enumerable = false, Configurable = false }, false);
+                DefineOwnProperty("arguments", new AccessorDescriptor(thrower, thrower) { Enumerable = false, Configurable = false }, false);
             }
         }
 

+ 1 - 1
Jint/Native/Number/NumberPrototype.cs

@@ -21,7 +21,7 @@ namespace Jint.Native.Number
             obj.PrimitiveValue = 0;
             obj.Extensible = true;
 
-            obj.FastAddProperty("constructor", numberConstructor, false, false, false);
+            obj.FastAddProperty("constructor", numberConstructor, true, false, true);
 
             return obj;
         }

+ 1 - 1
Jint/Native/Object/ObjectConstructor.cs

@@ -35,7 +35,7 @@ namespace Jint.Native.Object
             Prototype = Engine.Function.PrototypeObject;
 
             FastAddProperty("getPrototypeOf", new ClrFunctionInstance<object, object>(Engine, GetPrototypeOf, 1), false, false, false);
-            FastAddProperty("getOwnPropertyDescriptor", new ClrFunctionInstance<object, object>(Engine, GetOwnPropertyDescriptor), false, false, false);
+            FastAddProperty("getOwnPropertyDescriptor", new ClrFunctionInstance<object, object>(Engine, GetOwnPropertyDescriptor, 2), false, false, false);
             FastAddProperty("getOwnPropertyNames", new ClrFunctionInstance<object, object>(Engine, GetOwnPropertyNames), false, false, false);
             FastAddProperty("create", new ClrFunctionInstance<object, object>(Engine, Create), false, false, false);
             FastAddProperty("defineProperty", new ClrFunctionInstance<object, object>(Engine, DefineProperty), false, false, false);

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

@@ -15,7 +15,7 @@ namespace Jint.Native.Object
         {
             var obj = new ObjectPrototype(engine) { Extensible = true };
 
-            obj.FastAddProperty("constructor", objectConstructor, false, false, false);
+            obj.FastAddProperty("constructor", objectConstructor, true, false, true);
 
             return obj;
         }

+ 1 - 1
Jint/Native/RegExp/RegExpPrototype.cs

@@ -19,7 +19,7 @@ namespace Jint.Native.RegExp
             obj.Prototype = engine.Object.PrototypeObject;
             obj.Extensible = true;
 
-            obj.FastAddProperty("constructor", regExpConstructor, false, false, false);
+            obj.FastAddProperty("constructor", regExpConstructor, true, false, true);
 
             return obj;
         }

+ 17 - 2
Jint/Runtime/ExpressionIntepreter.cs

@@ -786,12 +786,27 @@ namespace Jint.Runtime
 
         public object EvaluateFunctionExpression(FunctionExpression functionExpression)
         {
-            return new ScriptFunctionInstance(
+            var funcEnv = LexicalEnvironment.NewDeclarativeEnvironment(_engine, _engine.ExecutionContext.LexicalEnvironment);
+            var envRec = (DeclarativeEnvironmentRecord)funcEnv.Record;
+
+            if (functionExpression.Id != null && !String.IsNullOrEmpty(functionExpression.Id.Name))
+            {
+                envRec.CreateMutableBinding(functionExpression.Id.Name);
+            }
+
+            var closure = new ScriptFunctionInstance(
                 _engine,
                 functionExpression,
-                LexicalEnvironment.NewDeclarativeEnvironment(_engine, _engine.ExecutionContext.LexicalEnvironment),
+                funcEnv,
                 functionExpression.Strict
                 );
+
+            if (functionExpression.Id != null && !String.IsNullOrEmpty(functionExpression.Id.Name))
+            {
+                envRec.InitializeImmutableBinding(functionExpression.Id.Name, closure);
+            }
+
+            return closure;
         }
 
         public object EvaluateCallExpression(CallExpression callExpression)