/* $Id: VisitorTest.java,v 1.2 2007/02/25 20:04:30 m31 Exp $
 *
 * This file is part of the project "Hilbert II" - http://www.qedeq.org
 *
 * Copyright 2000-2007,  Michael Meyling <mime@qedeq.org>.
 *
 * "Hilbert II" is free software; you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 */

package org.qedeq.kernel.dto.list;

import org.qedeq.kernel.base.common.QedeqException;
import org.qedeq.kernel.base.list.Atom;
import org.qedeq.kernel.base.list.Element;
import org.qedeq.kernel.base.list.ElementList;
import org.qedeq.kernel.bo.visitor.ListVisitor;
import org.qedeq.kernel.bo.visitor.QedeqNotNullTransverser;
import org.qedeq.kernel.dto.list.AtomImpl;
import org.qedeq.kernel.dto.list.ElementListImpl;
import org.qedeq.kernel.test.QedeqTestCase;

/**
 * Test visitor implementations. TODO mime 20070110: adapt. 
 * 
 * @version $Revision: 1.2 $
 * @author Michael Meyling
 */
public class VisitorTest extends QedeqTestCase implements ListVisitor {

    /**
     * Constructor.
     */
    public VisitorTest() {
        super();
    }

    /**
     * Constructor.
     * 
     * @param   name    Test case name.
     */
    public VisitorTest(String name) {
        super(name);
    }

    /**
     * Test implementation of visitor.
     */
    public void testVisit() throws QedeqException {
        Element el = new ElementListImpl("myOperator", new Element[] {
            new AtomImpl("Hello"), 
            new AtomImpl("Again"),
            new ElementListImpl("again", new Element[] {
                new AtomImpl("one"), 
                new AtomImpl("two"),
                new AtomImpl("three")
            })
        });
        // FIXME todo
    }
    
    /**
     * Test generation.
     */
    public void testGeneration() throws Exception {
        Element el = new ElementListImpl("EQUI", new Element[] {
            new ElementListImpl("PREDCON", new Element[] {
                new AtomImpl("equal"), 
                new ElementListImpl("VAR", new Element[] {
                    new AtomImpl("y"), 
                }),
                new ElementListImpl("CLASS", new Element[] {
                    new ElementListImpl("VAR", new Element[] {
                        new AtomImpl("x"), 
                    }),
                    new ElementListImpl("PREDVAR", new Element[] {
                        new AtomImpl("\\phi"), 
                        new ElementListImpl("VAR", new Element[] {
                            new AtomImpl("x"), 
                        })
                    })
                })
            }),
            new ElementListImpl("FORALL", new Element[] {
                new ElementListImpl("VAR", new Element[] {
                    new AtomImpl("z"), 
                }),
                new ElementListImpl("EQUI", new Element[] {
                    new ElementListImpl("PREDCON", new Element[] {
                        new AtomImpl("in"), 
                        new ElementListImpl("VAR", new Element[] {
                            new AtomImpl("z"), 
                        }),
                        new ElementListImpl("VAR", new Element[] {
                            new AtomImpl("y"), 
                        })
                    }),
                    new ElementListImpl("PREDCON", new Element[] {
                        new AtomImpl("in"), 
                        new ElementListImpl("VAR", new Element[] {
                            new AtomImpl("z"), 
                        }),
                        new ElementListImpl("CLASS", new Element[] {
                            new ElementListImpl("VAR", new Element[] {
                                new AtomImpl("x"), 
                            }),
                            new ElementListImpl("PREDVAR", new Element[] {
                                new AtomImpl("\\phi"), 
                                new ElementListImpl("VAR", new Element[] {
                                    new AtomImpl("x"), 
                                })
                            })
                        })
                    })
                })
            })
        });
        System.out.println(el.toString());
    }
    
    protected void setUp() throws Exception {
        super.setUp();
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void visitEnter(Atom atom) {
        System.out.println("Visiting atom enter:" + atom.toString());
        
    }

    public void visitEnter(ElementList list) {
        System.out.println("Visiting list enter:" + list.getOperator());
    }

    public void visitLeave(Atom atom) {
        System.out.println("Visiting atom leave:" + atom.toString());
        
    }

    public void visitLeave(ElementList list) {
        System.out.println("Visiting list leave:" + list.getOperator());
    }
}
