package gradeCount;

import static org.junit.Assert.assertFalse;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;

import org.junit.BeforeClass;
import org.junit.Test;

import config.Example;
import edu.udel.cis.vsl.tass.config.CompareConfiguration;
import edu.udel.cis.vsl.tass.front.minimp.ModelExtractor;
import edu.udel.cis.vsl.tass.front.minimp.ModelPair;
import edu.udel.cis.vsl.tass.model.IF.ModelIF;
import edu.udel.cis.vsl.tass.verify.Comparison;

/**
 * The two versions differ. The error is hard to detect with usual depth first
 * search methods because of a blowup in the state space due to a number of
 * nondeterministic choices. However it can be found quickly with the loop
 * technique.
 */
public class GradeCountTest {
	private static ModelIF specModel, implModel;
	private static CompareConfiguration compareConfiguration;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		ModelPair pair;
		File rootDirectory = new File(Example.exampleDirectory, "gradeCount");

		compareConfiguration = new CompareConfiguration(new File(rootDirectory,
				"TASSREP"));

		compareConfiguration.setLoopTechnique(true);
		compareConfiguration.setSpecSourceFile(new File(rootDirectory,
				"gradeCountSpec.c"));
		compareConfiguration.setImplSourceFile(new File(rootDirectory,
				"gradeCountImpl.c"));
		compareConfiguration.setSpecNumProcs(1);
		compareConfiguration.setImplNumProcs(1);
		compareConfiguration.setSpecModelName("gradeCountSpec");
		compareConfiguration.setImplModelName("gradeCountImpl");
		pair = ModelExtractor.extractModelPair(compareConfiguration);
		specModel = pair.spec();
		implModel = pair.impl();
	}

	@Test
	public void testCompare() throws FileNotFoundException {
		assertFalse(Comparison.compare(specModel, implModel,
				compareConfiguration, true));
	}
}
