Exemplo n.º 1
0
        public void CheckDisjunctionDoesNothing()
        {
            var yes = new BooleanLiteral (true);
            var no = new BooleanLiteral (false);
            var disjunction = new LogicalDisjunction (yes, no);

            var result = disjunction.Walk (new RefChecker (), new [] { "Foobar" });

            Assert.AreEqual (1, result.Length);
            Assert.Contains ("Foobar", result);
        }
Exemplo n.º 2
0
        public void SerializeLogicalDisjunction()
        {
            var disjunction = new LogicalDisjunction(
                new BooleanLiteral(true),
                new BooleanLiteral(false)
            );

            var sql = disjunction.Walk (new Sqlizer (foobarTable()));

            Assert.AreEqual ("(TRUE OR FALSE)", sql);
        }
Exemplo n.º 3
0
        public void DisjunctionErrorsOnNumbers()
        {
            var numberVal = new NumberLiteral (42);
            var boolVal = new BooleanLiteral (true);
            var left = new LogicalDisjunction (numberVal, boolVal);
            var right = new LogicalDisjunction (boolVal, numberVal);

            var leftEx = Assert.Throws<TypeCheckException>(() => left.Walk (new TypeChecker ()));
            var rightEx = Assert.Throws<TypeCheckException>(() => right.Walk (new TypeChecker ()));

            Assert.That (INCOMPATIBLE_RE.IsMatch (leftEx.Message));
            Assert.That (INCOMPATIBLE_RE.IsMatch (rightEx.Message));
        }
Exemplo n.º 4
0
        public void DisjunctionErrorsOnStrings()
        {
            var stringVal = new StringLiteral ("foobar");
            var boolVal = new BooleanLiteral (true);
            var left = new LogicalDisjunction (stringVal, boolVal);
            var right = new LogicalDisjunction (boolVal, stringVal);

            var leftEx = Assert.Throws<TypeCheckException>(() => left.Walk (new TypeChecker ()));
            var rightEx = Assert.Throws<TypeCheckException>(() => right.Walk (new TypeChecker ()));

            Assert.That (INCOMPATIBLE_RE.IsMatch (leftEx.Message));
            Assert.That (INCOMPATIBLE_RE.IsMatch (rightEx.Message));
        }
Exemplo n.º 5
0
        public void CheckLogicalDisjunction()
        {
            var lhs = new BinaryOperation ("=", new NumberLiteral (1), new NumberLiteral (2));
            var rhs = new BinaryOperation ("<", new NumberLiteral (3), new NumberLiteral (4));
            var disjunction = new LogicalDisjunction (lhs, rhs);

            var type = disjunction.Walk (new TypeChecker ());

            Assert.AreEqual (SpecType.Boolean, type.Type);
        }