X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.graph.compiler%2Ftests%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Ftests%2FGraphCompilerTests.java;h=c0e328d04a0e6dda87000fb351a2bb6426fd462b;hb=refs%2Fchanges%2F38%2F238%2F2;hp=7c5a07cb208bf747aef7f3d4f1bc736adb86fffb;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.graph.compiler/tests/org/simantics/graph/compiler/tests/GraphCompilerTests.java b/bundles/org.simantics.graph.compiler/tests/org/simantics/graph/compiler/tests/GraphCompilerTests.java index 7c5a07cb2..c0e328d04 100644 --- a/bundles/org.simantics.graph.compiler/tests/org/simantics/graph/compiler/tests/GraphCompilerTests.java +++ b/bundles/org.simantics.graph.compiler/tests/org/simantics/graph/compiler/tests/GraphCompilerTests.java @@ -1,73 +1,73 @@ -package org.simantics.graph.compiler.tests; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; - -import junit.framework.Assert; - -import org.junit.Before; -import org.junit.Test; -import org.simantics.graph.compiler.CompilationResult; -import org.simantics.graph.compiler.ExternalFileLoader; -import org.simantics.graph.compiler.GraphCompiler; -import org.simantics.graph.compiler.GraphCompilerPreferences; -import org.simantics.graph.representation.TransferableGraph1; -import org.simantics.ltk.ISource; -import org.simantics.ltk.LocalResourceSource; - -public class GraphCompilerTests { - - @Before - public void initialize() { - - } - - public CompilationResult compile(String source) throws Exception { - ArrayList sources = new ArrayList(); - sources.add(new LocalResourceSource(GraphCompilerTests.class, source)); - ArrayList dependencies = new ArrayList(); - dependencies.add(GraphCompiler.read(GraphCompilerTests.class.getResourceAsStream("graph.tg"))); - ExternalFileLoader fileLoader = new ExternalFileLoader() { - @Override - public byte[] load(String fileName) throws IOException { - throw new FileNotFoundException(); - } - }; - GraphCompilerPreferences preferences = new GraphCompilerPreferences(); - preferences.validate = true; - return GraphCompiler.compile( - "1.0", - sources, - dependencies, - fileLoader, - preferences); - } - - @Test - public void testUndefinedVariable() throws Exception { - CompilationResult result = compile("graphs/UndefinedVariable.pgraph"); - Assert.assertEquals(1, result.getErrors().size()); - } - - @Test - public void testUndefinedConcept() throws Exception { - CompilationResult result = compile("graphs/UndefinedConcept.pgraph"); - Assert.assertEquals(1, result.getErrors().size()); - } - - @Test - public void testDomainAndRangeSyntax() throws Exception { - CompilationResult result = compile("graphs/DomainAndRangeSyntax.pgraph"); - Assert.assertEquals(0, result.getErrors().size()); - } - - @Test - public void testLists() throws Exception { - CompilationResult result = compile("graphs/Lists.pgraph"); - Assert.assertEquals(0, result.getErrors().size()); - Assert.assertEquals(3 /*InstanceOf*/ + 2 /*Element*/ + 3 /*Next*/, - result.getGraph().statements.length/4); - result.getGraph().print(); - } -} +package org.simantics.graph.compiler.tests; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; + +import junit.framework.Assert; + +import org.junit.Before; +import org.junit.Test; +import org.simantics.graph.compiler.CompilationResult; +import org.simantics.graph.compiler.ExternalFileLoader; +import org.simantics.graph.compiler.GraphCompiler; +import org.simantics.graph.compiler.GraphCompilerPreferences; +import org.simantics.graph.representation.TransferableGraph1; +import org.simantics.ltk.ISource; +import org.simantics.ltk.LocalResourceSource; + +public class GraphCompilerTests { + + @Before + public void initialize() { + + } + + public CompilationResult compile(String source) throws Exception { + ArrayList sources = new ArrayList(); + sources.add(new LocalResourceSource(GraphCompilerTests.class, source)); + ArrayList dependencies = new ArrayList(); + dependencies.add(GraphCompiler.read(GraphCompilerTests.class.getResourceAsStream("graph.tg"))); + ExternalFileLoader fileLoader = new ExternalFileLoader() { + @Override + public byte[] load(String fileName) throws IOException { + throw new FileNotFoundException(); + } + }; + GraphCompilerPreferences preferences = new GraphCompilerPreferences(); + preferences.validate = true; + return GraphCompiler.compile( + "1.0", + sources, + dependencies, + fileLoader, + preferences); + } + + @Test + public void testUndefinedVariable() throws Exception { + CompilationResult result = compile("graphs/UndefinedVariable.pgraph"); + Assert.assertEquals(1, result.getErrors().size()); + } + + @Test + public void testUndefinedConcept() throws Exception { + CompilationResult result = compile("graphs/UndefinedConcept.pgraph"); + Assert.assertEquals(1, result.getErrors().size()); + } + + @Test + public void testDomainAndRangeSyntax() throws Exception { + CompilationResult result = compile("graphs/DomainAndRangeSyntax.pgraph"); + Assert.assertEquals(0, result.getErrors().size()); + } + + @Test + public void testLists() throws Exception { + CompilationResult result = compile("graphs/Lists.pgraph"); + Assert.assertEquals(0, result.getErrors().size()); + Assert.assertEquals(3 /*InstanceOf*/ + 2 /*Element*/ + 3 /*Next*/, + result.getGraph().statements.length/4); + result.getGraph().print(); + } +}