1 package org.simantics.scl.compiler.tests.unit;
4 import org.simantics.scl.compiler.environment.Environment;
5 import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification;
6 import org.simantics.scl.compiler.errors.Locations;
7 import org.simantics.scl.compiler.internal.elaboration.constraints2.ConstraintSolver;
8 import org.simantics.scl.compiler.tests.TestBase;
9 import org.simantics.scl.compiler.types.TCon;
10 import org.simantics.scl.compiler.types.TMetaVar;
11 import org.simantics.scl.compiler.types.Types;
12 import org.simantics.scl.compiler.types.kinds.Kinds;
14 public class TestConstraintSolver {
16 public final TCon COLLECTION = Types.con("Collection", "Collection");
19 public void testConstraintSolver() throws Exception {
20 EnvironmentSpecification environmentSpecification = new EnvironmentSpecification();
21 environmentSpecification.importModule("Builtin", "");
22 environmentSpecification.importModule("Prelude", "");
23 environmentSpecification.importModule("Collection", "");
25 Environment environment = TestBase.PRELUDE_MODULE_REPOSITORY
26 .createRuntimeEnvironment(environmentSpecification,
27 getClass().getClassLoader()).getEnvironment();
29 ConstraintSolver solver = new ConstraintSolver(environment);
31 TMetaVar a = Types.metaVar(Kinds.STAR);
32 TMetaVar b = Types.metaVar(Kinds.STAR);
33 solver.addDemand(Types.pred(COLLECTION, Types.list(a), b), Locations.NO_LOCATION);