text:
package org.orekit.estimation.sequential;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import org.hipparchus.filtering.kalman.ProcessEstimate;
import org.hipparchus.filtering.kalman.unscented.UnscentedEvolution;
import org.hipparchus.filtering.kalman.unscented.UnscentedKalmanFilter;
import org.hipparchus.filtering.kalman.unscented.UnscentedProcess;
import org.hipparchus.linear.ArrayRealVector;
import org.hipparchus.linear.MatrixUtils;
import org.hipparchus.linear.RealMatrix;
import org.hipparchus.linear.RealVector;
import org.hipparchus.util.FastMath;
import org.orekit.estimation.measurements.EstimatedMeasurement;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.orbits.Orbit;
import org.orekit.orbits.OrbitType;
import org.orekit.orbits.PositionAngle;
import org.orekit.propagation.PropagationType;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.conversion.DSSTPropagatorBuilder;
import org.orekit.propagation.semianalytical.dsst.DSSTPropagator;
import org.orekit.propagation.semianalytical.dsst.forces.DSSTForceModel;
import org.orekit.propagation.semianalytical.dsst.forces.ShortPeriodTerms;
import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.ChronologicalComparator;
import org.orekit.utils.ParameterDriver;
import org.orekit.utils.ParameterDriversList;
import org.orekit.utils.ParameterDriversList.DelegatingDriver;

/** Class defining the process model dynamics to use with a {@link SemiAnalyticalUnscentedKalmanEstimator}.
 * @author Gaëtan Pierre
 * @author Bryan Cazabonne
 * @since 11.3
 */
public class SemiAnalyticalUnscentedKalmanModel implements KalmanEstimation, UnscentedProcess<MeasurementDecorator>, SemiAnalyticalProcess {

    /** Initial builder for propagator. */
    private final DSSTPropagatorBuilder builder;

    /** Estimated orbital parameters. */
    private final ParameterDriversList estimatedOrbitalParameters;

    /** Estimated propagation parameters. */
    private final ParameterDriversList estimatedPropagationParameters;

    /** Estimated measurements parameters. */
    private final ParameterDriversList estimatedMeasurementsParameters;

    /** Provider for covariance matrice. */
    private final CovarianceMatrixProvider covarianceMatrixProvider;

    /** Process noise matrix provider for measurement parameters. */
    private final CovarianceMatrixProvider measurementProcessNoiseMatrix;

    /** Position angle type used during orbit determination. */
    private final PositionAngle angleType;

    /** Orbit type used during orbit determination. */
    private final OrbitType orbitType;

    /** Current corrected estimate. */
    private ProcessEstimate correctedEstimate;

    /** Observer to retrieve current estimation info. */
    private KalmanObserver observer;

    /** Current number of measurement. */
    private int currentMeasurementNumber;

    /** Current date. */
    private AbsoluteDate currentDate;

    /** Nominal mean spacecraft state. */
    private SpacecraftState nominalMeanSpacecraftState;

    /** Previous nominal mean spacecraft state. */
    private SpacecraftState previousNominalMeanSpacecraftState;

    /** Predicted osculating spacecraft state. */
    private SpacecraftState predictedSpacecraftState;

    /** Corrected mean spacecraft state. */
    private SpacecraftState correctedSpacecraftState;

    /** Predicted measurement. */
    private EstimatedMeasurement<?> predictedMeasurement;

    /** Corrected measurement. */
    private EstimatedMeasurement<?> correctedMeasurement;

    /** Predicted mean element filter correction. */
    private RealVector predictedFilterCorrection;

    /** Corrected mean element filter correction. */
    private RealVector correctedFilterCorrection;

    /** Propagators for the reference trajectories, up to current date. */
    private DSSTPropagator dsstPropagator;

    /** Short period terms for the nominal mean spacecraft state. */
    private RealVector shortPeriodicTerms;

    /** Unscented Kalman process model constructor (package private).
     * @param propagatorBuilder propagators builders used to evaluate the orbits.
     * @param covarianceMatrixProvider provider for covariance matrix
     * @param estimatedMeasurementParameters measurement parameters to estimate
     * @param measurementProcessNoiseMatrix provider for measurement process noise matrix
     */
    protected SemiAnalyticalUnscentedKalmanModel(final DSSTPropagatorBuilder propagatorBuilder,
                                                 final CovarianceMatrixProvider covarianceMatrixProvider,
                                                 final ParameterDriversList estimatedMeasurementParameters,
                                                 final CovarianceMatrixProvider measurementProcessNoiseMatrix) {

        this.builder                         = propagatorBuilder;
        this.angleType                       = propagatorBuilder.getPositionAngle();
        this.orbitType                       = propagatorBuilder.getOrbitType();
        this.estimatedMeasurementsParameters = estimatedMeasurementParameters;
        this.currentMeasurementNumber        = 0;
        this.currentDate                     = propagatorBuilder.getInitialOrbitDate();
        this.covarianceMatrixProvider        = covarianceMatrixProvider;
        this.measurementProcessNoiseMatrix   = measurementProcessNoiseMatrix;

        // Number of estimated parameters
        int columns = 0;

        // Set estimated orbital parameters
        this.estimatedOrbitalParameters = new ParameterDriversList();
        for (final ParameterDriver driver : propagatorBuilder.getOrbitalParametersDrivers().getDrivers()) {

            // Verify if the driver reference date has been set
            if (driver.getReferenceDate() == null) {
                driver.setReferenceDate(currentDate);
            }

            // Verify if the driver is selected
            if (driver.isSelected()) {
                estimatedOrbitalParameters.add(driver);
                columns++;
            }

        }

        // Set estimated propagation parameters
        this.estimatedPropagationParameters = new ParameterDriversList();
        final List<String> estimatedPropagationParametersNames = new ArrayList<>();
        for (final ParameterDriver driver : propagatorBuilder.getPropagationParametersDrivers().getDrivers()) {

            // Verify if the driver reference date has been set
            if (driver.getReferenceDate() == null) {
                driver.setReferenceDate(currentDate);
            }

            // Verify if the driver is selected
            if (driver.isSelected()) {
                estimatedPropagationParameters.add(driver);
                final String driverName = driver.getName();
                // Add the driver name if it has not been added yet
                if (!estimatedPropagationParametersNames.contains(driverName)) {
                    estimatedPropagationParametersNames.add(driverName);
                    ++columns;
                }
            }

        }
        estimatedPropagationParametersNames.sort(Comparator.naturalOrder());

        // Set the estimated measurement parameters
        for (final ParameterDriver parameter : estimatedMeasurementsParameters.getDrivers()) {
            if (parameter.getReferenceDate() == null) {
                parameter.setReferenceDate(currentDate);
            }
            ++columns;
        }

        // Number of estimated measurement parameters
        final int nbMeas = estimatedMeasurementParameters.getNbParams();

        // Number of estimated dynamic parameters (orbital + propagation)
        final int nbDyn  = estimatedOrbitalParameters.getNbParams() +
                           estimatedPropagationParameters.getNbParams();

        // Build the reference propagator
        this.dsstPropagator = getEstimatedPropagator();
        final SpacecraftState meanState = dsstPropagator.initialIsOsculating() ?
                         DSSTPropagator.computeMeanState(dsstPropagator.getInitialState(), dsstPropagator.getAttitudeProvider(), dsstPropagator.getAllForceModels()) :
                         dsstPropagator.getInitialState();
        this.nominalMeanSpacecraftState         = meanState;
        this.predictedSpacecraftState           = meanState;
        this.correctedSpacecraftState           = predictedSpacecraftState;
        this.previousNominalMeanSpacecraftState = nominalMeanSpacecraftState;

        // Initialize the estimated mean element filter correction
        this.predictedFilterCorrection = MatrixUtils.createRealVector(columns);
        this.correctedFilterCorrection = predictedFilterCorrection;

        // Covariance matrix
        final RealMatrix noiseK = MatrixUtils.createRealMatrix(nbDyn + nbMeas, nbDyn + nbMeas);
        final RealMatrix noiseP = covarianceMatrixProvider.getInitialCovarianceMatrix(nominalMeanSpacecraftState);
        noiseK.setSubMatrix(noiseP.getData(), 0, 0);
        if (measurementProcessNoiseMatrix != null) {
            final RealMatrix noiseM = measurementProcessNoiseMatrix.getInitialCovarianceMatrix(nominalMeanSpacecraftState);
            noiseK.setSubMatrix(noiseM.getData(), nbDyn, nbDyn);
        }

        KalmanEstimatorUtil.checkDimension(noiseK.getRowDimension(),
                                           propagatorBuilder.getOrbitalParametersDrivers(),
                                           propagatorBuilder.getPropagationParametersDrivers(),
                                           estimatedMeasurementsParameters);

        // Initialize corrected estimate
        this.correctedEstimate = new ProcessEstimate(0.0, correctedFilterCorrection, noiseK);

    }

    /** {@inheritDoc} */
    @Override
    public KalmanObserver getObserver() {
        return observer;
    }

    /** Set the observer.
     * @param observer the observer
     */
    public void setObserver(final KalmanObserver observer) {
        this.observer = observer;
    }

    /** Get the current corrected estimate.
     *

     * For the Unscented Semi-analytical Kalman Filter
     * it corresponds to the corrected filter correction.
     * In other words, it doesn't represent an orbital state.
     *

     * @return current corrected estimate
     */
    public ProcessEstimate getEstimate() {
        return correctedEstimate;
    }

    /** Process measurements.
     * @param observedMeasurements the list of measurements to process
     * @param filter Unscented Kalman Filter
     * @return estimated propagator
     */
    public DSSTPropagator processMeasurements(final List<ObservedMeasurement<?>> observedMeasurements,
                                              final UnscentedKalmanFilter<MeasurementDecorator> filter) {

        // Sort the measurement
        observedMeasurements.sort(new ChronologicalComparator());
        final AbsoluteDate tStart             = observedMeasurements.get(0).getDate();
        final AbsoluteDate tEnd               = observedMeasurements.get(observedMeasurements.size() - 1).getDate();
        final double       overshootTimeRange = FastMath.nextAfter(tEnd.durationFrom(tStart),
                                                Double.POSITIVE_INFINITY);

        // Initialize step handler and set it to a parallelized propagator
        final SemiAnalyticalMeasurementHandler  stepHandler = new SemiAnalyticalMeasurementHandler(this, filter, observedMeasurements, builder.getInitialOrbitDate());
        dsstPropagator.getMultiplexer().add(stepHandler);
        dsstPropagator.propagate(tStart, tStart.shiftedBy(overshootTimeRange));

        // Return the last estimated propagator
        return getEstimatedPropagator();

    }

    /** Get the propagator estimated with the values set in the propagator builder.
     * @return propagator based on the current values in the builder
     */
    public DSSTPropagator getEstimatedPropagator() {
        // Return propagator built with current instantiation of the propagator builder
        return builder.buildPropagator(builder.getSelectedNormalizedParameters());
    }

    /** {@inheritDoc} */
    @Override
    public UnscentedEvolution getEvolution(final double previousTime, final RealVector[] sigmaPoints,
                                           final MeasurementDecorator measurement) {

        // Set a reference date for all measurements parameters that lack one (including the not estimated ones)
        final ObservedMeasurement<?> observedMeasurement = measurement.getObservedMeasurement();
        for (final ParameterDriver driver : observedMeasurement.getParametersDrivers()) {
            if (driver.getReferenceDate() == null) {
                driver.setReferenceDate(builder.getInitialOrbitDate());
            }
        }

        // Increment measurement number
        ++currentMeasurementNumber;

        // Update the current date
        currentDate = measurement.getObservedMeasurement().getDate();

        // STM for the prediction of the filter correction
        final RealMatrix stm = getStm();

        // Estimate the measurement for each predicted state
        final RealVector[] predictedStates       = new RealVector[sigmaPoints.length];
        final RealVector[] predictedMeasurements = new RealVector[sigmaPoints.length];
        for (int k = 0; k < sigmaPoints.length; ++k) {

            // Predict filter correction for the current sigma point
            final RealVector predicted = stm.operate(sigmaPoints[k]);
            predictedStates[k] = predicted;

            // Calculate the predicted osculating elements for the current mean state
            final RealVector osculating = computeOsculatingElements(predicted, nominalMeanSpacecraftState, shortPeriodicTerms);
            final Orbit osculatingOrbit = orbitType.mapArrayToOrbit(osculating.toArray(), null, angleType,
                                                                    currentDate, builder.getMu(), builder.getFrame());

            // Then, estimate the measurement
            final EstimatedMeasurement<?> estimated = observedMeasurement.estimate(currentMeasurementNumber,
                                                                                currentMeasurementNumber,
                                                                                new SpacecraftState[] {
                                                                                new SpacecraftState(osculatingOrbit)
                                                                                });
            predictedMeasurements[k] = new ArrayRealVector(estimated.getEstimatedValue());
        }

        // Number of estimated measurement parameters
        final int nbMeas = getNumberSelectedMeasurementDrivers();

        // Number of estimated dynamic parameters (orbital + propagation)
        final int nbDyn  = getNumberSelectedOrbitalDrivers() + getNumberSelectedPropagationDrivers();

        // Covariance matrix
        final RealMatrix noiseK = MatrixUtils.createRealMatrix(nbDyn + nbMeas, nbDyn + nbMeas);
        final RealMatrix noiseP = covarianceMatrixProvider.getProcessNoiseMatrix(previousNominalMeanSpacecraftState, nominalMeanSpacecraftState);
        noiseK.setSubMatrix(noiseP.getData(), 0, 0);
        if (measurementProcessNoiseMatrix != null) {
            final RealMatrix noiseM = measurementProcessNoiseMatrix.getProcessNoiseMatrix(previousNominalMeanSpacecraftState, nominalMeanSpacecraftState);
            noiseK.setSubMatrix(noiseM.getData(), nbDyn, nbDyn);
        }

        // Verify dimension
        KalmanEstimatorUtil.checkDimension(noiseK.getRowDimension(),
                                           builder.getOrbitalParametersDrivers(),
                                           builder.getPropagationParametersDrivers(),
                                           estimatedMeasurementsParameters);

        // Return
        return new UnscentedEvolution(measurement.getTime(), predictedStates, predictedMeasurements, noiseK);

    }

