public void TestClosure() { CallSignature callSignature = GetCallSignature(); Closure node = new Closure( GetTypeOrNamespaceModuleLiteral(), new FunctionLikeExpression( GetSymbolAtom(), callSignature, GetStatement1(), 5, callSignature.Parameters.Count, null, DefaultLineInfo, GetFunctionStatistic()), EvaluationStackFrame.UnsafeFrom(new object[] { 1, "hello" }.Select(v => EvaluationResult.Create(v)).ToArray())); Assert.Throws <NotImplementedException>(() => CheckSerializationRoundTrip(node)); }
private static EvaluationResult StaticMerge(Context context, ModuleLiteral env, EvaluationStackFrame args) { ObjectLiteral result = null; var arrayOfObjects = Args.AsArrayLiteral(args, 0); for (int i = 0; i < arrayOfObjects.Length; i++) { if (arrayOfObjects[i].IsUndefined) { continue; } var arg = Converter.ExpectObjectLiteral( arrayOfObjects[i], new ConversionContext(pos: i, objectCtx: arrayOfObjects)); if (result == null) { result = arg; } else { var merged = result.Merge(context, EvaluationStackFrame.UnsafeFrom(new EvaluationResult[0]), EvaluationResult.Create(arg)); // Merge can fail due to custom merge functions failing. if (merged.IsErrorValue) { return(merged); } // Left and right are guaranteed to be objects so the result must be object. result = (ObjectLiteral)merged.Value; } } if (result == null) { return(EvaluationResult.Undefined); } return(EvaluationResult.Create(result)); }