示例#1
0
        private static void VerifyNullableStructIsIEquatableOfStruct(S?value)
        {
            Expression <Func <bool> > e =
                Expression.Lambda <Func <bool> >(
                    Expression.TypeIs(Expression.Constant(value, typeof(S?)), typeof(IEquatable <S>)),
                    Enumerable.Empty <ParameterExpression>());
            Func <bool> f = e.Compile();

            // compute the value with the expression tree
            bool      etResult    = default(bool);
            Exception etException = null;

            try
            {
                etResult = f();
            }
            catch (Exception ex)
            {
                etException = ex;
            }

            // compute the value with regular IL
            bool      csResult    = default(bool);
            Exception csException = null;

            try
            {
                csResult = value is IEquatable <S>;
            }
            catch (Exception ex)
            {
                csException = ex;
            }

            // either both should have failed the same way or they should both produce the same result
            if (etException != null || csException != null)
            {
                Assert.NotNull(etException);
                Assert.NotNull(csException);
                Assert.Equal(csException.GetType(), etException.GetType());
            }
            else
            {
                Assert.Equal(csResult, etResult);
            }
        }
示例#2
0
        private TransitionRegex(SymbolicRegexBuilder <S> builder, TransitionRegexKind kind, S?test, TransitionRegex <S>?first, TransitionRegex <S>?second, SymbolicRegexNode <S>?node, DerivativeEffect?effect)
        {
            Debug.Assert(builder is not null);
            Debug.Assert(
                kind is TransitionRegexKind.Leaf && node is not null && Equals(test, default(S)) && first is null && second is null && effect is null ||
                kind is TransitionRegexKind.Conditional && test is not null && first is not null && second is not null && node is null && effect is null ||
                kind is TransitionRegexKind.Union && Equals(test, default(S)) && first is not null && second is not null && node is null && effect is null ||
                kind is TransitionRegexKind.Lookaround && Equals(test, default(S)) && first is not null && second is not null && node is not null && effect is null ||
                kind is TransitionRegexKind.Effect && Equals(test, default(S)) && first is not null && second is null && node is null && effect is not null);

            _builder = builder;
            _kind    = kind;
            _test    = test;
            _first   = first;
            _second  = second;
            _node    = node;
            _effect  = effect;
        }
示例#3
0
 internal void Add(S?state, A?action, DFlowAction method)
 {
     if (state == null)
     {
         AddAll(action, method);
         return;
     }
     if (!actions.ContainsKey(state))
     {
         actions.Add(state, new NullableDict <A?, List <ActionHolder> >());
     }
     if (!actions[state].ContainsKey(action))
     {
         actions[state].Add(action, new List <ActionHolder>());
     }
     actions[state][action].Add(new ActionHolder(__id++, method));
     actions[state][action].Sort((a, b) => b.Id - a.Id);
 }
示例#4
0
    public static int Main()
    {
        S   a   = new S();
        S?  b   = null;
        var res = a | b;

        if (res != "op")
        {
            return(1);
        }

        var res2 = a + b;

        if (res2 != 9)
        {
            return(2);
        }

        return(0);
    }
示例#5
0
    public static int Main()
    {
        S?s  = null;
        S?s2 = new S();

        long?i = s;

        if (i != null)
        {
            return(1);
        }

        double?ui = s2;

        if (ui == null)
        {
            return(2);
        }

        return(0);
    }
示例#6
0
    static int TestNullable()
    {
        int?i = 4;
        var m = i?.CompareTo(3);

        if (m.GetType() != typeof(int))
        {
            return(1);
        }

        if (m != 1)
        {
            return(2);
        }

        DateTime?dt = null;

        dt?.ToString();
        if (dt?.ToString() != null)
        {
            return(3);
        }

        byte?b = 0;

        if (b?.ToString() != "0")
        {
            return(4);
        }

        S?  s  = null;
        var p1 = s?.Prop;

        if (p1 != null)
        {
            return(5);
        }

        return(0);
    }
示例#7
0
    public static int Main()
    {
        S?nullable = null;

        using (var a = nullable)
        {
        }

        if (S.hit != 0)
        {
            return(1);
        }

        using (var s = new S())
        {
        }

        if (S.hit != 1)
        {
            return(2);
        }

        C c = null;

        GenMethod(c);

        using (S? a = nullable, b = nullable)
        {
        }

        if (S.hit != 1)
        {
            return(3);
        }

        Console.WriteLine("ok");
        return(0);
    }
示例#8
0
    public static int Main()
    {
        S?s = null;
        C c = (C)s;

        if (c.ID != 5)
        {
            return(1);
        }

        s = new S()
        {
            ID = 10
        };
        c = (C)s;

        if (c.ID != 10)
        {
            return(2);
        }

        return(0);
    }
示例#9
0
        public static void CheckNullableStructArrayListTest()
        {
            S?[][] array = new S?[][]
            {
                new S?[] {  },
                new S?[] { default(S) },
                new S?[] { default(S), new S() }
            };
            Expression[][] exprs = new Expression[array.Length][];
            for (int i = 0; i < array.Length; i++)
            {
                exprs[i] = new Expression[array[i].Length];
                for (int j = 0; j < array[i].Length; j++)
                {
                    S?val = array[i][j];
                    exprs[i][j] = Expression.Constant(val, typeof(S?));
                }
            }

            for (int i = 0; i < array.Length; i++)
            {
                VerifyNullableStructArrayList(array[i], exprs[i]);
            }
        }
示例#10
0
 static void Test(S?s)
 {
     Foo(s);
 }
