<commit_before>/*
 * Copyright The Sett Ltd, 2005 to 2014.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.thesett.aima.logic.fol.wam.debugger;

import java.io.IOException;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.apache.log4j.NDC;

import com.thesett.aima.logic.fol.Clause;
import com.thesett.aima.logic.fol.DisjunctionResolverUnitTestBase;
import com.thesett.aima.logic.fol.LogicCompiler;
import com.thesett.aima.logic.fol.Parser;
import com.thesett.aima.logic.fol.interpreter.ResolutionEngine;
import com.thesett.aima.logic.fol.isoprologparser.ClauseParser;
import com.thesett.aima.logic.fol.isoprologparser.Token;
import com.thesett.aima.logic.fol.wam.compiler.WAMCompiledPredicate;
import com.thesett.aima.logic.fol.wam.compiler.WAMCompiledQuery;
import com.thesett.aima.logic.fol.wam.compiler.WAMCompiler;
import com.thesett.aima.logic.fol.wam.debugger.controller.TopLevelStandaloneController;
import com.thesett.aima.logic.fol.wam.debugger.monitor.MachineMonitor;
import com.thesett.aima.logic.fol.wam.debugger.uifactory.ComponentFactoryBuilder;
import com.thesett.aima.logic.fol.wam.machine.WAMEngine;
import com.thesett.aima.logic.fol.wam.machine.WAMResolvingJavaMachine;
import com.thesett.aima.logic.fol.wam.machine.WAMResolvingMachine;
import com.thesett.common.util.doublemaps.SymbolTableImpl;

public class DebuggerTest extends TestCase
{
    /** Holds the WAM machine to run the tests through. */
    private static WAMResolvingMachine machine;

    /**
     * Creates a test with the specified name.
     *
     * @param name The name of the test.
     */
    public DebuggerTest(String name)
    {
        super(name);
    }

    /**
     * Compile all the tests for the default tests for unifiers into a suite, plus the tests defined in this class.
     *
     * @return A test suite.
     */
    public static Test suite()
    {
        // Create a machine to debug.
        SymbolTableImpl<Integer, String, Object> symbolTable = new SymbolTableImpl<Integer, String, Object>();
        machine = new WAMResolvingJavaMachine(symbolTable);

        LogicCompiler<Clause, WAMCompiledPredicate, WAMCompiledQuery> compiler = new WAMCompiler(symbolTable, machine);
        Parser<Clause, Token> parser = new ClauseParser(machine);

        ResolutionEngine<Clause, WAMCompiledPredicate, WAMCompiledQuery> engine =
            new WAMEngine(parser, machine, compiler, machine);

        // Attach the debugger to the machine.
        final TopLevelStandaloneController controller =
            new TopLevelStandaloneController(ComponentFactoryBuilder.createComponentFactory(
                    ComponentFactoryBuilder.SWING_FACTORY));
        controller.open();

        MachineMonitor monitor = controller.getMachineMonitor();

        machine.attachMonitor(monitor);

        // Register a shutdown hook to keep the window open at the end of the tests.
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
                {
                    public void run()
                    {
                        try
                        {
                            System.in.read();
                        }
                        catch (IOException e)
                        {
                            throw new RuntimeException(e);
                        }
                    }
                }));

        // Build a new test suite.
        TestSuite suite = new TestSuite("WAMResolvingJavaMachine Tests");

        suite.addTest(new DisjunctionResolverUnitTestBase<Clause, WAMCompiledPredicate, WAMCompiledQuery>(
                "testJunctionBracketingFalse", engine));

        return suite;
    }<commit_msg>Switching over to run the cut tests.<commit_after>/*
 * Copyright The Sett Ltd, 2005 to 2014.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.thesett.aima.logic.fol.wam.debugger;

import java.io.IOException;

import com.thesett.aima.logic.fol.CutResolverUnitTestBase;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.apache.log4j.NDC;

import com.thesett.aima.logic.fol.Clause;
import com.thesett.aima.logic.fol.LogicCompiler;
import com.thesett.aima.logic.fol.Parser;
import com.thesett.aima.logic.fol.interpreter.ResolutionEngine;
import com.thesett.aima.logic.fol.isoprologparser.ClauseParser;
import com.thesett.aima.logic.fol.isoprologparser.Token;
import com.thesett.aima.logic.fol.wam.compiler.WAMCompiledPredicate;
import com.thesett.aima.logic.fol.wam.compiler.WAMCompiledQuery;
import com.thesett.aima.logic.fol.wam.compiler.WAMCompiler;
import com.thesett.aima.logic.fol.wam.debugger.controller.TopLevelStandaloneController;
import com.thesett.aima.logic.fol.wam.debugger.monitor.MachineMonitor;
import com.thesett.aima.logic.fol.wam.debugger.uifactory.ComponentFactoryBuilder;
import com.thesett.aima.logic.fol.wam.machine.WAMEngine;
import com.thesett.aima.logic.fol.wam.machine.WAMResolvingJavaMachine;
import com.thesett.aima.logic.fol.wam.machine.WAMResolvingMachine;
import com.thesett.common.util.doublemaps.SymbolTableImpl;

public class DebuggerTest extends TestCase
{
    /** Holds the WAM machine to run the tests through. */
    private static WAMResolvingMachine machine;

    /**
     * Creates a test with the specified name.
     *
     * @param name The name of the test.
     */
    public DebuggerTest(String name)
    {
        super(name);
    }

    /**
     * Compile all the tests for the default tests for unifiers into a suite, plus the tests defined in this class.
     *
     * @return A test suite.
     */
    public static Test suite()
    {
        // Create a machine to debug.
        SymbolTableImpl<Integer, String, Object> symbolTable = new SymbolTableImpl<Integer, String, Object>();
        machine = new WAMResolvingJavaMachine(symbolTable);

        LogicCompiler<Clause, WAMCompiledPredicate, WAMCompiledQuery> compiler = new WAMCompiler(symbolTable, machine);
        Parser<Clause, Token> parser = new ClauseParser(machine);

        ResolutionEngine<Clause, WAMCompiledPredicate, WAMCompiledQuery> engine =
            new WAMEngine(parser, machine, compiler, machine);

        // Attach the debugger to the machine.
        final TopLevelStandaloneController controller =
            new TopLevelStandaloneController(ComponentFactoryBuilder.createComponentFactory(
                    ComponentFactoryBuilder.SWING_FACTORY));
        controller.open();

        MachineMonitor monitor = controller.getMachineMonitor();

        machine.attachMonitor(monitor);

        // Register a shutdown hook to keep the window open at the end of the tests.
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
                {
                    public void run()
                    {
                        try
                        {
                            System.in.read();
                        }
                        catch (IOException e)
                        {
                            throw new RuntimeException(e);
                        }
                    }
                }));

        // Build a new test suite.
        TestSuite suite = new TestSuite("WAMResolvingJavaMachine Tests");

        /*suite.addTest(new DisjunctionResolverUnitTestBase<Clause, WAMCompiledPredicate, WAMCompiledQuery>(
                "testJunctionBracketingFalse", engine));*/
        suite.addTest(new CutResolverUnitTestBase<Clause, WAMCompiledPredicate, WAMCompiledQuery>(
                "testNeckCutPreventsBacktrackingOk", engine));
        /*suite.addTest(new CutResolverUnitTestBase<Clause, WAMCompiledPredicate, WAMCompiledQuery>(
                "testDeepCutPreventsBacktrackingOk", engine));*/

        return suite;
    }
{'fraction_non_alphanumeric': 0.08620494859337928, 'fraction_numerical': 0.0029375211840470005, 'mean_word_length': 2.789383561643836, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1924445', 'n_tokens_mistral': 2549, 'n_tokens_neox': 2414, 'n_words': 612}