public static SqlExpression InsertNode(InsertStatementHeadToken head, params InsertValueToken[] values) { return(SqlExpression.NewInsert( new InsertExpression( head, ListModule.OfArray(values)))); }
public override void Setup(BenchmarkContext context) { base.Setup(context); var list = ListModule.OfArray(new[] { 123, 2342355, 456456467578, 234234, -234281 }); InitStreamWith(list); }
public static FromExpressionNode From <TTable>(params JoinClauseNode[] joins) { return (new FromExpressionNode( new FSharpList <ITableIdentifier>(new TableIdentifier <TTable>(), FSharpList <ITableIdentifier> .Empty), ListModule.OfArray(joins))); }
public static UpdateStatementHeadToken UpdHead <TTableType>(params UpdateSetToken[] setExprs) { return (new UpdateStatementHeadToken( Types.TableReferenceFromType <TTableType>(), ListModule.OfArray(setExprs))); }
public override FSharpList <T> Deserialize(ref byte[] bytes, int offset, DirtyTracker tracker, out int byteSize) { // tracker.Dirty(); FSharpList is immutable var length = BinaryUtil.ReadInt32(ref bytes, offset); if (length == -1) { byteSize = 4; return(null); } var startOffset = offset; offset += 4; int size; ZeroFormatterSerializer.ValidateNewLength(length); var result = new T[length]; for (int i = 0; i < length; i++) { result[i] = formatter.Deserialize(ref bytes, offset, tracker, out size); offset += size; } byteSize = offset - startOffset; return(ListModule.OfArray(result)); }
public void List() { var opt = ListModule.OfArray(new [] { FSharpOption <string> .Some("123"), FSharpOption <string> .None }); Helper.MakeSimpleTest(opt, Options); Helper.MakeObjectTest(opt, Options); }
public static object CreateDisembarkOrder(GameState.UnitIndex idx, HexTiling.HexCoords[] path) { PexAssume.IsNotNull(idx); PexAssume.IsNotNull(path); PexAssume.AreElementsNotNull(path); return(EmbarkOrders.DisembarkOrder.NewDisembark(idx, ListModule.OfArray(path))); }
public void EmptyGraph() { FSharpList <int> expected = ListModule.OfArray(new int[] { }); FSharpList <Tuple <int, int> > input = ListModule.OfArray(new Tuple <int, int> [0]); FSharpList <int> result = sortGraph <int>(input); Assert.AreEqual(expected, result); }
public void CanSerializeFSharpList() { var expected = ListModule.OfArray(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }); Serialize(expected); Reset(); var actual = Deserialize <object>(); Assert.AreEqual(expected, actual); }
public void TestFSharpList() { var list = ListModule.OfArray(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }); Test(list); }
public static JoinClauseNode Join <TSource1, TSource2, TTarget>(JoinType type, ValueNode joinExpr) { return(new JoinClauseNode( ListModule.OfArray(new ITableIdentifier[] { new TableIdentifier <TSource1>(), new TableIdentifier <TSource2>() }), new TableIdentifier <TTarget>(), type, joinExpr.ToOption())); }
public void TwoElementGraph() { FSharpList <int> expected = ListModule.OfArray(new[] { 2, 1 }); FSharpList <Tuple <int, int> > input = ListModule.OfArray(new[] { new Tuple <int, int>(2, 1) }); FSharpList <int> result = sortGraph <int>(input); Assert.AreEqual(expected, result); }
protected override void Init() { base.Init(); list = ListModule.OfArray(new[] { 123, 2342355, 456456467578, 234234, -234281 }); set = SetModule.OfArray(new[] { 123, 2342355, 456456467578, 234234, -234281 }); record = new TestRecord( name: "John Doe", aref: FSharpOption <string> .Some("ok"), connections: "test"); du = DU2.NewC(DU1.NewB("test", 123)); sdu = SDU1.NewB("hello", 123); }
public static void MyGPULaunch <T1, T2, T3>( this ILGPUModule module, Action <T1, T2, T3> kernelD, LaunchParam lp, T1 arg1, T2 arg2, T3 arg3) { // get the kernel object by method name var kernel = module.GPUEntities.GetKernel(kernelD.Method.Name).Kernel; // create parameter list (which is FSharpList) var parameterArray = new object[] { arg1, arg2, arg3 }; var parameterList = ListModule.OfArray(parameterArray); // use untyped LaunchRaw to launch the kernel kernel.LaunchRaw(lp, parameterList); }
public void ItCanVisitAMultipleColumnSelector() { Expression <Func <Person, object> > func = (Person p) => new { p.Age, p.Name }; var tableRef = Types.TableReferenceFromType <Person>(); var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), new[] { tableRef }.ToContext() ); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.Col <Person>("Age"), S.Col <Person>("Name") })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
public static object CreateOrder(bool isBomb, bool isBombard, bool isConquer, bool isDirectAttack, bool isDockAt, bool isLandAt, HexTiling.HexCoords coords, HexTiling.HexCoords[] path) { PexAssume.IsNotNull(coords); PexAssume.IsNotNull(path); PexAssume.AreElementsNotNull(path); return (isBomb ? Orders.Order.NewBomb(coords, ListModule.OfArray(path)) : isBombard?Orders.Order.NewBombard(coords) : isConquer?Orders.Order.NewConquer(ListModule.OfArray(path)) : isDirectAttack?Orders.Order.NewDirectAttack(coords, ListModule.OfArray(path)) : isDockAt?Orders.Order.NewDockAt(ListModule.OfArray(path)) : isLandAt?Orders.Order.NewLandAt(ListModule.OfArray(path)) : Orders.Order.NewUnload(ListModule.OfArray(path), coords)); }
public void ListGraph() { // 7 --> 6 --> 5 --> 4 --> 3 --> 2 --> 1 FSharpList <int> expected = ListModule.OfArray(new[] { 7, 6, 5, 4, 3, 2, 1 }); FSharpList <Tuple <int, int> > input = ListModule.OfArray(new[] { new Tuple <int, int>(2, 1), new Tuple <int, int>(3, 2), new Tuple <int, int>(4, 3), new Tuple <int, int>(5, 4), new Tuple <int, int>(6, 5), new Tuple <int, int>(7, 6) }); FSharpList <int> result = sortGraph <int>(input); Assert.AreEqual(expected, result); }
public void ItShouldBeAbleToGenerateAliasesForBinaryExpressions() { Expression <Func <Person, object> > func = (Person p) => new { AgePlusTen = p.Age + 10 }; var tableRefs = new[] { Types.TableReferenceFromType <Person>(), }; var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), tableRefs.ToContext()); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.AliasedCol(S.BinExp(S.Col <Person>("Age"), BinaryOperation.Add, S.Const(10)), "AgePlusTen"), })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
public void ItShouldBeAbleToGenerateAliasesForConstants() { Expression <Func <Person, object> > func = (Person p) => new { FavoriteNumber = 42 }; var tableRefs = new[] { Types.TableReferenceFromType <Person>(), }; var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), tableRefs.ToContext()); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.AliasedCol(S.Const(42), "FavoriteNumber"), })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
public void ItShouldNotGenerateAliasColumnsForColumnsBeingAliasedToItsOrdinaryName() { Expression <Func <Person, object> > func = (Person p) => new { Name = p.Name, Age = p.Age }; var tableRefs = new[] { Types.TableReferenceFromType <Person>(), }; var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), tableRefs.ToContext()); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.Col <Person>("Name"), S.Col <Person>("Age"), })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
//[Test, TestCaseSource("split_token_tests")] public void TestSplitContent(StringTest test) { Func <string[], FSStringList> of_array = (array) => ListModule.OfArray <string>(array); Func <FSStringList, string[]> to_string_array = (string_list) => { var tl = string_list; var res = new StringList(); while (ListModule.Length <string>(tl) > 0) { res.Add(ListModule.Head <string>(tl)); tl = ListModule.Tail <string>(tl); } return(res.ToArray()); }; //Assert.AreEqual(to_string_array(of_array(test.expected)), to_string_array(OutputHandling.split_token_contents(test.provided))); }
public void SortGraph() { FSharpList <int> expected = ListModule.OfArray(new[] { 8, 7, 6, 5, 4, 3, 2, 1 }); FSharpList <Tuple <int, int> > input = ListModule.OfArray(new[] { new Tuple <int, int>(4, 1), new Tuple <int, int>(4, 2), new Tuple <int, int>(4, 3), new Tuple <int, int>(5, 2), new Tuple <int, int>(6, 4), new Tuple <int, int>(6, 5), new Tuple <int, int>(7, 4), new Tuple <int, int>(8, 3), new Tuple <int, int>(8, 5) }); FSharpList <int> result = sortGraph <int>(input); Assert.AreEqual(expected, result); }
public void Order4() { // 4 // \ // 3 --- 1 // \ / // 2 FSharpList <int> expected = ListModule.OfArray(new[] { 4, 3, 2, 1 }); FSharpList <Tuple <int, int> > input = ListModule.OfArray(new[] { new Tuple <int, int>(2, 1), new Tuple <int, int>(4, 3), new Tuple <int, int>(3, 2), new Tuple <int, int>(3, 1) }); FSharpList <int> result = sortGraph <int>(input); Assert.AreEqual(expected, result); }
public void ItShouldBeAbleToGenerateAliasedColumnTokens() { Expression <Func <Person, object> > func = (Person p) => new { p.Name, AgeOfPerson = p.Age, Count = Sql.Count() }; var tableRefs = new[] { Types.TableReferenceFromType <Person>(), }; var ev = ExpressionVisitor.Visit( ExpressionVisitor.VisitableExpression.NewLinqExpression(func), tableRefs.ToContext()); var expected = ValueNode.NewValueList( ListModule.OfArray(new[] { S.Col <Person>("Name"), S.AliasedCol <Person>("Age", "AgeOfPerson"), S.AliasedCol <Person>(AST.AggregateType.Count, S.Null(), "Count") })).ToOption(); Assert.That(ev, Is.EqualTo(expected)); }
/// <summary> /// <see cref=""/> /// </summary> /// <param name="test"></param> //[Test, TestCaseSource("smart_split_tests")] public void TestSmartSplit(StringTest test) { Regex r = new Regex(@"(""(?:[^""\\]*(?:\\.[^""\\]*)*)""|'(?:[^'\\]*(?:\\.[^'\\]*)*)'|[^\s]+)", RegexOptions.Compiled); MatchCollection m = r.Matches(@"'\'funky\' style'"); Func <string[], FSStringList> of_array = (array) => ListModule.OfArray <string>(array); Func <FSStringList, string[]> to_string_array = (string_list) => { var tl = string_list; var res = new StringList(); while (ListModule.Length <string>(tl) > 0) { res.Add(ListModule.Head <string>(tl)); tl = ListModule.Tail <string>(tl); } return(res.ToArray()); }; // Assert.AreEqual(to_string_array(of_array(test.expected)), to_string_array(OutputHandling.smart_split(test.provided))); }
public void TreeGraph_Integer() { // / 3 // 6 // / \ 4 // 7 // \ / 1 // 5 // \ 2 FSharpList <int> expected = ListModule.OfArray(new[] { 7, 6, 4, 3, 5, 2, 1 }); FSharpList <Tuple <int, int> > input = ListModule.OfArray(new[] { new Tuple <int, int>(5, 1), new Tuple <int, int>(5, 2), new Tuple <int, int>(6, 3), new Tuple <int, int>(6, 4), new Tuple <int, int>(7, 5), new Tuple <int, int>(7, 6) }); FSharpList <int> result = sortGraph <int>(input); Assert.AreEqual(expected, result); }
public void StandartGraph_Integer() { // 6 3 // / \ / \ // 7 4 1 // \ / \ / // 5 2 FSharpList <int> expected = ListModule.OfArray(new[] { 7, 6, 5, 4, 3, 2, 1 }); FSharpList <Tuple <int, int> > input = ListModule.OfArray(new[] { new Tuple <int, int>(2, 1), new Tuple <int, int>(3, 1), new Tuple <int, int>(4, 2), new Tuple <int, int>(4, 3), new Tuple <int, int>(5, 4), new Tuple <int, int>(6, 4), new Tuple <int, int>(7, 5), new Tuple <int, int>(7, 6) }); FSharpList <int> result = sortGraph <int>(input); Assert.AreEqual(expected, result); }
public void TreeGraph_String() { // / 3 // 6 // / \ 4 // 7 // \ / 1 // 5 // \ 2 FSharpList <string> expected = ListModule.OfArray(new[] { "seven", "six", "four", "three", "five", "two", "one" }); FSharpList <Tuple <string, string> > input = ListModule.OfArray(new[] { new Tuple <string, string>("five", "one"), new Tuple <string, string>("five", "two"), new Tuple <string, string>("six", "three"), new Tuple <string, string>("six", "four"), new Tuple <string, string>("seven", "five"), new Tuple <string, string>("seven", "six") }); FSharpList <string> result = sortGraph <string>(input); Assert.AreEqual(expected, result); }
public static FSharpList <Tuple <string, string> > Traits(params Tuple <string, string>[] traits) { return(ListModule.OfArray(traits)); }
public Microsoft.FSharp.Quotations.FSharpExpr GetInvokerExpression(MethodBase syntheticMethodBase, Microsoft.FSharp.Quotations.FSharpExpr[] parameters) { Helpers.TraceCall(); if (syntheticMethodBase is System.Reflection.ConstructorInfo) { var ac = syntheticMethodBase as ArtificialConstructorInfo; if (ac.DeclaringType.FullName == "N.T") { return(FSharpExpr.DefaultValue(ac.DeclaringType.BaseType)); } Debug.Assert(false, "NYI"); throw new NotImplementedException(); } else if (syntheticMethodBase is System.Reflection.MethodInfo) { var am = syntheticMethodBase as ArtificialMethodInfo; if (am.DeclaringType.FullName == "N.T" && am.Name == "M") { var plist = ListModule.OfArray(new[] { FSharpExpr.Value(1), FSharpExpr.Value(2), FSharpExpr.Value(3) }); return(FSharpExpr.NewArray(typeof(int), plist)); } else if (am.DeclaringType.FullName == "N.T" && am.Name == "get_StaticProp1") { return(FSharpExpr.Lambda(FSharpVar.Global("", typeof(decimal)), FSharpExpr.Value <decimal>(4.2M))); } else if (am.DeclaringType.FullName == "N.T" && am.Name == "get_StaticProp2") { return(FSharpExpr.Lambda(FSharpVar.Global("", typeof(System.Tuple <int, int, int, int, int, int, int, System.Tuple <int, int, int> >)), FSharpExpr.Value <System.Tuple <int, int, int, int, int, int, int, System.Tuple <int, int, int> > >(new System.Tuple <int, int, int, int, int, int, int, System.Tuple <int, int, int> >(1, 2, 3, 4, 5, 6, 7, new Tuple <int, int, int>(8, 9, 10))))); } else if (am.DeclaringType.FullName == "N.T" && am.Name == "get_StaticProp3") { return(FSharpExpr.Lambda(FSharpVar.Global("", typeof(System.Tuple <int, int, int>)), FSharpExpr.Value <System.Tuple <int, int, int> >(new Tuple <int, int, int>(1, 2, 3)))); } else if (am.DeclaringType.FullName == "N.T" && am.Name == "RaiseEvent1") { Debug.Assert(false, "NYI"); throw new NotImplementedException(); } else if (am.DeclaringType.FullName == "N.T" && am.Name == "M1") { var plist = ListModule.OfArray(new[] { FSharpExpr.Value(1), FSharpExpr.Value(2), FSharpExpr.Value(3) }); return(FSharpExpr.NewArray(typeof(int), plist)); } else if (am.DeclaringType.FullName == "N.I1" && am.Name == "M") { var plist = ListModule.OfArray(new[] { FSharpExpr.Value(1), FSharpExpr.Value(2), FSharpExpr.Value(3) }); return(FSharpExpr.NewArray(typeof(int), plist)); } else { Debug.Assert(false, "NYI"); throw new NotImplementedException(); } } else { Debug.Assert(false, "GetInvokerExpression() invoked with neither ConstructorInfo nor MethodInfo!"); return(null); } //Expression<Func<S>> e = () => new S(9); //return e.Body; //throw new NotImplementedException(); }