]> gerrit.simantics Code Review - simantics/platform.git/blob
a6aad45cc831ce1acfc69685202274ad0cc43a7f
[simantics/platform.git] /
1 package org.simantics.scl.compiler.tests.unit;
2
3 import org.junit.Test;
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;
13
14 public class TestConstraintSolver {
15     
16     public final TCon COLLECTION = Types.con("Collection", "Collection");
17             
18     @Test
19     public void testConstraintSolver() throws Exception {
20         EnvironmentSpecification environmentSpecification = new EnvironmentSpecification();
21         environmentSpecification.importModule("Builtin", "");
22         environmentSpecification.importModule("Prelude", "");
23         environmentSpecification.importModule("Collection", "");
24         
25         Environment environment = TestBase.PRELUDE_MODULE_REPOSITORY
26                 .createRuntimeEnvironment(environmentSpecification,
27                         getClass().getClassLoader()).getEnvironment();
28         
29         ConstraintSolver solver = new ConstraintSolver(environment);
30         
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);
34         
35         solver.print();
36     }
37     
38 }