    /** {@inheritDoc} */
    @Override
    public RealVector getInnovation(final MeasurementDecorator measurement, final RealVector predictedMeas,
                                    final RealVector predictedState, final RealMatrix innovationCovarianceMatrix) {

        // Predicted filter correction
        predictedFilterCorrection = predictedState;

        // Predicted measurement
        final RealVector osculating = computeOsculatingElements(predictedFilterCorrection, nominalMeanSpacecraftState, shortPeriodicTerms);
        final Orbit osculatingOrbit = orbitType.mapArrayToOrbit(osculating.toArray(), null, angleType,
                                                                currentDate, builder.getMu(), builder.getFrame());
        predictedSpacecraftState = new SpacecraftState(osculatingOrbit);
        predictedMeasurement = measurement.getObservedMeasurement().estimate(currentMeasurementNumber, currentMeasurementNumber, getPredictedSpacecraftStates());

        // Apply the dynamic outlier filter, if it exists
        KalmanEstimatorUtil.applyDynamicOutlierFilter(predictedMeasurement, innovationCovarianceMatrix);

        // Compute the innovation vector (not normalized for unscented Kalman filter)
        return KalmanEstimatorUtil.computeInnovationVector(predictedMeasurement);

    }

    /** {@inheritDoc} */
    @Override
    public void finalizeEstimation(final ObservedMeasurement<?> observedMeasurement,
                                   final ProcessEstimate estimate) {
        // Update the process estimate
        correctedEstimate = estimate;
        // Corrected filter correction
        correctedFilterCorrection = estimate.getState();

        // Update the previous nominal mean spacecraft state
        previousNominalMeanSpacecraftState = nominalMeanSpacecraftState;

        // Update the previous nominal mean spacecraft state
        // Calculate the corrected osculating elements
        final RealVector osculating = computeOsculatingElements(correctedFilterCorrection, nominalMeanSpacecraftState, shortPeriodicTerms);
        final Orbit osculatingOrbit = orbitType.mapArrayToOrbit(osculating.toArray(), null, builder.getPositionAngle(),
                                                                currentDate, builder.getMu(), builder.getFrame());

        // Compute the corrected measurements
        correctedSpacecraftState = new SpacecraftState(osculatingOrbit);
        correctedMeasurement = observedMeasurement.estimate(currentMeasurementNumber,
                                                            currentMeasurementNumber,
                                                            getCorrectedSpacecraftStates());
        // Call the observer if the user add one
        if (observer != null) {
            observer.evaluationPerformed(this);
        }
    }

    /** Get the state transition matrix used to predict the filter correction.
     *

     * The state transition matrix is not computed by the DSST propagator.
     * It is analytically calculated considering Keplerian contribution only
     *

     * @return the state transition matrix used to predict the filter correction
     */
    private RealMatrix getStm() {

        // initialize the STM
        final int nbDym  = getNumberSelectedOrbitalDrivers() + getNumberSelectedPropagationDrivers();
        final int nbMeas = getNumberSelectedMeasurementDrivers();
        final RealMatrix stm = MatrixUtils.createRealIdentityMatrix(nbDym + nbMeas);

        // State transition matrix using Keplerian contribution only
        final double mu  = builder.getMu();
        final double sma = previousNominalMeanSpacecraftState.getA();
        final double dt  = currentDate.durationFrom(previousNominalMeanSpacecraftState.getDate());
        final double contribution = -1.5 * dt * FastMath.sqrt(mu / FastMath.pow(sma, 5));
        stm.setEntry(5, 0, contribution);

        // Return
        return stm;

    }

    /** {@inheritDoc} */
    @Override
    public void finalizeOperationsObservationGrid() {
        // Update parameters
        updateParameters();
    }

    /** {@inheritDoc} */
    @Override
    public ParameterDriversList getEstimatedOrbitalParameters() {
        return estimatedOrbitalParameters;
    }

    /** {@inheritDoc} */
    @Override
    public ParameterDriversList getEstimatedPropagationParameters() {
        return estimatedPropagationParameters;
    }

    /** {@inheritDoc} */
    @Override
    public ParameterDriversList getEstimatedMeasurementsParameters() {
        return estimatedMeasurementsParameters;
    }

    /** {@inheritDoc}
     *

     * Predicted state is osculating.
     *

     */
    @Override
    public SpacecraftState[] getPredictedSpacecraftStates() {
        return new SpacecraftState[] {predictedSpacecraftState};
    }

    /** {@inheritDoc}
     *

     * Corrected state is osculating.
     *

     */
    @Override
    public SpacecraftState[] getCorrectedSpacecraftStates() {
        return new SpacecraftState[] {correctedSpacecraftState};
    }

    /** {@inheritDoc} */
    @Override
    public RealVector getPhysicalEstimatedState() {
        // Method {@link ParameterDriver#getValue()} is used to get
        // the physical values of the state.
        // The scales'array is used to get the size of the state vector
        final RealVector physicalEstimatedState = new ArrayRealVector(getEstimate().getState().getDimension());
        int i = 0;
        for (final DelegatingDriver driver : getEstimatedOrbitalParameters().getDrivers()) {
            physicalEstimatedState.setEntry(i++, driver.getValue());
        }
        for (final DelegatingDriver driver : getEstimatedPropagationParameters().getDrivers()) {
            physicalEstimatedState.setEntry(i++, driver.getValue());
        }
        for (final DelegatingDriver driver : getEstimatedMeasurementsParameters().getDrivers()) {
            physicalEstimatedState.setEntry(i++, driver.getValue());
        }

        return physicalEstimatedState;
    }

    /** {@inheritDoc} */
    @Override
    public RealMatrix getPhysicalEstimatedCovarianceMatrix() {
        return correctedEstimate.getCovariance();
    }

    /** {@inheritDoc} */
    @Override
    public RealMatrix getPhysicalStateTransitionMatrix() {
        return null;
    }

    /** {@inheritDoc} */
    @Override
    public RealMatrix getPhysicalMeasurementJacobian() {
        return null;
    }

    /** {@inheritDoc} */
    @Override
    public RealMatrix getPhysicalInnovationCovarianceMatrix() {
        return correctedEstimate.getInnovationCovariance();
    }

    /** {@inheritDoc} */
    @Override
    public RealMatrix getPhysicalKalmanGain() {
        return correctedEstimate.getKalmanGain();
    }

    /** {@inheritDoc} */
    @Override
    public int getCurrentMeasurementNumber() {
        return currentMeasurementNumber;
    }

    /** {@inheritDoc} */
    @Override
    public AbsoluteDate getCurrentDate() {
        return currentDate;
    }

    /** {@inheritDoc} */
    @Override
    public EstimatedMeasurement<?> getPredictedMeasurement() {
        return predictedMeasurement;
    }

    /** {@inheritDoc} */
    @Override
    public EstimatedMeasurement<?> getCorrectedMeasurement() {
        return correctedMeasurement;
    }

    /** {@inheritDoc} */
    @Override
    public void updateNominalSpacecraftState(final SpacecraftState nominal) {
        this.nominalMeanSpacecraftState = nominal;
        // Short period terms
        shortPeriodicTerms = new ArrayRealVector(dsstPropagator.getShortPeriodTermsValue(nominalMeanSpacecraftState));
        // Update the builder with the nominal mean elements orbit
        builder.resetOrbit(nominal.getOrbit(), PropagationType.MEAN);
    }

    /** {@inheritDoc} */
    @Override
    public void updateShortPeriods(final SpacecraftState state) {
        // Loop on DSST force models
        for (final DSSTForceModel model : dsstPropagator.getAllForceModels()) {
            model.updateShortPeriodTerms(model.getParameters(), state);
        }
    }

    /** {@inheritDoc} */
    @Override
    public void initializeShortPeriodicTerms(final SpacecraftState meanState) {
        final List<ShortPeriodTerms> shortPeriodTerms = new ArrayList<ShortPeriodTerms>();
        for (final DSSTForceModel force :  builder.getAllForceModels()) {
            shortPeriodTerms.addAll(force.initializeShortPeriodTerms(new AuxiliaryElements(meanState.getOrbit(), 1), PropagationType.OSCULATING, force.getParameters()));
        }
        dsstPropagator.setShortPeriodTerms(shortPeriodTerms);
    }

    /** Compute the predicted osculating elements.
     * @param filterCorrection physical kalman filter correction
     * @param meanState mean spacecraft state
     * @param shortPeriodTerms short period terms for the given mean state
     * @return the predicted osculating element
     */
    private RealVector computeOsculatingElements(final RealVector filterCorrection,
                                                 final SpacecraftState meanState,
                                                 final RealVector shortPeriodTerms) {

        // Convert the input predicted mean state to a SpacecraftState
        final RealVector stateVector = toRealVector(meanState);

        // Return
        return stateVector.add(filterCorrection).add(shortPeriodTerms);

    }

    /** Convert a SpacecraftState to a RealVector.
     * @param state the input SpacecraftState
     * @return the corresponding RealVector
     */
    private RealVector toRealVector(final SpacecraftState state) {

        // Convert orbit to array
        final double[] stateArray = new double[6];
        orbitType.mapOrbitToArray(state.getOrbit(), angleType, stateArray, null);

        // Return the RealVector
        return new ArrayRealVector(stateArray);

    }

    /** Get the number of estimated orbital parameters.
     * @return the number of estimated orbital parameters
     */
    public int getNumberSelectedOrbitalDrivers() {
        return estimatedOrbitalParameters.getNbParams();
    }

    /** Get the number of estimated propagation parameters.
     * @return the number of estimated propagation parameters
     */
    public int getNumberSelectedPropagationDrivers() {
        return estimatedPropagationParameters.getNbParams();
    }

    /** Get the number of estimated measurement parameters.
     * @return the number of estimated measurement parameters
     */
    public int getNumberSelectedMeasurementDrivers() {
        return estimatedMeasurementsParameters.getNbParams();
    }

    /** Update the estimated parameters after the correction phase of the filter.
     * The min/max allowed values are handled by the parameter themselves.
     */
    private void updateParameters() {
        final RealVector correctedState = correctedEstimate.getState();
        int i = 0;
        for (final DelegatingDriver driver : getEstimatedOrbitalParameters().getDrivers()) {
            // let the parameter handle min/max clipping
            driver.setValue(driver.getValue() + correctedState.getEntry(i++));
        }
        for (final DelegatingDriver driver : getEstimatedPropagationParameters().getDrivers()) {
            // let the parameter handle min/max clipping
            driver.setValue(driver.getValue() + correctedState.getEntry(i++));
        }
        for (final DelegatingDriver driver : getEstimatedMeasurementsParameters().getDrivers()) {
            // let the parameter handle min/max clipping
            driver.setValue(driver.getValue() + correctedState.getEntry(i++));
        }
    }

}


text:
package com.navercorp.pinpoint.profiler.context.provider.grpc;

import com.google.inject.Inject;
import com.google.inject.Provider;
import io.grpc.NameResolverProvider;
import io.grpc.internal.PinpointDnsNameResolverProvider;

import java.util.Objects;
import java.util.concurrent.ExecutorService;

/**
 * @author Woonduk Kang(emeroad)
 */
