]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.compiler/tests/org/simantics/graph/compiler/tests/GraphCompilerTests.java
Removed org.simantics.ltk[.antlr] bundles, exact import for antlr
[simantics/platform.git] / bundles / org.simantics.graph.compiler / tests / org / simantics / graph / compiler / tests / GraphCompilerTests.java
index 7c5a07cb208bf747aef7f3d4f1bc736adb86fffb..7f004a5fe97c866527db0ede094c91f013d9beb6 100644 (file)
@@ -1,73 +1,73 @@
-package org.simantics.graph.compiler.tests;\r
-\r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.simantics.graph.compiler.CompilationResult;\r
-import org.simantics.graph.compiler.ExternalFileLoader;\r
-import org.simantics.graph.compiler.GraphCompiler;\r
-import org.simantics.graph.compiler.GraphCompilerPreferences;\r
-import org.simantics.graph.representation.TransferableGraph1;\r
-import org.simantics.ltk.ISource;\r
-import org.simantics.ltk.LocalResourceSource;\r
-\r
-public class GraphCompilerTests {\r
-    \r
-    @Before\r
-    public void initialize() {\r
-        \r
-    }\r
-    \r
-    public CompilationResult compile(String source) throws Exception {\r
-        ArrayList<ISource> sources = new ArrayList<ISource>();\r
-        sources.add(new LocalResourceSource(GraphCompilerTests.class, source));\r
-        ArrayList<TransferableGraph1> dependencies = new ArrayList<TransferableGraph1>();\r
-        dependencies.add(GraphCompiler.read(GraphCompilerTests.class.getResourceAsStream("graph.tg")));\r
-        ExternalFileLoader fileLoader = new ExternalFileLoader() {                  \r
-            @Override\r
-            public byte[] load(String fileName) throws IOException {\r
-                throw new FileNotFoundException();\r
-            }\r
-        };\r
-        GraphCompilerPreferences preferences = new GraphCompilerPreferences();\r
-        preferences.validate = true;\r
-        return GraphCompiler.compile(\r
-                "1.0",\r
-                sources, \r
-                dependencies, \r
-                fileLoader,\r
-                preferences);\r
-    }\r
-    \r
-    @Test\r
-    public void testUndefinedVariable() throws Exception {\r
-        CompilationResult result = compile("graphs/UndefinedVariable.pgraph");\r
-        Assert.assertEquals(1, result.getErrors().size());\r
-    }\r
-    \r
-    @Test\r
-    public void testUndefinedConcept() throws Exception {\r
-        CompilationResult result = compile("graphs/UndefinedConcept.pgraph");\r
-        Assert.assertEquals(1, result.getErrors().size());\r
-    }\r
-    \r
-    @Test\r
-    public void testDomainAndRangeSyntax() throws Exception {\r
-        CompilationResult result = compile("graphs/DomainAndRangeSyntax.pgraph");\r
-        Assert.assertEquals(0, result.getErrors().size());\r
-    }\r
-    \r
-    @Test\r
-    public void testLists() throws Exception {\r
-        CompilationResult result = compile("graphs/Lists.pgraph");\r
-        Assert.assertEquals(0, result.getErrors().size());\r
-        Assert.assertEquals(3 /*InstanceOf*/ + 2 /*Element*/ + 3 /*Next*/, \r
-                result.getGraph().statements.length/4);\r
-        result.getGraph().print();\r
-    }\r
-}\r
+package org.simantics.graph.compiler.tests;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+
+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.compiler.internal.ltk.ISource;
+import org.simantics.graph.compiler.internal.ltk.LocalResourceSource;
+import org.simantics.graph.representation.TransferableGraph1;
+
+import junit.framework.Assert;
+
+public class GraphCompilerTests {
+    
+    @Before
+    public void initialize() {
+        
+    }
+    
+    public CompilationResult compile(String source) throws Exception {
+        ArrayList<ISource> sources = new ArrayList<ISource>();
+        sources.add(new LocalResourceSource(GraphCompilerTests.class, source));
+        ArrayList<TransferableGraph1> dependencies = new ArrayList<TransferableGraph1>();
+        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();
+    }
+}