فهرست منبع

Fixing some tests

Sebastien Ros 8 سال پیش
والد
کامیت
7d3d59f231

+ 1 - 1
Jint.Tests/project.json

@@ -16,6 +16,6 @@
         }
       }
     },
-    //"net451": {}
+    "net451": {}
   }
 }

+ 1 - 0
Jint/Engine.cs

@@ -303,6 +303,7 @@ namespace Jint
             }
 
             parserOptions.AdaptRegexp = true;
+            parserOptions.Tolerant = false;
 
             var parser = new JavaScriptParser(source, parserOptions);
             return Execute(parser.ParseProgram());

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

@@ -33,7 +33,7 @@ namespace Jint.Native.Function
 
             try
             {
-                var parser = new JavaScriptParser(code /* TODO: Esprima, StrictModeScope.IsStrictModeCode*/);
+                var parser = new JavaScriptParser(code, new ParserOptions { AdaptRegexp = true, Tolerant = false, Strict = StrictModeScope.IsStrictModeCode });
                 var program = parser.ParseProgram();
                 using (new StrictModeScope(program.IsStrict()))
                 {

+ 2 - 2
Jint/Native/Function/FunctionConstructor.cs

@@ -85,8 +85,8 @@ namespace Jint.Native.Function
             IFunction function;
             try
             {
-                var functionExpression = "function(" + p + ") { " + body + "}";
-                var parser = new JavaScriptParser(body);
+                var functionExpression = "function f(" + p + ") { " + body + "}";
+                var parser = new JavaScriptParser(functionExpression);
                 function = parser.ParseProgram().Body.First().As<IFunction>();
             }
             catch (ParserException)

+ 2 - 2
Jint/Runtime/ExpressionIntepreter.cs

@@ -680,7 +680,7 @@ namespace Jint.Runtime
                         {
                             get = new ScriptFunctionInstance(
                                 _engine,
-                                getter.As<FunctionDeclaration>(),
+                                getter,
                                 _engine.ExecutionContext.LexicalEnvironment,
                                 StrictModeScope.IsStrictModeCode
                             );
@@ -703,7 +703,7 @@ namespace Jint.Runtime
 
                             set = new ScriptFunctionInstance(
                                 _engine,
-                                setter.As<FunctionDeclaration>(),
+                                setter,
                                 _engine.ExecutionContext.LexicalEnvironment,
                                 StrictModeScope.IsStrictModeCode
                                 );

+ 1 - 1
Jint/Runtime/StatementInterpreter.cs

@@ -353,7 +353,7 @@ namespace Jint.Runtime
         {
             var exprRef = _engine.EvaluateExpression(switchStatement.Discriminant);
             var r = ExecuteSwitchBlock(switchStatement.Cases, _engine.GetValue(exprRef));
-            if (r.Type == Completion.Break && r.Identifier == switchStatement.LabelSet.Name)
+            if (r.Type == Completion.Break && r.Identifier == switchStatement.LabelSet?.Name)
             {
                 return new Completion(Completion.Normal, r.Value, null);
             }