Example #1
0
        // VisitFailure
        public virtual void testSomeIdentity()
        {
            Identity id = new Identity();
            Some     some = new Some(logVisitor(id));
            Logger expected = new Logger(id, new IVisitable[]{n1,n2});

            IVisitable nodeReturned = some.visit(n0);
            Assertion.AssertEquals(expected, logger);
            Assertion.AssertEquals(n0, nodeReturned);
        }
Example #2
0
        // throws VisitFailure
        public virtual void testSomeOneFailure()
        {
            IVisitor v = new FailAtNodes(n1);
            Some     some = new Some(logVisitor(v));
            Logger expected = new Logger(v, new IVisitable[]{n1,n2});

            IVisitable nodeReturned = null;

            nodeReturned = some.visit(n0);
            Assertion.AssertEquals(expected, logger);
            Assertion.AssertEquals(n0, nodeReturned);
        }
Example #3
0
        public virtual void testSomeAllFailures()
        {
            Fail f = new Fail();
            Some     some = new Some(logVisitor(f));
            Logger expected = new Logger(f, new IVisitable[]{n1,n2});

            IVisitable nodeReturned = null;

            try {
                nodeReturned = some.visit(n0);
            }
            catch (VisitFailure)
            {
                Assertion.AssertEquals(expected, logger);
                Assertion.AssertNull(nodeReturned);
            }
        }
Example #4
0
        public virtual void testSomeLeaf()
        {
            Identity id = new Identity();
            Some     some = new Some(logVisitor(id));
            Logger expected = new Logger();
            IVisitable nodeReturned = null;

            try
            {
                nodeReturned = some.visit(n11);
                Assertion.Fail("Some(leaf) should fail!");
            }
            catch (VisitFailure)
            {
                Assertion.AssertEquals(expected, logger);
                Assertion.AssertNull(nodeReturned);
            }
        }