public void VarPattern_Update()
        {
            var t = Expression.Variable(typeof(int));
            var p = CSharpPattern.Var(CSharpPattern.ObjectPatternInfo(CSharpPattern.PatternInfo(typeof(int), typeof(int)), variable: t));

            Assert.AreSame(p, p.Update(t));

            var u = Expression.Variable(typeof(int));
            var q = p.Update(u);

            Assert.AreNotSame(p, q);
            Assert.AreSame(u, q.Variable);
        }
        public void VarPattern_ArgumentChecking()
        {
            // null
            AssertEx.Throws <ArgumentNullException>(() => CSharpPattern.Var(info: null));
            AssertEx.Throws <ArgumentNullException>(() => CSharpPattern.Var(variable: null));

            // by-ref type
            AssertEx.Throws <ArgumentException>(() => CSharpPattern.Var(variable: Expression.Variable(typeof(int).MakeByRefType())));
            AssertEx.Throws <ArgumentException>(() => CSharpPattern.Var(info: null, variable: Expression.Variable(typeof(int).MakeByRefType())));

            // invalid typing
            AssertEx.Throws <ArgumentException>(() => CSharpPattern.Var(CSharpPattern.ObjectPatternInfo(CSharpPattern.PatternInfo(typeof(object), typeof(int)), variable: null)));
            AssertEx.Throws <ArgumentException>(() => CSharpPattern.Var(CSharpPattern.ObjectPatternInfo(CSharpPattern.PatternInfo(typeof(int), typeof(int)), Expression.Variable(typeof(long)))));
        }