public class GrpcNameResolverProvider implements Provider<NameResolverProvider> {

    private final Provider<ExecutorService> dnsExecutorService;

    @Inject
    public GrpcNameResolverProvider(Provider<ExecutorService> dnsExecutorService) {
        this.dnsExecutorService = Objects.requireNonNull(dnsExecutorService, "dnsExecutorServiceProvider");
    }

    @Override
    public NameResolverProvider get() {
        ExecutorService executorService = dnsExecutorService.get();
        NameResolverProvider nameResolverProvider = new PinpointDnsNameResolverProvider("pinpoint-dns", executorService);
        return nameResolverProvider;
    }
}

redpajama_set_name: RedPajamaGithub


text:
package ai.h2o.sparkling.ml.algos

import ai.h2o.sparkling.ml.metrics.{H2OMetrics, H2OOrdinalGLMMetrics, H2OOrdinalMetrics, MetricsAssertions}
import ai.h2o.sparkling.ml.models.{H2OGLMMOJOModel, H2OMOJOModel}
import ai.h2o.sparkling.{SharedH2OTestContext, TestUtils}
import org.apache.spark.sql.types._
import org.apache.spark.sql.{DataFrame, SparkSession}
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FunSuite, Matchers}

@RunWith(classOf[JUnitRunner])
class OrdinalPredictionTestSuite extends FunSuite with Matchers with SharedH2OTestContext {

  override def createSparkSession(): SparkSession = sparkSession("local[*]")

  private lazy val dataset = spark.read
    .option("header", "true")
    .option("inferSchema", "true")
    .csv(TestUtils.locate("smalldata/insurance.csv"))

  private def createAlgorithm(): H2OGLM = {
    new H2OGLM()
      .setSplitRatio(0.8)
      .setFeaturesCols("District", "Group", "Claims")
      .setLabelCol("Age")
      .setSeed(1)
      .setFamily("ordinal")
  }

  private def assertExistenceOfColumns(df: DataFrame, path: String, expectedColumns: Seq[String]): Unit = {
    assert(df.select(path).columns.sameElements(expectedColumns))
  }

