<commit_before>package org.basex.test.query;

import org.basex.core.Context;
import org.basex.core.Main;
import org.basex.core.Process;
import org.basex.core.AProp;
import org.basex.core.Prop;
import org.basex.core.proc.CreateDB;
import org.basex.core.proc.DropDB;
import org.basex.core.proc.XQuery;
import org.basex.data.Nodes;
import org.basex.data.Result;
import org.basex.query.up.UpdateFunctions;
import org.basex.util.Performance;

/**
 * XQuery Test class.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-09, ISC License
 * @author <NAME>
 */
public final class QueryTest {
  /** Test instances. */
  private static final AbstractTest[] TESTS = {
    new SimpleTest(), new XPathMarkFTTest(), new FTTest(), new XQUPTest()
  };
  /** Verbose flag. */
  private static final boolean VERBOSE = false;
  /** Test all flag. */
  private static final boolean ALL = true;
  /** Database Context. */
  private final Context context = new Context();

  /** Wrong results counter. */
  private int wrong;
  /** Query counter. */
  private int counter;

  /**
   * Main method of the test class.
   * @param args command-line arguments (ignored)
   */
  public static void main(final String[] args) {
    new QueryTest();
  }

  /**
   * Constructor.
   */
  private QueryTest() {
    final Performance p = new Performance();
    final Prop prop = context.prop;
    boolean ok = true;

    if(ALL) {
      // testing all kinds of combinations
      for(int a = 0; a < 2; a++) { prop.set(Prop.FTINDEX, a == 0);
        for(int b = 0; b < 2; b++) { prop.set(Prop.FTFUZZY, b == 0);
          for(int c = 0; c < 2; c++) { prop.set(Prop.FTST, c == 0);
            for(int d = 0; d < 2; d++) { prop.set(Prop.FTDC, d == 0);
              for(int e = 0; e < 2; e++) { prop.set(Prop.FTCS, e == 0);
                ok &= test(prop);
              }
            }
          }
        }
      }
    } else {
      // single test
      prop.set(Prop.FTINDEX, true);
      prop.set(Prop.FTFUZZY, true);
      prop.set(Prop.FTST, false);
      prop.set(Prop.FTDC, false);
      prop.set(Prop.FTCS, false);
      ok &= test(prop);
    }

    System.out.println(ok ? "All tests correct." : wrong + " Wrong results...");
    System.out.println(counter + " queries, " + p);
  }

  /**
   * Tests the specified query implementation.
   * @param prop database properties
   * @return true if everything went alright
   */
  private boolean test(final AProp prop) {
    boolean ok = true;
    for(final AbstractTest test : TESTS) ok &= test(test, test.details(prop));
    return ok;
  }

  /**
   * Tests the specified instance.
   * @param test instance
   * @param ext extended error info
   * @return true if everything went alright
   */
  private boolean test(final AbstractTest test, final String ext) {
    final String file = test.doc.replaceAll("\\\"", "\\\\\"");
    final String name = Main.name(test);
    final boolean up = test instanceof XQUPTest;
    Process proc = new CreateDB(file, name);
    boolean ok = proc.execute(context);

    if(ok) {
      for(final Object[] qu : test.queries) {
        // added to renew document after each update test
        if(up && ((String) qu[0]).startsWith("x")) {
          proc = new CreateDB(file, name);
          ok = proc.execute(context);
          UpdateFunctions.printTable(context.data());
        }
        
        final boolean correct = qu.length == 3;
        final String query = qu[correct ? 2 : 1].toString();<commit_msg>whoops, removed output<commit_after>package org.basex.test.query;

import org.basex.core.Context;
import org.basex.core.Main;
import org.basex.core.Process;
import org.basex.core.AProp;
import org.basex.core.Prop;
import org.basex.core.proc.CreateDB;
import org.basex.core.proc.DropDB;
import org.basex.core.proc.XQuery;
import org.basex.data.Nodes;
import org.basex.data.Result;
import org.basex.query.up.UpdateFunctions;
import org.basex.util.Performance;

/**
 * XQuery Test class.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-09, ISC License
 * @author <NAME>
 */
public final class QueryTest {
  /** Test instances. */
  private static final AbstractTest[] TESTS = {
    new SimpleTest(), new XPathMarkFTTest(), new FTTest(), new XQUPTest()
  };
  /** Verbose flag. */
  private static final boolean VERBOSE = false;
  /** Test all flag. */
  private static final boolean ALL = true;
  /** Database Context. */
  private final Context context = new Context();

  /** Wrong results counter. */
  private int wrong;
  /** Query counter. */
  private int counter;

  /**
   * Main method of the test class.
   * @param args command-line arguments (ignored)
   */
  public static void main(final String[] args) {
    new QueryTest();
  }

  /**
   * Constructor.
   */
  private QueryTest() {
    final Performance p = new Performance();
    final Prop prop = context.prop;
    boolean ok = true;

    if(ALL) {
      // testing all kinds of combinations
      for(int a = 0; a < 2; a++) { prop.set(Prop.FTINDEX, a == 0);
        for(int b = 0; b < 2; b++) { prop.set(Prop.FTFUZZY, b == 0);
          for(int c = 0; c < 2; c++) { prop.set(Prop.FTST, c == 0);
            for(int d = 0; d < 2; d++) { prop.set(Prop.FTDC, d == 0);
              for(int e = 0; e < 2; e++) { prop.set(Prop.FTCS, e == 0);
                ok &= test(prop);
              }
            }
          }
        }
      }
    } else {
      // single test
      prop.set(Prop.FTINDEX, true);
      prop.set(Prop.FTFUZZY, true);
      prop.set(Prop.FTST, false);
      prop.set(Prop.FTDC, false);
      prop.set(Prop.FTCS, false);
      ok &= test(prop);
    }

    System.out.println(ok ? "All tests correct." : wrong + " Wrong results...");
    System.out.println(counter + " queries, " + p);
  }

  /**
   * Tests the specified query implementation.
   * @param prop database properties
   * @return true if everything went alright
   */
  private boolean test(final AProp prop) {
    boolean ok = true;
    for(final AbstractTest test : TESTS) ok &= test(test, test.details(prop));
    return ok;
  }

  /**
   * Tests the specified instance.
   * @param test instance
   * @param ext extended error info
   * @return true if everything went alright
   */
  private boolean test(final AbstractTest test, final String ext) {
    final String file = test.doc.replaceAll("\\\"", "\\\\\"");
    final String name = Main.name(test);
    final boolean up = test instanceof XQUPTest;
    Process proc = new CreateDB(file, name);
    boolean ok = proc.execute(context);

    if(ok) {
      for(final Object[] qu : test.queries) {
        // added to renew document after each update test
        if(up && ((String) qu[0]).startsWith("x")) {
          proc = new CreateDB(file, name);
          ok = proc.execute(context);
//          UpdateFunctions.printTable(context.data());
        }
        
        final boolean correct = qu.length == 3;
        final String query = qu[correct ? 2 : 1].toString();
{'fraction_non_alphanumeric': 0.14174924601464886, 'fraction_numerical': 0.007180812868016659, 'mean_word_length': 2.4733167082294263, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7646897', 'n_tokens_mistral': 2250, 'n_tokens_neox': 2175, 'n_words': 643}