示例#11
0
        public static IQueryable <T> CheckBetween <T, S>(this IQueryable <T> baseQuery, S valMin, S?valMax, Expression <Func <T, S?> > field, bool includeMin = true, bool includeMax = true)
            where S : struct
        {
            S?a = valMin;
            S?b = valMax;

            return(CheckBetween(baseQuery, a, b, field, includeMin, includeMax));
        }
示例#12
0
 public static void Main()
 {
     S      a   = new S();
     S?     b   = null;
     string res = a > b;
 }
示例#13
0
 public static IQueryable <T> CheckEqual <T, S>(this IQueryable <T> baseQuery, S?val, Expression <Func <T, S?> > field)
     where S : struct
 {
     if (val == null)
     {
         return(baseQuery);
     }
     else
     {
         var equal = Expression.Equal(Expression.PropertyOrField(field.Body, "Value"), Expression.Constant(val));
         var where = Expression.Lambda <Func <T, bool> >(equal, field.Parameters[0]);
         return(baseQuery.Where(where));
     }
 }
示例#14
0
 public static IQueryable <T> CheckBetween <T, S>(this IQueryable <T> baseQuery, S?valMin, S?valMax, Expression <Func <T, S?> > field, bool includeMin = true, bool includeMax = true)
     where S : struct
 {
     if (valMin == null && valMax == null)
     {
         return(baseQuery);
     }
     else
     {
         BinaryExpression exp1 = null;
         BinaryExpression exp2 = null;
         BinaryExpression exp  = null;
         if (valMin != null)
         {
             exp1 = !includeMin?Expression.GreaterThan(Expression.PropertyOrField(field.Body, "Value"), Expression.Constant(valMin)) : Expression.GreaterThanOrEqual(Expression.PropertyOrField(field.Body, "Value"), Expression.Constant(valMin));
         }
         if (valMax != null)
         {
             exp2 = !includeMax?Expression.LessThan(Expression.PropertyOrField(field.Body, "Value"), Expression.Constant(valMax)) : Expression.LessThanOrEqual(Expression.PropertyOrField(field.Body, "Value"), Expression.Constant(valMax));
         }
         if (exp1 != null && exp2 != null)
         {
             exp = Expression.And(exp1, exp2);
         }
         else
         {
             exp = exp1 ?? exp2;
         }
         var where = Expression.Lambda <Func <T, bool> >(exp, field.Parameters[0]);
         return(baseQuery.Where(where));
     }
 }
示例#15
0
	public static void Test (S? s)
	{
		C<S?>.Foo (s);
		C<ValueType>.Foo (s);
		C<object>.Foo (s);
	}
示例#16
0
 static void Bar(S?s)
 {
     C <I> .Foo(s);
 }
示例#17
0
文件: Machines.cs 项目: sy1989/nora
 public MachineTransitionBinding <E, S> Transit(S state)
 {
     this.state = state;
     return(this);
 }
示例#18
0
 static void TestStruct2(S?s = new S?())
 {
 }
示例#19
0
 public Transition()
 {
     Call = null;
     Next = null;
 }
示例#20
0
文件: Machines.cs 项目: sy1989/nora
 public MachineTransitionBinding(E e)
 {
     this.e     = e;
     this.call  = null;
     this.state = null;
 }
示例#21
0
    public static int Main()
    {
        S?s  = new S();
        S?s2 = null;
        S?s4 = null;

        if ((s == s2) != false)
        {
            return(1);
        }

        if ((s2 == s) != false)
        {
            return(2);
        }

        if ((s2 == s4) != true)
        {
            return(3);
        }

        S x = new S();

        if ((s2 == x) != false)
        {
            return(5);
        }

        if ((x == s2) != false)
        {
            return(6);
        }

        S2?s2_1 = new S2();
        S2?s2_3 = new S2();
        S2 x2   = new S2();

        if ((s2_1 == s2_3) != true)
        {
            return(7);
        }

        if ((s2_1 == x2) != true)
        {
            return(8);
        }

        if ((x2 == s2_1) != true)
        {
            return(9);
        }

        if (S2.counter != 3)
        {
            return(10);
        }

        S3 s3;

        if ((s3 == null) != true)
        {
            return(20);
        }

        if ((null == s3) != true)
        {
            return(21);
        }

        if (S3.counter != 2)
        {
            return(22);
        }

        return(0);
    }
示例#22
0
文件: gtest-452.cs 项目: mdae/MonoRT
 static void TestStruct(S?s = new S())
 {
 }
示例#23
0
 private static TransitionRegex <S> GetOrCreate(SymbolicRegexBuilder <S> builder, TransitionRegexKind kind, S?test, TransitionRegex <S>?one, TransitionRegex <S>?two, SymbolicRegexNode <S>?node, DerivativeEffect?effect = null)
 {
     // Keep transition regexes internalized using the builder
     ref TransitionRegex <S>?tr = ref CollectionsMarshal.GetValueRefOrAddDefault(builder._trCache, (kind, test, one, two, node, effect), out _);
示例#24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ListDiff.ListDiffAction`2"/> class.
 /// </summary>
 /// <param name="type">The <see cref="ActionType"/></param>
 /// <param name="source">The <see cref="SourceItem"/></param>
 /// <param name="dest">The <see cref="DestinationItem"/></param>
 public ListDiffAction(ListDiffActionType type, S?source, D?dest)
 {
     ActionType      = type;
     SourceItem      = source;
     DestinationItem = dest;
 }
示例#25
0
 static void Test(S?s)
 {
     C <S> .Foo(s);
 }