  test("Correct content of ordinal predictions") {
    val algorithm = createAlgorithm()
    val model = algorithm.fit(dataset)

    val predictions = model.transform(dataset)

    assert(model.getModelDetails().contains(""""model_category": "Ordinal""""))
    assertExistenceOfColumns(predictions, "*", dataset.columns ++ Seq("detailed_prediction", "prediction"))
    assertExistenceOfColumns(predictions, "detailed_prediction.*", Seq("label", "probabilities"))
    val probabilities = predictions.select("detailed_prediction.probabilities").take(2).map(_.getStruct(0))

    assert(probabilities(0).getDouble(0) != probabilities(1).getDouble(0))
    assert(probabilities(0).getDouble(1) != probabilities(1).getDouble(1))
    assert(probabilities(0).getDouble(2) != probabilities(1).getDouble(2))
    assert(probabilities(0).getDouble(3) != probabilities(1).getDouble(3))
  }

  test("transformSchema returns expected result") {
    val algorithm = createAlgorithm()
    val model = algorithm.fit(dataset)

    val datasetFields = dataset.schema.fields
    val labelField = StructField("label", StringType, nullable = true)
    val predictionColField = StructField("prediction", StringType, nullable = true)
    val classFields = Seq("25-29", "30-35", "<25", ">35").map(StructField(_, DoubleType, nullable = false))
    val probabilitiesField = StructField("probabilities", StructType(classFields), nullable = false)
    val detailedPredictionColField =
      StructField("detailed_prediction", StructType(Seq(labelField, probabilitiesField)), nullable = true)

    val expectedSchema = StructType(datasetFields ++ (detailedPredictionColField :: predictionColField :: Nil))
    val expectedSchemaByTransform = model.transform(dataset).schema
    val schema = model.transformSchema(dataset.schema)

    assert(model.getModelDetails().contains(""""model_category": "Ordinal""""))
    assert(schema == expectedSchema)
    assert(schema == expectedSchemaByTransform)
  }

  private def assertMetrics[T](model: H2OMOJOModel): Unit = {
    assertMetrics(model.getTrainingMetricsObject(), model.getTrainingMetrics())
    assertMetrics(model.getValidationMetricsObject(), model.getValidationMetrics())
    assert(model.getCrossValidationMetricsObject() == null)
    assert(model.getCrossValidationMetrics() == Map())
  }

  private def assertMetrics(metricsObject: H2OMetrics, metrics: Map[String, Double]): Unit = {
    metricsObject.isInstanceOf[H2OOrdinalGLMMetrics] should be(true)
    MetricsAssertions.assertMetricsObjectAgainstMetricsMap(metricsObject, metrics)
  }

  test("test ordinal glm metric objects") {
    val algo = createAlgorithm()
    val model = algo.fit(dataset)
    assertMetrics[H2OOrdinalMetrics](model)

    model.write.overwrite().save("ml/build/glm_ordinal_model_metrics")
    val loadedModel = H2OGLMMOJOModel.load("ml/build/glm_ordinal_model_metrics")
    assertMetrics[H2OOrdinalGLMMetrics](loadedModel)
  }
}


text:
@interface ViewController : UIViewController<UICollectionViewDataSource, UICollectionViewDelegate, CJUICollectionViewWaterFallLayoutDelegate>

@end


text:
package org.camunda.bpm.tasklist.impl.plugin.resources;

import javax.ws.rs.Path;

import org.camunda.bpm.tasklist.impl.plugin.TasklistPlugins;
import org.camunda.bpm.tasklist.resource.AbstractTasklistPluginRootResource;

/**
 * @author Roman Smirnov
 *
 */
@Path("plugin/" + TasklistPlugins.ID)
public class TasklistPluginsRootResource extends AbstractTasklistPluginRootResource {

  public TasklistPluginsRootResource() {
    super(TasklistPlugins.ID);
  }

}


text:
import os
from util.SysUtil import SysUtil
import logging

__author__ = 'lto'

PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

if __name__ == '__main__':
    logging.basicConfig(format='%(asctime)s_%(process)d:%(pathname)s:%(lineno)d [%(levelname)s] %(message)s',level=logging.DEBUG)
    logger = logging.getLogger("EMMLogger")
    handler = logging.FileHandler('%s/logs/%s.log' % (PATH, os.path.basename(__file__)))
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s_%(process)d:%(pathname)s:%(lineno)d [%(levelname)s] %(message)s')
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    sys_util = SysUtil()
    sys_util.init_sys()

    print sys_util.get_sys_conf().props;


text:
0.16.0 - Removed legacy filtering of leaf nodes. By @michaelsantiago

0.15.0 - Upgraded to `jszip@2.2.2`, fixes `DEFLATE` issue in #25

0.14.0 - Moved test suite to `mocha` to make standalone tests easier

0.13.0 - Added verbose output and updated unzip test for no src files. Fixes #24

0.12.0 - Robustified unzipping empty directories logic. Fixes #21 for OSX

0.11.0 - Fixed bug with unzipping empty directories. Fixes #21

0.10.2 - Added Travis CI

0.10.1 - Upgraded devDependencies from grunt@0.3 to grunt@0.4

0.10.0 - Fixed Windows -> Linux zip compatibility bug. Via #20

0.9.1 - Added assertion against `cwd` and `router` in same config

Before 0.9.1 - See `git log`


text:
- Added support for wildcards in *fieldsToHash*.
- Added the *un-populate* and *removeLabels* arguments.


text:
import { SerializationFormat } from "../schema";

export interface XmlSerlializationFormat extends SerializationFormat {
  name?: string;
  namespace?: string; // url
  prefix?: string;
  attribute: boolean;
  wrapped: boolean;
  text: boolean;
}


text:
'use strict';

/* Dependencies. */
var decode = require('parse-entities');
var whitespace = require('is-whitespace-character');
var locate = require('../locate/url');

/* Expose. */
module.exports = url;
url.locator = locate;
url.notInLink = true;

/* Constants. */
var C_BRACKET_OPEN = '[';
var C_BRACKET_CLOSE = ']';
var C_PAREN_OPEN = '(';
var C_PAREN_CLOSE = ')';
var C_LT = '<';
var C_AT_SIGN = '@';

/* Protocols. */
var HTTP_PROTOCOL = 'http://';
var HTTPS_PROTOCOL = 'https://';
var MAILTO_PROTOCOL = 'mailto:';

var PROTOCOLS = [
  HTTP_PROTOCOL,
  HTTPS_PROTOCOL,
  MAILTO_PROTOCOL
];

var PROTOCOLS_LENGTH = PROTOCOLS.length;

/**
 * Tokenise a link.
 *
 * @property {Function} locator.
 * @param {function(string)} eat - Eater.
 * @param {string} value - Rest of content.
 * @param {boolean?} [silent] - Whether this is a dry run.
 * @return {Node?|boolean} - `link` node.
 */
function url(eat, value, silent) {
  var self = this;
  var subvalue;
  var content;
  var character;
  var index;
  var position;
  var protocol;
  var match;
  var length;
  var queue;
  var parenCount;
  var nextCharacter;
  var exit;

  if (!self.options.gfm) {
    return;
  }

  subvalue = '';
  index = -1;
  length = PROTOCOLS_LENGTH;

  while (++index < length) {
    protocol = PROTOCOLS[index];
    match = value.slice(0, protocol.length);

    if (match.toLowerCase() === protocol) {
      subvalue = match;
      break;
    }
  }

  if (!subvalue) {
    return;
  }

  index = subvalue.length;
  length = value.length;
  queue = '';
  parenCount = 0;

  while (index < length) {
    character = value.charAt(index);

    if (whitespace(character) || character === C_LT) {
      break;
    }

    if (
      character === '.' ||
      character === ',' ||
      character === ':' ||
      character === ';' ||
      character === '"' ||
      character === '\'' ||
      character === ')' ||
      character === ']'
    ) {
      nextCharacter = value.charAt(index + 1);

      if (!nextCharacter || whitespace(nextCharacter)) {
        break;
      }
    }

    if (character === C_PAREN_OPEN || character === C_BRACKET_OPEN) {
      parenCount++;
    }

    if (character === C_PAREN_CLOSE || character === C_BRACKET_CLOSE) {
      parenCount--;

      if (parenCount < 0) {
        break;
      }
    }

    queue += character;
    index++;
  }

  if (!queue) {
    return;
  }

  subvalue += queue;
  content = subvalue;

  if (protocol === MAILTO_PROTOCOL) {
    position = queue.indexOf(C_AT_SIGN);

    if (position === -1 || position === length - 1) {
      return;
    }

    content = content.substr(MAILTO_PROTOCOL.length);
  }

  /* istanbul ignore if - never used (yet) */
  if (silent) {
    return true;
  }

  exit = self.enterLink();
  content = self.tokenizeInline(content, eat.now());
  exit();

  return eat(subvalue)({
    type: 'link',
    title: null,
    url: decode(subvalue),
    children: content
  });
}


text:
package com.chrisrm.idea.panes;

import com.chrisrm.idea.MTConfig;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.IdeRootPaneNorthExtension;
import com.intellij.ui.ColorUtil;
import com.intellij.util.ui.JBInsets;
import com.intellij.util.ui.JBSwingUtilities;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import sun.swing.SwingUtilities2;

import javax.swing.*;
import java.awt.*;

/**
 * Component for theming the Top Frame
 */
public final class MTFrameComponentExtension extends IdeRootPaneNorthExtension {
  private JComponent myWrapperPanel;
  private Project myProject;
  private JPanel myBar;

  public MTFrameComponentExtension(final Project project) {
    myProject = project;
    Disposer.register(myProject, this);
  }

  @Override
  public String getKey() {
    return "MTFrame";
  }

  @Override
  public JComponent getComponent() {
    if (myWrapperPanel == null) {
      myWrapperPanel = new MTWrapperPanel(new BorderLayout()) {
        @Override
        public Insets getInsets() {
          return new JBInsets(0, 0, 0, 0);
        }
      };
      myWrapperPanel.add(buildMTPanel(), BorderLayout.CENTER);
    }
    return myWrapperPanel;
  }

  @Override
  public void uiSettingsChanged(final UISettings settings) {

  }

  @Override
  public IdeRootPaneNorthExtension copy() {
    return new MTFrameComponentExtension(myProject);
  }

  @Override
  public void dispose() {
    myWrapperPanel = null;
    myProject = null;
    myBar = null;
  }

  private Component buildMTPanel() {
    myBar = new JPanel(true);
    //    myWrapperPanel.putClientProperty("MTBarPanel", myBar);

    final JPanel panel = new JPanel(new BorderLayout()) {
      @Override
      public Insets getInsets() {
        return JBUI.insets(10);
      }

      @Override
      public void doLayout() {
        // align vertically
        final Rectangle r = getBounds();
        final Insets insets = getInsets();
        final int x = insets.left;

        final Component navBar = myBar;

        navBar.setBounds(x, insets.top, r.width, r.height);
      }

      @Override
      public void updateUI() {
        super.updateUI();
        setOpaque(true);

        myBar.setOpaque(false);
        myBar.setBorder(null);
      }

      @Override
      protected void paintComponent(final Graphics g) {
        super.paintComponent(g);
        final Component navBar = myBar;
        final Rectangle r = navBar.getBounds();

        final Graphics2D g2d = (Graphics2D) g.create();
        g2d.translate(r.x, r.y);

        final FontMetrics metrics = SwingUtilities2.getFontMetrics(this, g);
        g.setColor(ColorUtil.fromHex(MTConfig.getInstance().getAccentColor()));
        g.fillRect(0, 0, r.width, r.height);

        g.setColor(UIUtil.getListSelectionForeground());
        g.setFont(getFont().deriveFont(Font.BOLD));
        final String textToDraw = myProject.getName().toUpperCase();
        SwingUtilities2.drawString(this, g, textToDraw, r.x + getXOffset(), r.y + metrics.getAscent() - 2);

        g2d.dispose();
      }

      private int getXOffset() {
        return JBUI.scale(12);
      }
    };

    panel.add(myBar, BorderLayout.CENTER);
    panel.updateUI();
    return panel;
  }

  private class MTWrapperPanel extends JPanel {
    MTWrapperPanel(final LayoutManager layout) {
      super(layout);
    }

    @Override
    protected Graphics getComponentGraphics(final Graphics graphics) {
      return JBSwingUtilities.runGlobalCGTransform(this, super.getComponentGraphics(graphics));
    }
  }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
in Batista & Ciferri, Quad. Lab. crittogam. , Pavia 31: 135 (1963)

#### Original name
Microxiphium pinicola Bat., Nascim. & Cif.

### Remarks
null


text:
package org.kaazing.specification.http.rfc7230;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.rules.RuleChain.outerRule;

import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.DisableOnDebug;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.kaazing.k3po.junit.annotation.Specification;
import org.kaazing.k3po.junit.rules.K3poRule;

/**
 * Test to validate behavior as specified in RFC 7230 section 4:
 * Transfer Codings.
 */
public class TransferCodingsIT {

    private final K3poRule k3po = new K3poRule().setScriptRoot("org/kaazing/specification/http/rfc7230/transfer.codings");

    private final TestRule timeout = new DisableOnDebug(new Timeout(5, SECONDS));

    @Rule
    public final TestRule chain = outerRule(k3po).around(timeout);

    @Test
    @Specification({
        "request.transfer.encoding.chunked/request",
        "request.transfer.encoding.chunked/response" })
    public void requestTransferEncodingChunked() throws Exception {
        k3po.finish();
    }

    @Test
    @Specification({
        "response.transfer.encoding.chunked/request",
        "response.transfer.encoding.chunked/response" })
    public void responseTransferEncodingChunked() throws Exception {
        k3po.finish();
    }

    @Test
    @Ignore("requires enhancement https://github.com/k3po/k3po/issues/313")
    public void requestTransferEncodingChunkedExtension() throws Exception {
        k3po.finish();
    }

    @Test
    @Ignore("requires enhancement https://github.com/k3po/k3po/issues/313")
    public void responseTransferEncodingChunkedExtension() throws Exception {
        k3po.finish();
    }

    @Test
    @Specification({
        "request.transfer.encoding.chunked.with.trailer/request",
        "request.transfer.encoding.chunked.with.trailer/response" })
    public void requestTransferEncodingChunkedWithTrailer() throws Exception {
        k3po.finish();
    }

    @Test
    @Specification({
        "response.transfer.encoding.chunked.with.trailer/request",
        "response.transfer.encoding.chunked.with.trailer/response" })
    public void responseTransferEncodingChunkedWithTrailer() throws Exception {
        k3po.finish();
    }

}


text:
class CreateArtworks < ActiveRecord::Migration
  def change
    create_table :artworks do |t|
      t.string :title
      t.string :price
      t.string :image
      t.string :description

      t.timestamps null: false
    end
  end
end


text:
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Text.RegularExpressions;
using System.Globalization;
using Xunit;

public class RegexLangElementsCoverageTests
{
    // This class mainly exists to hit language elements that were missed in other test cases.
    [Fact]
    public static void RegexLangElementsCoverage()
    {
        //////////// Global Variables used for all tests
        String strLoc = "Loc_000oo";
        int iCountErrors = 0;
        int iCountTestcases = 0;

        try
        {
            /////////////////////////  START TESTS ////////////////////////////
            ///////////////////////////////////////////////////////////////////

            //AppDomain.CurrentDomain.AssemblyLoad += AssemblyLoadEventHandler;

            for (int i = 0; i < s_regexTests.Length; i++)
            {
                try
                {
                    iCountTestcases++;
                    if (!s_regexTests[i].Run())
                    {
                        Console.WriteLine("Err_79872asnko! Test {0} FAILED Pattern={1}, Input={2}\n", i, s_regexTests[i].Pattern, s_regexTests[i].Input);
                        iCountErrors++;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Err_79872asnko! Test {0} FAILED Pattern={1}, Input={2} threw the following exception:", i, s_regexTests[i].Pattern, s_regexTests[i].Input);
                    Console.WriteLine(e);
                    iCountErrors++;
                }
            }

            ///////////////////////////////////////////////////////////////////
            /////////////////////////// END TESTS /////////////////////////////
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine("Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
        }
        ////  Finish Diagnostics
        Assert.Equal(0, iCountErrors);
    }

    //private const int GERMAN_PHONEBOOK = 0x10407;
    //private const int ENGLISH_US = 0x0409;
    //private const int INVARIANT = 0x007F;
    //private const int CZECH = 0x0405;
    //private const int DANISH = 0x0406;
    //private const int TURKISH = 0x041F;
    //private const int LATIN_AZERI = 0x042C;
    private static CultureInfo _GERMAN_PHONEBOOK = new CultureInfo("de-DE");
    private static CultureInfo _ENGLISH_US = new CultureInfo("en-US");
    private static CultureInfo _INVARIANT = new CultureInfo("");
    private static CultureInfo _CZECH = new CultureInfo("cs-CZ");
    private static CultureInfo _DANISH = new CultureInfo("da-DK");
    private static CultureInfo _TURKISH = new CultureInfo("tr-TR");
    private static CultureInfo _LATIN_AZERI = new CultureInfo("az-Latn-AZ");

    private static RegexTestCase[] s_regexTests = new RegexTestCase[] {

        /*********************************************************
        Unicode Char Classes
        *********************************************************/
        new RegexTestCase(@"(\p{Lu}\w*)\s(\p{Lu}\w*)", "Hello World", new string[] {"Hello World", "Hello", "World"}),
        new RegexTestCase(@"(\p{Lu}\p{Ll}*)\s(\p{Lu}\p{Ll}*)", "Hello World", new string[] {"Hello World", "Hello", "World"}),
        new RegexTestCase(@"(\P{Ll}\p{Ll}*)\s(\P{Ll}\p{Ll}*)", "Hello World", new string[] {"Hello World", "Hello", "World"}),
        new RegexTestCase(@"(\P{Lu}+\p{Lu})\s(\P{Lu}+\p{Lu})", "hellO worlD", new string[] {"hellO worlD", "hellO", "worlD"}),
        new RegexTestCase(@"(\p{Lt}\w*)\s(\p{Lt}*\w*)", "\u01C5ello \u01C5orld", new string[] {"\u01C5ello \u01C5orld", "\u01C5ello", "\u01C5orld"}),
        new RegexTestCase(@"(\P{Lt}\w*)\s(\P{Lt}*\w*)", "Hello World", new string[] {"Hello World", "Hello", "World"}),

        /*********************************************************
            Character ranges IgnoreCase
        *********************************************************/
        new RegexTestCase(@"[@-D]+", RegexOptions.IgnoreCase, "eE?@ABCDabcdeE", new string[] {"@ABCDabcd"}),
        new RegexTestCase(@"[>-D]+", RegexOptions.IgnoreCase, "eE=>?@ABCDabcdeE", new string[] {">?@ABCDabcd"}),
        new RegexTestCase(@"[\u0554-\u0557]+", RegexOptions.IgnoreCase, "\u0583\u0553\u0554\u0555\u0556\u0584\u0585\u0586\u0557\u0558", new string[] {"\u0554\u0555\u0556\u0584\u0585\u0586\u0557"}),
        new RegexTestCase(@"[X-\]]+", RegexOptions.IgnoreCase, "wWXYZxyz[\\]^", new string[] {"XYZxyz[\\]"}),
        new RegexTestCase(@"[X-\u0533]+", RegexOptions.IgnoreCase, "\u0551\u0554\u0560AXYZaxyz\u0531\u0532\u0533\u0561\u0562\u0563\u0564", new string[] {"AXYZaxyz\u0531\u0532\u0533\u0561\u0562\u0563"}),
        new RegexTestCase(@"[X-a]+", RegexOptions.IgnoreCase, "wWAXYZaxyz", new string[] {"AXYZaxyz"}),
        new RegexTestCase(@"[X-c]+", RegexOptions.IgnoreCase, "wWABCXYZabcxyz", new string[] {"ABCXYZabcxyz"}),
        new RegexTestCase(@"[X-\u00C0]+", RegexOptions.IgnoreCase, "\u00C1\u00E1\u00C0\u00E0wWABCXYZabcxyz", new string[] {"\u00C0\u00E0wWABCXYZabcxyz"}),
        new RegexTestCase(@"[\u0100\u0102\u0104]+", RegexOptions.IgnoreCase, "\u00FF \u0100\u0102\u0104\u0101\u0103\u0105\u0106", new string[] {"\u0100\u0102\u0104\u0101\u0103\u0105"}),
        new RegexTestCase(@"[B-D\u0130]+", RegexOptions.IgnoreCase, "aAeE\u0129\u0131\u0068 BCDbcD\u0130\u0069\u0070", new string[] {"BCDbcD\u0130\u0069"}),
        new RegexTestCase(@"[\u013B\u013D\u013F]+", RegexOptions.IgnoreCase, "\u013A\u013B\u013D\u013F\u013C\u013E\u0140\u0141", new string[] {"\u013B\u013D\u013F\u013C\u013E\u0140"}),
        new RegexTestCase(@"[\uFFFD-\uFFFF]+", RegexOptions.IgnoreCase, "\uFFFC\uFFFD\uFFFE\uFFFF", new string[] {"\uFFFD\uFFFE\uFFFF"}),
        new RegexTestCase(@"[\uFFFC-\uFFFE]+", RegexOptions.IgnoreCase, "\uFFFB\uFFFC\uFFFD\uFFFE\uFFFF", new string[] {"\uFFFC\uFFFD\uFFFE"}),

        /*********************************************************
            Escape Chars
            *********************************************************/
        new RegexTestCase("(Cat)\r(Dog)", "Cat\rDog", new string[] {"Cat\rDog", "Cat", "Dog"}),
        new RegexTestCase("(Cat)\t(Dog)", "Cat\tDog", new string[] {"Cat\tDog", "Cat", "Dog"}),
        new RegexTestCase("(Cat)\f(Dog)", "Cat\fDog", new string[] {"Cat\fDog", "Cat", "Dog"}),

        /*********************************************************
            Miscelaneous { witout matching }
            *********************************************************/
        new RegexTestCase(@"\p{klsak", typeof(ArgumentException)),
        new RegexTestCase(@"{5", "hello {5 world", new string[] {"{5"}),
        new RegexTestCase(@"{5,", "hello {5, world", new string[] {"{5,"}),
        new RegexTestCase(@"{5,6", "hello {5,6 world", new string[] {"{5,6"}),

        /*********************************************************
            Miscelaneous inline options
            *********************************************************/
        new RegexTestCase(@"(?r:cat)", typeof(ArgumentException)),
        new RegexTestCase(@"(?c:cat)", typeof(ArgumentException)),
        new RegexTestCase(@"(?n:(?<cat>cat)(\s+)(?<dog>dog))", "cat   dog", new string[] {"cat   dog", "cat", "dog"}),
        new RegexTestCase(@"(?n:(cat)(\s+)(dog))", "cat   dog", new string[] {"cat   dog"}),
        new RegexTestCase(@"(?n:(cat)(?<SpaceChars>\s+)(dog))", "cat   dog", new string[] {"cat   dog", "   "}),
        new RegexTestCase(@"(?x:
                            (?<cat>cat) # Cat statement
                            (\s+) # Whitespace chars
                            (?<dog>dog # Dog statement
                            ))", "cat   dog", new string[] {"cat   dog", "   ",  "cat", "dog"}),
        new RegexTestCase(@"(?e:cat)", typeof(ArgumentException)),
        new RegexTestCase(@"(?+i:cat)", "CAT", new string[] {"CAT"}),

        /*********************************************************
            \d, \D, \s, \S, \w, \W, \P, \p inside character range
            *********************************************************/
        new RegexTestCase(@"cat([\d]*)dog", "hello123cat230927dog1412d", new string[] {"cat230927dog", "230927"}),
        new RegexTestCase(@"([\D]*)dog", "65498catdog58719", new string[] {"catdog", "cat"}),
        new RegexTestCase(@"cat([\s]*)dog", "wiocat   dog3270", new string[] {"cat   dog", "   "}),
        new RegexTestCase(@"cat([\S]*)", "sfdcatdog    3270", new string[] {"catdog", "dog"}),
        new RegexTestCase(@"cat([\w]*)", "sfdcatdog    3270", new string[] {"catdog", "dog"}),
        new RegexTestCase(@"cat([\W]*)dog", "wiocat   dog3270", new string[] {"cat   dog", "   "}),
        new RegexTestCase(@"([\p{Lu}]\w*)\s([\p{Lu}]\w*)", "Hello World", new string[] {"Hello World", "Hello", "World"}),
        new RegexTestCase(@"([\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)", "Hello World", new string[] {"Hello World", "Hello", "World"}),

        new RegexTestCase(@"cat([a-\d]*)dog", typeof(ArgumentException)),
        new RegexTestCase(@"([5-\D]*)dog", typeof(ArgumentException)),
        new RegexTestCase(@"cat([6-\s]*)dog", typeof(ArgumentException)),
        new RegexTestCase(@"cat([c-\S]*)", typeof(ArgumentException)),
        new RegexTestCase(@"cat([7-\w]*)", typeof(ArgumentException)),
        new RegexTestCase(@"cat([a-\W]*)dog", typeof(ArgumentException)),
        new RegexTestCase(@"([f-\p{Lu}]\w*)\s([\p{Lu}]\w*)", typeof(ArgumentException)),
        new RegexTestCase(@"([1-\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)", typeof(ArgumentException)),
        new RegexTestCase(@"[\p]", typeof(ArgumentException)),
        new RegexTestCase(@"[\P]", typeof(ArgumentException)),
        new RegexTestCase(@"([\pcat])", typeof(ArgumentException)),
        new RegexTestCase(@"([\Pcat])", typeof(ArgumentException)),
        new RegexTestCase(@"(\p{", typeof(ArgumentException)),
        new RegexTestCase(@"(\p{Ll", typeof(ArgumentException)),

        /*********************************************************
            \x, \u, \a, \b, \e, \f, \n, \r, \t, \v, \c, inside character range
            *********************************************************/
       new RegexTestCase(@"(cat)([\x41]*)(dog)", "catAAAdog", new String[] {"catAAAdog", "cat", "AAA", "dog"}),
       new RegexTestCase(@"(cat)([\u0041]*)(dog)", "catAAAdog", new String[] {"catAAAdog", "cat", "AAA", "dog"}),
       new RegexTestCase(@"(cat)([\a]*)(dog)", "cat\a\a\adog", new String[] {"cat\a\a\adog", "cat", "\a\a\a", "dog"}),
       new RegexTestCase(@"(cat)([\b]*)(dog)", "cat\b\b\bdog", new String[] {"cat\b\b\bdog", "cat", "\b\b\b", "dog"}),
       new RegexTestCase(@"(cat)([\e]*)(dog)", "cat\u001B\u001B\u001Bdog", new String[] {"cat\u001B\u001B\u001Bdog", "cat", "\u001B\u001B\u001B", "dog"}),
       new RegexTestCase(@"(cat)([\f]*)(dog)", "cat\f\f\fdog", new String[] {"cat\f\f\fdog", "cat", "\f\f\f", "dog"}),
       new RegexTestCase(@"(cat)([\r]*)(dog)", "cat\r\r\rdog", new String[] {"cat\r\r\rdog", "cat", "\r\r\r", "dog"}),
       new RegexTestCase(@"(cat)([\v]*)(dog)", "cat\v\v\vdog", new String[] {"cat\v\v\vdog", "cat", "\v\v\v", "dog"}),
       new RegexTestCase(@"(cat)([\o]*)(dog)", typeof(ArgumentException)),

        /*********************************************************
        \d, \D, \s, \S, \w, \W, \P, \p inside character range ([0-5]) with ECMA Option
        *********************************************************/
       new RegexTestCase(@"cat([\d]*)dog", RegexOptions.ECMAScript, "hello123cat230927dog1412d", new string[] {"cat230927dog", "230927"}),
       new RegexTestCase(@"([\D]*)dog", RegexOptions.ECMAScript, "65498catdog58719", new string[] {"catdog", "cat"}),
       new RegexTestCase(@"cat([\s]*)dog", RegexOptions.ECMAScript, "wiocat   dog3270", new string[] {"cat   dog", "   "}),
       new RegexTestCase(@"cat([\S]*)", RegexOptions.ECMAScript, "sfdcatdog    3270", new string[] {"catdog", "dog"}),
       new RegexTestCase(@"cat([\w]*)", RegexOptions.ECMAScript, "sfdcatdog    3270", new string[] {"catdog", "dog"}),
       new RegexTestCase(@"cat([\W]*)dog", RegexOptions.ECMAScript, "wiocat   dog3270", new string[] {"cat   dog", "   "}),
       new RegexTestCase(@"([\p{Lu}]\w*)\s([\p{Lu}]\w*)", RegexOptions.ECMAScript, "Hello World", new string[] {"Hello World", "Hello", "World"}),
       new RegexTestCase(@"([\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)", RegexOptions.ECMAScript, "Hello World", new string[] {"Hello World", "Hello", "World"}),

        /*********************************************************
        \d, \D, \s, \S, \w, \W, \P, \p outside character range ([0-5]) with ECMA Option
        *********************************************************/
       new RegexTestCase(@"(cat)\d*dog", RegexOptions.ECMAScript, "hello123cat230927dog1412d", new string[] {"cat230927dog", "cat"}),
       new RegexTestCase(@"\D*(dog)", RegexOptions.ECMAScript, "65498catdog58719", new string[] {"catdog", "dog"}),
       new RegexTestCase(@"(cat)\s*(dog)", RegexOptions.ECMAScript, "wiocat   dog3270", new string[] {"cat   dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\S*", RegexOptions.ECMAScript, "sfdcatdog    3270", new string[] {"catdog", "cat"}),
       new RegexTestCase(@"(cat)\w*", RegexOptions.ECMAScript, "sfdcatdog    3270", new string[] {"catdog", "cat"}),
       new RegexTestCase(@"(cat)\W*(dog)", RegexOptions.ECMAScript, "wiocat   dog3270", new string[] {"cat   dog", "cat", "dog"}),
       new RegexTestCase(@"\p{Lu}(\w*)\s\p{Lu}(\w*)", RegexOptions.ECMAScript, "Hello World", new string[] {"Hello World", "ello", "orld"}),
       new RegexTestCase(@"\P{Ll}\p{Ll}*\s\P{Ll}\p{Ll}*", RegexOptions.ECMAScript, "Hello World", new string[] {"Hello World"}),

        /*********************************************************
        Use < in a group
        *********************************************************/
       new RegexTestCase(@"cat(?<0>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?<1dog>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?<dog)_*>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?<dog!>)_*>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?<dog >)_*>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?<dog<>)_*>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?<>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?<->dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?<dog121>dog)", "catcatdogdogcat", new string[] {"catdog", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s*(?<cat>dog)", "catcat    dogdogcat", new string[] {"cat    dog", "dog"}),
       new RegexTestCase(@"(?<1>cat)\s*(?<1>dog)", "catcat    dogdogcat", new string[] {"cat    dog", "dog"}),
       new RegexTestCase(@"(?<2048>cat)\s*(?<2048>dog)", "catcat    dogdogcat", new string[] {"cat    dog", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\w+(?<dog-cat>dog)", "cat_Hello_World_dog", new string[] {"cat_Hello_World_dog", "", "_Hello_World_"}),
       new RegexTestCase(@"(?<cat>cat)\w+(?<-cat>dog)", "cat_Hello_World_dog", new string[] {"cat_Hello_World_dog", ""}),
       new RegexTestCase(@"(?<cat>cat)\w+(?<cat-cat>dog)", "cat_Hello_World_dog", new string[] {"cat_Hello_World_dog", "_Hello_World_"}),
       new RegexTestCase(@"(?<1>cat)\w+(?<dog-1>dog)", "cat_Hello_World_dog", new string[] {"cat_Hello_World_dog", "", "_Hello_World_"}),
       new RegexTestCase(@"(?<cat>cat)\w+(?<2-cat>dog)", "cat_Hello_World_dog", new string[] {"cat_Hello_World_dog", "", "_Hello_World_"}),
       new RegexTestCase(@"(?<1>cat)\w+(?<2-1>dog)", "cat_Hello_World_dog", new string[] {"cat_Hello_World_dog", "", "_Hello_World_"}),
       new RegexTestCase(@"(?<cat>cat)\w+(?<dog-16>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>cat)\w+(?<dog-1uosn>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>cat)\w+(?<dog-catdog>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>cat)\w+(?<dog-()*!@>dog)", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>cat)\w+(?<dog-0>dog)", "cat_Hello_World_dog", null),

        /*********************************************************
        Quantifiers
        *********************************************************/
       new RegexTestCase(@"(?<cat>cat){", "STARTcat{", new string[] {"cat{", "cat"}),
       new RegexTestCase(@"(?<cat>cat){fdsa", "STARTcat{fdsa", new string[] {"cat{fdsa", "cat"}),
       new RegexTestCase(@"(?<cat>cat){1", "STARTcat{1", new string[] {"cat{1", "cat"}),
       new RegexTestCase(@"(?<cat>cat){1END", "STARTcat{1END", new string[] {"cat{1END", "cat"}),
       new RegexTestCase(@"(?<cat>cat){1,", "STARTcat{1,", new string[] {"cat{1,", "cat"}),
       new RegexTestCase(@"(?<cat>cat){1,END", "STARTcat{1,END", new string[] {"cat{1,END", "cat"}),
       new RegexTestCase(@"(?<cat>cat){1,2", "STARTcat{1,2", new string[] {"cat{1,2", "cat"}),
       new RegexTestCase(@"(?<cat>cat){1,2END", "STARTcat{1,2END", new string[] {"cat{1,2END", "cat"}),

        /*********************************************************
        Use (? in a group
        *********************************************************/
       new RegexTestCase(@"cat(?(?#COMMENT)cat)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?(?'cat'cat)dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?(?<cat>cat)dog)", typeof(ArgumentException)),
       new RegexTestCase(@"cat(?(?afdcat)dog)", typeof(ArgumentException)),

        /*********************************************************
        Use IgnorePatternWhitespace
        *********************************************************/
       new RegexTestCase(@"(cat) #cat
                            \s+ #followed by 1 or more whitespace
                            (dog)  #followed by dog
                            ", RegexOptions.IgnorePatternWhitespace, "cat    dog", new String[] {"cat    dog", "cat", "dog" }),
       new RegexTestCase(@"(cat) #cat
                            \s+ #followed by 1 or more whitespace
                            (dog)  #followed by dog", RegexOptions.IgnorePatternWhitespace, "cat    dog", new String[] {"cat    dog", "cat", "dog" }),
       new RegexTestCase(@"(cat) (?#cat)    \s+ (?#followed by 1 or more whitespace) (dog)  (?#followed by dog)",
           RegexOptions.IgnorePatternWhitespace, "cat    dog", new String[] {"cat    dog", "cat", "dog" }),
       new RegexTestCase(@"(cat) (?#cat)    \s+ (?#followed by 1 or more whitespace",
           RegexOptions.IgnorePatternWhitespace, typeof(ArgumentException)),

        /*********************************************************
        Without IgnorePatternWhitespace
        *********************************************************/
       new RegexTestCase(@"(cat) (?#cat)    \s+ (?#followed by 1 or more whitespace", typeof(ArgumentException)),

        /*********************************************************
        Back Reference
        *********************************************************/
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k<cat>", "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k'cat'", "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\<cat>", "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\'cat'", "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),

       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k<1>", "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k'1'", "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\<1>", "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\'1'", "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\1", "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\1", RegexOptions.ECMAScript, "asdfcat   dogcat   dog", new string[] {"cat   dogcat", "cat", "dog"}),

       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k<dog>", "asdfcat   dogdog   dog", new string[] {"cat   dogdog", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\2", "asdfcat   dogdog   dog", new string[] {"cat   dogdog", "cat", "dog"}),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\2", RegexOptions.ECMAScript, "asdfcat   dogdog   dog", new string[] {"cat   dogdog", "cat", "dog"}),

       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\kcat", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k<cat2>", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k<8>cat", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k<8>cat", RegexOptions.ECMAScript, typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k8", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\k8", RegexOptions.ECMAScript, typeof(ArgumentException)),

        /*********************************************************
        Octal
        *********************************************************/
       new RegexTestCase(@"(cat)(\077)", "hellocat?dogworld", new string[] {"cat?", "cat", "?"}),
       new RegexTestCase(@"(cat)(\77)", "hellocat?dogworld", new string[] {"cat?", "cat", "?"}),
       new RegexTestCase(@"(cat)(\176)", "hellocat~dogworld", new string[] {"cat~", "cat", "~"}),
       new RegexTestCase(@"(cat)(\400)", "hellocat\0dogworld", new string[] {"cat\0", "cat", "\0"}),
       new RegexTestCase(@"(cat)(\300)", "hellocat\u00C0dogworld", new string[] {"cat\u00C0", "cat", "\u00C0"}),
       new RegexTestCase(@"(cat)(\300)", "hellocat\u00C0dogworld", new string[] {"cat\u00C0", "cat", "\u00C0"}),
       new RegexTestCase(@"(cat)(\477)", "hellocat\u003Fdogworld", new string[] {"cat\u003F", "cat", "\u003F"}),
       new RegexTestCase(@"(cat)(\777)", "hellocat\u00FFdogworld", new string[] {"cat\u00FF", "cat", "\u00FF"}),
       new RegexTestCase(@"(cat)(\7770)", "hellocat\u00FF0dogworld", new string[] {"cat\u00FF0", "cat", "\u00FF0"}),
       new RegexTestCase(@"(cat)(\7)", typeof(ArgumentException)),

       new RegexTestCase(@"(cat)(\077)", RegexOptions.ECMAScript, "hellocat?dogworld", new string[] {"cat?", "cat", "?"}),
       new RegexTestCase(@"(cat)(\77)", RegexOptions.ECMAScript, "hellocat?dogworld", new string[] {"cat?", "cat", "?"}),
       new RegexTestCase(@"(cat)(\7)", RegexOptions.ECMAScript, "hellocat\adogworld", new string[] {"cat\a", "cat", "\a"}),
       new RegexTestCase(@"(cat)(\40)", RegexOptions.ECMAScript, "hellocat dogworld", new string[] {"cat ", "cat", " "}),
       new RegexTestCase(@"(cat)(\040)", RegexOptions.ECMAScript, "hellocat dogworld", new string[] {"cat ", "cat", " "}),
       new RegexTestCase(@"(cat)(\176)", RegexOptions.ECMAScript, "hellocatcat76dogworld", new string[] {"catcat76", "cat", "cat76"}),
       new RegexTestCase(@"(cat)(\377)", RegexOptions.ECMAScript, "hellocat\u00FFdogworld", new string[] {"cat\u00FF", "cat", "\u00FF"}),
       new RegexTestCase(@"(cat)(\400)", RegexOptions.ECMAScript, "hellocat 0Fdogworld", new string[] {"cat 0", "cat", " 0"}),

        /*********************************************************
        Decimal
        *********************************************************/
       new RegexTestCase(@"(cat)\s+(?<2147483646>dog)", "asdlkcat  dogiwod", new string[] {"cat  dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\s+(?<2147483647>dog)",  "asdlkcat  dogiwod", new string[] {"cat  dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\s+(?<2147483648>dog)", typeof(System.ArgumentException)),
       new RegexTestCase(@"(cat)\s+(?<21474836481097>dog)", typeof(System.ArgumentException)),

        /*********************************************************
        Hex
        *********************************************************/
       new RegexTestCase(@"(cat)(\x2a*)(dog)", "asdlkcat***dogiwod", new string[] {"cat***dog", "cat", "***", "dog"}),
       new RegexTestCase(@"(cat)(\x2b*)(dog)", "asdlkcat+++dogiwod", new string[] {"cat+++dog", "cat", "+++", "dog"}),
       new RegexTestCase(@"(cat)(\x2c*)(dog)", "asdlkcat,,,dogiwod", new string[] {"cat,,,dog", "cat", ",,,", "dog"}),
       new RegexTestCase(@"(cat)(\x2d*)(dog)", "asdlkcat---dogiwod", new string[] {"cat---dog", "cat", "---", "dog"}),
       new RegexTestCase(@"(cat)(\x2e*)(dog)", "asdlkcat...dogiwod", new string[] {"cat...dog", "cat", "...", "dog"}),
       new RegexTestCase(@"(cat)(\x2f*)(dog)", "asdlkcat///dogiwod", new string[] {"cat///dog", "cat", "///", "dog"}),

       new RegexTestCase(@"(cat)(\x2A*)(dog)", "asdlkcat***dogiwod", new string[] {"cat***dog", "cat", "***", "dog"}),
       new RegexTestCase(@"(cat)(\x2B*)(dog)", "asdlkcat+++dogiwod", new string[] {"cat+++dog", "cat", "+++", "dog"}),
       new RegexTestCase(@"(cat)(\x2C*)(dog)", "asdlkcat,,,dogiwod", new string[] {"cat,,,dog", "cat", ",,,", "dog"}),
       new RegexTestCase(@"(cat)(\x2D*)(dog)", "asdlkcat---dogiwod", new string[] {"cat---dog", "cat", "---", "dog"}),
       new RegexTestCase(@"(cat)(\x2E*)(dog)", "asdlkcat...dogiwod", new string[] {"cat...dog", "cat", "...", "dog"}),
       new RegexTestCase(@"(cat)(\x2F*)(dog)", "asdlkcat///dogiwod", new string[] {"cat///dog", "cat", "///", "dog"}),

        /*********************************************************
        ScanControl
        *********************************************************/
       new RegexTestCase(@"(cat)(\c*)(dog)", typeof(ArgumentException)),
       new RegexTestCase(@"(cat)\c", typeof(ArgumentException)),
       new RegexTestCase(@"(cat)(\c *)(dog)", typeof(ArgumentException)),
       new RegexTestCase(@"(cat)(\c?*)(dog)", typeof(ArgumentException)),
       new RegexTestCase("(cat)(\\c\0*)(dog)", typeof(ArgumentException)),
       new RegexTestCase(@"(cat)(\c`*)(dog)", typeof(ArgumentException)),
       new RegexTestCase(@"(cat)(\c\|*)(dog)", typeof(ArgumentException)),
       new RegexTestCase(@"(cat)(\c\[*)(dog)", typeof(ArgumentException)),

       new RegexTestCase(@"(cat)(\c@*)(dog)", "asdlkcat\0\0dogiwod", new string[] {"cat\0\0dog", "cat", "\0\0", "dog"}),
       new RegexTestCase(@"(cat)(\cA*)(dog)", "asdlkcat\u0001dogiwod", new string[] {"cat\u0001dog", "cat", "\u0001", "dog"}),
       new RegexTestCase(@"(cat)(\ca*)(dog)", "asdlkcat\u0001dogiwod", new string[] {"cat\u0001dog", "cat", "\u0001", "dog"}),

       new RegexTestCase(@"(cat)(\cC*)(dog)", "asdlkcat\u0003dogiwod", new string[] {"cat\u0003dog", "cat", "\u0003", "dog"}),
       new RegexTestCase(@"(cat)(\cc*)(dog)", "asdlkcat\u0003dogiwod", new string[] {"cat\u0003dog", "cat", "\u0003", "dog"}),

       new RegexTestCase(@"(cat)(\cD*)(dog)", "asdlkcat\u0004dogiwod", new string[] {"cat\u0004dog", "cat", "\u0004", "dog"}),
       new RegexTestCase(@"(cat)(\cd*)(dog)", "asdlkcat\u0004dogiwod", new string[] {"cat\u0004dog", "cat", "\u0004", "dog"}),

       new RegexTestCase(@"(cat)(\cX*)(dog)", "asdlkcat\u0018dogiwod", new string[] {"cat\u0018dog", "cat", "\u0018", "dog"}),
       new RegexTestCase(@"(cat)(\cx*)(dog)", "asdlkcat\u0018dogiwod", new string[] {"cat\u0018dog", "cat", "\u0018", "dog"}),

       new RegexTestCase(@"(cat)(\cZ*)(dog)", "asdlkcat\u001adogiwod", new string[] {"cat\u001adog", "cat", "\u001a", "dog"}),
       new RegexTestCase(@"(cat)(\cz*)(dog)", "asdlkcat\u001adogiwod", new string[] {"cat\u001adog", "cat", "\u001a", "dog"}),

        /*********************************************************
        Atomic Zero-Width Assertions \A \Z \z \G \b \B
        *********************************************************/
        //\A
        new RegexTestCase(@"\A(cat)\s+(dog)", "cat   \n\n\n   dog", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),
       new RegexTestCase(@"\A(cat)\s+(dog)", RegexOptions.Multiline, "cat   \n\n\n   dog", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),
       new RegexTestCase(@"\A(cat)\s+(dog)", RegexOptions.ECMAScript, "cat   \n\n\n   dog", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),

       new RegexTestCase(@"\A(cat)\s+(dog)", "cat   \n\n\ncat     dog", null),
       new RegexTestCase(@"\A(cat)\s+(dog)", RegexOptions.Multiline, "cat   \n\n\ncat     dog", null),
       new RegexTestCase(@"\A(cat)\s+(dog)", RegexOptions.ECMAScript, "cat   \n\n\ncat     dog", null),

        //\Z
        new RegexTestCase(@"(cat)\s+(dog)\Z", "cat   \n\n\n   dog", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\s+(dog)\Z", RegexOptions.Multiline, "cat   \n\n\n   dog", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\s+(dog)\Z", RegexOptions.ECMAScript, "cat   \n\n\n   dog", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\s+(dog)\Z", "cat   \n\n\n   dog\n", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\s+(dog)\Z", RegexOptions.Multiline, "cat   \n\n\n   dog\n", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\s+(dog)\Z", RegexOptions.ECMAScript, "cat   \n\n\n   dog\n", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),

       new RegexTestCase(@"(cat)\s+(dog)\Z", "cat   dog\n\n\ncat", null),
       new RegexTestCase(@"(cat)\s+(dog)\Z", RegexOptions.Multiline, "cat   dog\n\n\ncat     ", null),
       new RegexTestCase(@"(cat)\s+(dog)\Z", RegexOptions.ECMAScript, "cat   dog\n\n\ncat     ", null),

        //\z
        new RegexTestCase(@"(cat)\s+(dog)\z", "cat   \n\n\n   dog", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\s+(dog)\z", RegexOptions.Multiline, "cat   \n\n\n   dog", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),
       new RegexTestCase(@"(cat)\s+(dog)\z", RegexOptions.ECMAScript, "cat   \n\n\n   dog", new string[] {"cat   \n\n\n   dog", "cat", "dog"}),

       new RegexTestCase(@"(cat)\s+(dog)\z", "cat   dog\n\n\ncat", null),
       new RegexTestCase(@"(cat)\s+(dog)\z", RegexOptions.Multiline, "cat   dog\n\n\ncat     ", null),
       new RegexTestCase(@"(cat)\s+(dog)\z", RegexOptions.ECMAScript, "cat   dog\n\n\ncat     ", null),
       new RegexTestCase(@"(cat)\s+(dog)\z", "cat   \n\n\n   dog\n", null),
       new RegexTestCase(@"(cat)\s+(dog)\z", RegexOptions.Multiline, "cat   \n\n\n   dog\n", null),
       new RegexTestCase(@"(cat)\s+(dog)\z", RegexOptions.ECMAScript, "cat   \n\n\n   dog\n", null),

        //\b
        new RegexTestCase(@"\b@cat", "123START123@catEND", new string[] {"@cat"}),
       new RegexTestCase(@"\b\<cat", "123START123<catEND", new string[] {"<cat"}),
       new RegexTestCase(@"\b,cat", "satwe,,,START,catEND", new string[] {",cat"}),
       new RegexTestCase(@"\b\[cat", "`12START123[catEND", new string[] {"[cat"}),

       new RegexTestCase(@"\b@cat", "123START123;@catEND", null),
       new RegexTestCase(@"\b\<cat", "123START123'<catEND", null),
       new RegexTestCase(@"\b,cat", "satwe,,,START',catEND", null),
       new RegexTestCase(@"\b\[cat", "`12START123'[catEND", null),

        //\B
        new RegexTestCase(@"\B@cat", "123START123;@catEND", new string[] {"@cat"}),
       new RegexTestCase(@"\B\<cat", "123START123'<catEND", new string[] {"<cat"}),
       new RegexTestCase(@"\B,cat", "satwe,,,START',catEND", new string[] {",cat"}),
       new RegexTestCase(@"\B\[cat", "`12START123'[catEND", new string[] {"[cat"}),

       new RegexTestCase(@"\B@cat", "123START123@catEND", null),
       new RegexTestCase(@"\B\<cat", "123START123<catEND", null),
       new RegexTestCase(@"\B,cat", "satwe,,,START,catEND", null),
       new RegexTestCase(@"\B\[cat", "`12START123[catEND", null),

        /*********************************************************
        \w matching \p{Lm} (Letter, Modifier)
        *********************************************************/
       new RegexTestCase(@"(\w+)\s+(\w+)", "cat\u02b0 dog\u02b1", new string[] {"cat\u02b0 dog\u02b1", "cat\u02b0", "dog\u02b1"}),
       new RegexTestCase(@"(cat\w+)\s+(dog\w+)", "STARTcat\u30FC dog\u3005END", new string[] {"cat\u30FC dog\u3005END", "cat\u30FC", "dog\u3005END"}),
       new RegexTestCase(@"(cat\w+)\s+(dog\w+)", "STARTcat\uff9e dog\uff9fEND", new string[] {"cat\uff9e dog\uff9fEND", "cat\uff9e", "dog\uff9fEND"}),

        /*********************************************************
        positive and negative character classes [a-c]|[^b-c]
        *********************************************************/
       new RegexTestCase(@"[^a]|d", "d", new string[] {"d"}),
       new RegexTestCase(@"([^a]|[d])*", "Hello Worlddf", new string[] {"Hello Worlddf", "f"}),
       new RegexTestCase(@"([^{}]|\n)+", "{{{{Hello\n World \n}END", new string[] {"Hello\n World \n", "\n"}),
       new RegexTestCase(@"([a-d]|[^abcd])+", "\tonce\n upon\0 a- ()*&^%#time?", new string[] {"\tonce\n upon\0 a- ()*&^%#time?", "?"}),
       new RegexTestCase(@"([^a]|[a])*", "once upon a time", new string[] {"once upon a time", "e"}),
       new RegexTestCase(@"([a-d]|[^abcd]|[x-z]|^wxyz])+", "\tonce\n upon\0 a- ()*&^%#time?", new string[] {"\tonce\n upon\0 a- ()*&^%#time?", "?"}),
       new RegexTestCase(@"([a-d]|[e-i]|[^e]|wxyz])+", "\tonce\n upon\0 a- ()*&^%#time?", new string[] {"\tonce\n upon\0 a- ()*&^%#time?", "?"}),

        /*********************************************************
        canonical and non-cannonical char class, where one group is in it's
        simplist form [a-e] and another is more complex .
        *********************************************************/
       new RegexTestCase(@"^(([^b]+ )|(.* ))$", "aaa ", new string[] {"aaa ", "aaa ", "aaa ", ""}),
       new RegexTestCase(@"^(([^b]+ )|(.*))$", "aaa", new string[] {"aaa", "aaa", "", "aaa"}),
       new RegexTestCase(@"^(([^b]+ )|(.* ))$", "bbb ", new string[] {"bbb ", "bbb ", "", "bbb "}),
       new RegexTestCase(@"^(([^b]+ )|(.*))$", "bbb", new string[] {"bbb", "bbb", "", "bbb"}),
       new RegexTestCase(@"^((a*)|(.*))$", "aaa", new string[] {"aaa", "aaa", "aaa", ""}),
       new RegexTestCase(@"^((a*)|(.*))$", "aaabbb", new string[] {"aaabbb", "aaabbb", "", "aaabbb"}),

       new RegexTestCase(@"(([0-9])|([a-z])|([A-Z]))*", "{hello 1234567890 world}", new string[] {"", "", "", "", ""}),
       new RegexTestCase(@"(([0-9])|([a-z])|([A-Z]))+", "{hello 1234567890 world}", new string[] {"hello", "o", "", "o", ""}),
       new RegexTestCase(@"(([0-9])|([a-z])|([A-Z]))*", "{HELLO 1234567890 world}", new string[] {"", "", "", "", ""}),
       new RegexTestCase(@"(([0-9])|([a-z])|([A-Z]))+", "{HELLO 1234567890 world}", new string[] {"HELLO", "O", "", "", "O"}),
       new RegexTestCase(@"(([0-9])|([a-z])|([A-Z]))*", "{1234567890 hello  world}", new string[] {"", "", "", "", ""}),
       new RegexTestCase(@"(([0-9])|([a-z])|([A-Z]))+", "{1234567890 hello world}", new string[] {"1234567890", "0", "0", "", ""}),

       new RegexTestCase(@"^(([a-d]*)|([a-z]*))$", "aaabbbcccdddeeefff", new string[] {"aaabbbcccdddeeefff", "aaabbbcccdddeeefff", "", "aaabbbcccdddeeefff"}),
       new RegexTestCase(@"^(([d-f]*)|([c-e]*))$", "dddeeeccceee", new string[] {"dddeeeccceee", "dddeeeccceee", "", "dddeeeccceee"}),
       new RegexTestCase(@"^(([c-e]*)|([d-f]*))$", "dddeeeccceee", new string[] {"dddeeeccceee", "dddeeeccceee", "dddeeeccceee", ""}),

       new RegexTestCase(@"(([a-d]*)|([a-z]*))", "aaabbbcccdddeeefff", new string[] {"aaabbbcccddd", "aaabbbcccddd", "aaabbbcccddd", ""}),
       new RegexTestCase(@"(([d-f]*)|([c-e]*))", "dddeeeccceee", new string[] {"dddeee", "dddeee", "dddeee", ""}),
       new RegexTestCase(@"(([c-e]*)|([d-f]*))", "dddeeeccceee", new string[] {"dddeeeccceee", "dddeeeccceee", "dddeeeccceee", ""}),

       new RegexTestCase(@"(([a-d]*)|(.*))", "aaabbbcccdddeeefff", new string[] {"aaabbbcccddd", "aaabbbcccddd", "aaabbbcccddd", ""}),
       new RegexTestCase(@"(([d-f]*)|(.*))", "dddeeeccceee", new string[] {"dddeee", "dddeee", "dddeee", ""}),
       new RegexTestCase(@"(([c-e]*)|(.*))", "dddeeeccceee", new string[] {"dddeeeccceee", "dddeeeccceee", "dddeeeccceee", ""}),

        /*********************************************************
        \p{Pi} (Punctuation Initial quote) \p{Pf} (Punctuation Final quote)
        *********************************************************/
       new RegexTestCase(@"\p{Pi}(\w*)\p{Pf}", "\u00ABCat\u00BB   \u00BBDog\u00AB'", new string[] {"\u00ABCat\u00BB", "Cat"}),
       new RegexTestCase(@"\p{Pi}(\w*)\p{Pf}", "\u2018Cat\u2019   \u2019Dog\u2018'", new string[] {"\u2018Cat\u2019", "Cat"}),

        /*********************************************************
Use special unicode characters
        *********************************************************/
        /*        new RegexTest(@"AE", "\u00C4", new string[] {"Hello World", "Hello", "World"}, GERMAN_PHONEBOOK),
                new RegexTest(@"oe", "\u00F6", new string[] {"Hello World", "Hello", "World"}, GERMAN_PHONEBOOK),

                new RegexTest("\u00D1", "\u004E\u0303", new string[] {"Hello World", "Hello", "World"}, ENGLISH_US),
                new RegexTest("\u00D1", "\u004E\u0303", new string[] {"Hello World", "Hello", "World"}, INVARIANT),
                new RegexTest("\u00D1", RegexOptions.IgnoreCase, "\u006E\u0303", new string[] {"Hello World", "Hello", "World"}, ENGLISH_US),
                new RegexTest("\u00D1", RegexOptions.IgnoreCase, "\u006E\u0303", new string[] {"Hello World", "Hello", "World"}, INVARIANT),

                new RegexTest("\u00F1", RegexOptions.IgnoreCase, "\u004E\u0303", new string[] {"Hello World", "Hello", "World"}, ENGLISH_US),
                new RegexTest("\u00F1", RegexOptions.IgnoreCase, "\u004E\u0303", new string[] {"Hello World", "Hello", "World"}, INVARIANT),
                new RegexTest("\u00F1", "\u006E\u0303", new string[] {"Hello World", "Hello", "World"}, ENGLISH_US),
                new RegexTest("\u00F1", "\u006E\u0303", new string[] {"Hello World", "Hello", "World"}, ENGLISH_US),
        */
       new RegexTestCase("CH", RegexOptions.IgnoreCase, "Ch", new string[] {"Ch"}, _ENGLISH_US),
       new RegexTestCase("CH", RegexOptions.IgnoreCase, "Ch", new string[] {"Ch"}, _CZECH),
       new RegexTestCase("cH", RegexOptions.IgnoreCase, "Ch", new string[] {"Ch"}, _ENGLISH_US),
       new RegexTestCase("cH", RegexOptions.IgnoreCase, "Ch", new string[] {"Ch"}, _CZECH),

       new RegexTestCase("AA", RegexOptions.IgnoreCase, "Aa", new string[] {"Aa"}, _ENGLISH_US),
       new RegexTestCase("AA", RegexOptions.IgnoreCase, "Aa", new string[] {"Aa"}, _DANISH),
       new RegexTestCase("aA", RegexOptions.IgnoreCase, "Aa", new string[] {"Aa"}, _ENGLISH_US),
       new RegexTestCase("aA", RegexOptions.IgnoreCase, "Aa", new string[] {"Aa"}, _DANISH),

       new RegexTestCase("\u0131", RegexOptions.IgnoreCase, "\u0049", new string[] {"\u0049"}, _TURKISH),
       new RegexTestCase("\u0130", RegexOptions.IgnoreCase, "\u0069", new string[] {"\u0069"}, _TURKISH),
       new RegexTestCase("\u0131", RegexOptions.IgnoreCase, "\u0049", new string[] {"\u0049"}, _LATIN_AZERI),
       new RegexTestCase("\u0130", RegexOptions.IgnoreCase, "\u0069", new string[] {"\u0069"}, _LATIN_AZERI),

       new RegexTestCase("\u0131", RegexOptions.IgnoreCase, "\u0049", null, _ENGLISH_US),
       new RegexTestCase("\u0131", RegexOptions.IgnoreCase, "\u0069", null, _ENGLISH_US),

        new RegexTestCase("\u0130", RegexOptions.IgnoreCase, "\u0049", new string[] {"\u0049"}, _ENGLISH_US),
        new RegexTestCase("\u0130", RegexOptions.IgnoreCase, "\u0069", new string[] {"\u0069"}, _ENGLISH_US),

       new RegexTestCase("\u0131", RegexOptions.IgnoreCase, "\u0049", null, _INVARIANT),
       new RegexTestCase("\u0131", RegexOptions.IgnoreCase, "\u0069", null, _INVARIANT),
       new RegexTestCase("\u0130", RegexOptions.IgnoreCase, "\u0049", null, _INVARIANT),
       new RegexTestCase("\u0130", RegexOptions.IgnoreCase, "\u0069", null, _INVARIANT),

        /*********************************************************
        ECMAScript
        *********************************************************/
       new RegexTestCase(@"(?<cat>cat)\s+(?<dog>dog)\s+\123\s+\234", RegexOptions.ECMAScript, "asdfcat   dog     cat23    dog34eia", new string[] {"cat   dog     cat23    dog34", "cat", "dog"}),

        /*********************************************************
        Balanced Mactching
        *********************************************************/
       new RegexTestCase(@"<div>
            (?>
                <div>(?<DEPTH>) |
                </div> (?<-DEPTH>) |
                .?
            )*?
            (?(DEPTH)(?!))
            </div>", RegexOptions.IgnorePatternWhitespace,
           "<div>this is some <div>red</div> text</div></div></div>",
           new string[] {"<div>this is some <div>red</div> text</div>", ""}),

       new RegexTestCase(@"(
            ((?'open'<+)[^<>]*)+
            ((?'close-open'>+)[^<>]*)+
            )+", RegexOptions.IgnorePatternWhitespace,
           "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>",
           new string[] {"<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", "<02deep_03<03deep_03>>>",
               "<03deep_03", ">>>", "<", "03deep_03"}),

       new RegexTestCase(@"(
            (?<start><)?
            [^<>]?
            (?<end-start>>)?
            )*", RegexOptions.IgnorePatternWhitespace,
           "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>",
           new string[] {"<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", "", "",
               "01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>"}),

       new RegexTestCase(@"(
            (?<start><[^/<>]*>)?
            [^<>]?
            (?<end-start></[^/<>]*>)?
            )*", RegexOptions.IgnorePatternWhitespace,
           "<b><a>Cat</a></b>",
           new string[] {"<b><a>Cat</a></b>", "", "", "<a>Cat</a>"}),

       new RegexTestCase(@"(
            (?<start><(?<TagName>[^/<>]*)>)?
            [^<>]?
            (?<end-start></\k<TagName>>)?
            )*", RegexOptions.IgnorePatternWhitespace,
           "<b>cat</b><a>dog</a>",
           new string[] {"<b>cat</b><a>dog</a>", "", "", "a", "dog"}),

        /*********************************************************
        Balanced Mactching With Backtracking
        *********************************************************/
       new RegexTestCase(@"(
            (?<start><[^/<>]*>)?
            .?
            (?<end-start></[^/<>]*>)?
            )*
            (?(start)(?!)) ", RegexOptions.IgnorePatternWhitespace,
           "<b><a>Cat</a></b><<<<c>>>><<d><e<f>><g><<<>>>>",
           new string[] {"<b><a>Cat</a></b><<<<c>>>><<d><e<f>><g><<<>>>>", "", "", "<a>Cat"}),

        /*********************************************************
        Character Classes and Lazy quantifier
        *********************************************************/
       new RegexTestCase(@"([0-9]+?)([\w]+?)", RegexOptions.ECMAScript, "55488aheiaheiad", new string[] {"55", "5", "5"}),
       new RegexTestCase(@"([0-9]+?)([a-z]+?)", RegexOptions.ECMAScript, "55488aheiaheiad", new string[] {"55488a", "55488", "a"}),

        /*********************************************************
        Misclaneous/Regression scenarios
        *********************************************************/
       new RegexTestCase(@"(?<openingtag>1)(?<content>.*?)(?=2)", RegexOptions.Singleline | RegexOptions.ExplicitCapture,
           "1\r\n<Projecaa DefaultTargets=\"x\"/>\r\n2", new string[] {"1\r\n<Projecaa DefaultTargets=\"x\"/>\r\n", "1", "\r\n<Projecaa DefaultTargets=\"x\"/>\r\n"}),

       new RegexTestCase(@"\G<%#(?<code>.*?)?%>", RegexOptions.Singleline,
           @"<%# DataBinder.Eval(this, ""MyNumber"") %>", new string[] {@"<%# DataBinder.Eval(this, ""MyNumber"") %>", @" DataBinder.Eval(this, ""MyNumber"") "}),

        /*********************************************************
        Nested Quantifiers
        *********************************************************/
       new RegexTestCase(@"^[abcd]{0,0x10}*$", "a{0,0x10}}}", new string[] {"a{0,0x10}}}"}),
       new RegexTestCase(@"^[abcd]{0,16}*$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]{1,}*$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]{1}*$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]{0,16}?*$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]{1,}?*$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]{1}?*$", typeof(ArgumentException)),

       new RegexTestCase(@"^[abcd]*+$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]+*$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]?*$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]*?+$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]+?*$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]??*$", typeof(ArgumentException)),

       new RegexTestCase(@"^[abcd]*{0,5}$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]+{0,5}$", typeof(ArgumentException)),
       new RegexTestCase(@"^[abcd]?{0,5}$", typeof(ArgumentException)),

        /*********************************************************
        Lazy operator Backtracking
        *********************************************************/
       new RegexTestCase(@"http://([a-zA-z0-9\-]*\.?)*?(:[0-9]*)??/",  RegexOptions.IgnoreCase, "http://www.msn.com", null),
       new RegexTestCase(@"http://([a-zA-z0-9\-]*\.?)*?(:[0-9]*)??/",  RegexOptions.IgnoreCase, "http://www.msn.com/", new string[] {"http://www.msn.com/", "com", String.Empty}),
       new RegexTestCase(@"http://([a-zA-Z0-9\-]*\.?)*?/", RegexOptions.IgnoreCase, @"http://www.google.com/", new string[] {"http://www.google.com/", "com"}),

       new RegexTestCase(@"([a-z]*?)([\w])",  RegexOptions.IgnoreCase, "cat", new string[] {"c", String.Empty, "c"}),
       new RegexTestCase(@"^([a-z]*?)([\w])$",  RegexOptions.IgnoreCase, "cat", new string[] {"cat", "ca", "t"}),

        // TODO: Come up with more scenarios here

        /*********************************************************
        Backtracking
        *********************************************************/
       new RegexTestCase(@"([a-z]*)([\w])",  RegexOptions.IgnoreCase, "cat", new string[] {"cat", "ca", "t"}),
       new RegexTestCase(@"^([a-z]*)([\w])$",  RegexOptions.IgnoreCase, "cat", new string[] {"cat", "ca", "t"}),

        // TODO: Come up with more scenarios here

        /*********************************************************
        Character Escapes Invalid Regular Expressions
        *********************************************************/
       new RegexTestCase(@"\u", typeof(ArgumentException)),
       new RegexTestCase(@"\ua", typeof(ArgumentException)),
       new RegexTestCase(@"\u0", typeof(ArgumentException)),
       new RegexTestCase(@"\x", typeof(ArgumentException)),
       new RegexTestCase(@"\x2", typeof(ArgumentException)),

        /*********************************************************
        Character class Invalid Regular Expressions
        *********************************************************/
       new RegexTestCase(@"[", typeof(ArgumentException)),
       new RegexTestCase(@"[]", typeof(ArgumentException)),
       new RegexTestCase(@"[a", typeof(ArgumentException)),
       new RegexTestCase(@"[^", typeof(ArgumentException)),
       new RegexTestCase(@"[cat", typeof(ArgumentException)),
       new RegexTestCase(@"[^cat", typeof(ArgumentException)),
       new RegexTestCase(@"[a-", typeof(ArgumentException)),
       new RegexTestCase(@"[a-]+", "ba-b", new string[] {"a-"}),
       new RegexTestCase(@"\p{", typeof(ArgumentException)),
       new RegexTestCase(@"\p{cat", typeof(ArgumentException)),
       new RegexTestCase(@"\p{cat}", typeof(ArgumentException)),
       new RegexTestCase(@"\P{", typeof(ArgumentException)),
       new RegexTestCase(@"\P{cat", typeof(ArgumentException)),
       new RegexTestCase(@"\P{cat}", typeof(ArgumentException)),

        /*********************************************************
        Quantifiers
        *********************************************************/
       new RegexTestCase(@"(cat){", "cat{", new string[] {"cat{", "cat"}),
       new RegexTestCase(@"(cat){}", "cat{}", new string[] {"cat{}", "cat"}),
       new RegexTestCase(@"(cat){,", "cat{,", new string[] {"cat{,", "cat"}),
       new RegexTestCase(@"(cat){,}", "cat{,}", new string[] {"cat{,}", "cat"}),
       new RegexTestCase(@"(cat){cat}", "cat{cat}", new string[] {"cat{cat}", "cat"}),
       new RegexTestCase(@"(cat){cat,5}", "cat{cat,5}", new string[] {"cat{cat,5}", "cat"}),
       new RegexTestCase(@"(cat){5,dog}", "cat{5,dog}", new string[] {"cat{5,dog}", "cat"}),
       new RegexTestCase(@"(cat){cat,dog}", "cat{cat,dog}", new string[] {"cat{cat,dog}", "cat"}),
       new RegexTestCase(@"(cat){,}?", "cat{,}?", new string[] {"cat{,}", "cat"}),
       new RegexTestCase(@"(cat){cat}?", "cat{cat}?", new string[] {"cat{cat}", "cat"}),
       new RegexTestCase(@"(cat){cat,5}?", "cat{cat,5}?", new string[] {"cat{cat,5}", "cat"}),
       new RegexTestCase(@"(cat){5,dog}?", "cat{5,dog}?", new string[] {"cat{5,dog}", "cat"}),
       new RegexTestCase(@"(cat){cat,dog}?", "cat{cat,dog}?", new string[] {"cat{cat,dog}", "cat"}),

        /*********************************************************
        Grouping Constructs Invalid Regular Expressions
        *********************************************************/
       new RegexTestCase(@"(", typeof(ArgumentException)),
       new RegexTestCase(@"(?", typeof(ArgumentException)),
       new RegexTestCase(@"(?<", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>", typeof(ArgumentException)),
       new RegexTestCase(@"(?'", typeof(ArgumentException)),
       new RegexTestCase(@"(?'cat'", typeof(ArgumentException)),
       new RegexTestCase(@"(?:", typeof(ArgumentException)),
       new RegexTestCase(@"(?imn", typeof(ArgumentException)),
       new RegexTestCase(@"(?imn )", typeof(ArgumentException)),
       new RegexTestCase(@"(?=", typeof(ArgumentException)),
       new RegexTestCase(@"(?!", typeof(ArgumentException)),
       new RegexTestCase(@"(?<=", typeof(ArgumentException)),
       new RegexTestCase(@"(?<!", typeof(ArgumentException)),
       new RegexTestCase(@"(?>", typeof(ArgumentException)),

       new RegexTestCase(@"()", "cat", new string[] {String.Empty, String.Empty}),
       new RegexTestCase(@"(?)", typeof(ArgumentException)),
       new RegexTestCase(@"(?<)", typeof(ArgumentException)),
       new RegexTestCase(@"(?<cat>)", "cat", new string[] {String.Empty, String.Empty}),
       new RegexTestCase(@"(?')", typeof(ArgumentException)),
       new RegexTestCase(@"(?'cat')", "cat", new string[] {String.Empty, String.Empty}),
       new RegexTestCase(@"(?:)", "cat", new string[] {String.Empty}),
       new RegexTestCase(@"(?imn)", "cat", new string[] {String.Empty}),
       new RegexTestCase(@"(?imn)cat", "(?imn)cat", new string[] {"cat"}),
       new RegexTestCase(@"(?=)", "cat", new string[] {String.Empty}),
       new RegexTestCase(@"(?!)", "(?!)cat"),
       new RegexTestCase(@"(?<=)", "cat", new string[] {String.Empty}),
       new RegexTestCase(@"(?<!)", "(?<!)cat"),
       new RegexTestCase(@"(?>)", "cat", new string[] {String.Empty}),

        /*********************************************************
        Grouping Constructs Invalid Regular Expressions
        *********************************************************/
       new RegexTestCase(@"\1", typeof(ArgumentException)),
       new RegexTestCase(@"\1", typeof(ArgumentException)),
       new RegexTestCase(@"\k", typeof(ArgumentException)),
       new RegexTestCase(@"\k<", typeof(ArgumentException)),
       new RegexTestCase(@"\k<1", typeof(ArgumentException)),
       new RegexTestCase(@"\k<cat", typeof(ArgumentException)),
       new RegexTestCase(@"\k<>", typeof(ArgumentException)),

        /*********************************************************
        Alternation construct Invalid Regular Expressions
        *********************************************************/
       new RegexTestCase(@"(?(", typeof(ArgumentException)),
       new RegexTestCase(@"(?()|", typeof(ArgumentException)),
       new RegexTestCase(@"(?()|)", "(?()|)", new string[] {""}),

       new RegexTestCase(@"(?(cat", typeof(ArgumentException)),
       new RegexTestCase(@"(?(cat)|", typeof(ArgumentException)),

       new RegexTestCase(@"(?(cat)|)", "cat", new string[] {""}),
       new RegexTestCase(@"(?(cat)|)", "dog", new string[] {""}),

       new RegexTestCase(@"(?(cat)catdog|)", "catdog", new string[] {"catdog"}),
       new RegexTestCase(@"(?(cat)catdog|)", "dog", new string[] {""}),
       new RegexTestCase(@"(?(cat)dog|)", "dog", new string[] {""}),
       new RegexTestCase(@"(?(cat)dog|)", "cat", new string[] {""}),

       new RegexTestCase(@"(?(cat)|catdog)", "cat", new string[] {""}),
       new RegexTestCase(@"(?(cat)|catdog)", "catdog", new string[] {""}),
       new RegexTestCase(@"(?(cat)|dog)", "dog", new string[] {"dog"}),
       new RegexTestCase(@"(?(cat)|dog)", "oof"),

        /*********************************************************
        Empty Match
        *********************************************************/
       new RegexTestCase(@"([a*]*)+?$", "ab", new string[] {"", ""}),
       new RegexTestCase(@"(a*)+?$", "b", new string[] {"", ""}),
    };
}


text:
///ts:import=Visitor
import Visitor = require('./Visitor'); ///ts:import:generated

class WebsiteVisitor implements Visitor {
    constructor(private email: string, private admin: boolean) {
    }

    public isAdmin(): boolean {
        return this.admin;
    }

    public getEmail(): string {
        return this.email;
    }
}
export = WebsiteVisitor;