blob: 6a03f528eed3b248da7b762dbf826b6ca50d514a [file] [log] [blame]
/*********************************************************************
* Copyright (c) 2018 The University of York.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipse.epsilon.evl.engine.test.acceptance.analysis;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.eclipse.epsilon.evl.EvlModule;
import org.eclipse.epsilon.evl.IEvlModule;
import org.eclipse.epsilon.evl.dom.Constraint;
import org.eclipse.epsilon.evl.engine.test.acceptance.EvlTests;
import org.eclipse.epsilon.evl.graph.EvlGraph;
/**
*
* @author Sina Madani
* @since 1.6
*/
@RunWith(Parameterized.class)
public class EvlGraphTests {
EvlGraph graph;
@Parameter
public IEvlModule module;
@Parameters(name = "{0}")
public static Iterable<? extends IEvlModule> modules() {
return Arrays.asList(
new EvlModule()
/*new EvlModuleParallelGraph(),
new EvlModuleParallelGraph(new EvlContextParallel(1))*/
);
}
@Before
public void setUp() throws Exception {
EvlTests.loadEVL(module, false);
graph = new EvlGraph(module.getContext());
graph.addConstraintContexts(module.getConstraintContexts());
}
@Test
public void testConstraintsDependedOn() {
Set<String>
actualDependencies = graph.getConstraintsDependedOn().stream().map(Constraint::toString).collect(Collectors.toSet()),
expectedDependencies = new HashSet<>(Arrays.asList(
"LazyAlwaysFalseOperation",
"AlwaysTrueOperation",
"AlwaysFalseOperation",
"LazyContextlessDependedOn",
"RequiresContextlessLazy",
"LazyContextlessCallsLazy",
"LazyWithGuard",
"AlwaysFalse"
));
assertEquals("Correctly identifies all constraints depended upon", expectedDependencies, actualDependencies);
}
@Test
public void testConstraintSequence() {
List<String>
actualSequence = graph.getConstraintSequence().stream().map(Constraint::toString).collect(Collectors.toList()),
expectedSequence = Arrays.asList(
//insert optimal order here...
);
assertEquals("Expected constraints order", expectedSequence, actualSequence);
}
}