- Timestamp:
- 12/21/05 11:21:12 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestOMCProxy.java
r228 r240 48 48 import org.eclipse.core.resources.IProject; 49 49 import org.modelica.mdt.core.IModelicaClass.Type; 50 import org.modelica.mdt.internal.core.ElementLocation; 51 import org.modelica.mdt.internal.omcproxy.ConnectException; 52 import org.modelica.mdt.internal.omcproxy.InvocationError; 53 import org.modelica.mdt.internal.omcproxy.OMCProxy; 54 import org.modelica.mdt.internal.omcproxy.UnexpectedReplyException; 50 import org.modelica.mdt.compiler.CompilerInstantiationException; 51 import org.modelica.mdt.compiler.ConnectException; 52 import org.modelica.mdt.compiler.IElementLocation; 53 import org.modelica.mdt.compiler.InvocationError; 54 import org.modelica.mdt.compiler.UnexpectedReplyException; 55 import org.modelica.mdt.internal.compiler.CompilerProxy; 55 56 import org.modelica.mdt.test.util.Area51Projects; 56 57 import org.modelica.mdt.test.util.Utility; … … 65 66 private IFile nested_models_mo; 66 67 67 protected void setUp() throws ConnectException 68 protected void setUp() 69 throws ConnectException, CompilerInstantiationException 68 70 { 69 71 Area51Projects.createProjects(); … … 90 92 91 93 /* we need to load modelica package */ 92 OMCProxy.loadSystemLibrary();94 CompilerProxy.loadSystemLibrary(); 93 95 } 94 96 95 97 /** 96 98 * test OMCProxy.getRestrictionType() 99 * @throws CompilerInstantiationException 97 100 */ 98 101 public void testGetRestrictionType() 99 throws ConnectException, UnexpectedReplyException 102 throws ConnectException, UnexpectedReplyException, 103 CompilerInstantiationException 100 104 { 101 if ( OMCProxy.getRestrictionType("Modelica") != Type.PACKAGE)105 if (CompilerProxy.getRestrictionType("Modelica") != Type.PACKAGE) 102 106 { 103 107 fail("Modelica class' restriction type is wrong"); 104 108 } 105 if ( OMCProxy.getRestrictionType("Modelica.Blocks.Examples.BusUsage")109 if (CompilerProxy.getRestrictionType("Modelica.Blocks.Examples.BusUsage") 106 110 != Type.MODEL) 107 111 { … … 109 113 "restriction type is wrong"); 110 114 } 111 if ( OMCProxy.getRestrictionType("Modelica.Math.log")115 if (CompilerProxy.getRestrictionType("Modelica.Math.log") 112 116 != Type.FUNCTION) 113 117 { 114 118 fail("Modelica.Math.log class' restriction type is wrong"); 115 119 } 116 if ( OMCProxy.getRestrictionType("Modelica.Icons.Record")120 if (CompilerProxy.getRestrictionType("Modelica.Icons.Record") 117 121 != Type.RECORD) 118 122 { 119 123 fail("Modelica.Icons.Record class' restriction type is wrong"); 120 124 } 121 if ( OMCProxy.getRestrictionType("Modelica.Electrical.Analog.Interfaces.Pin")125 if (CompilerProxy.getRestrictionType("Modelica.Electrical.Analog.Interfaces.Pin") 122 126 != Type.CONNECTOR) 123 127 { … … 125 129 "restriction type is wrong"); 126 130 } 127 if ( OMCProxy.getRestrictionType("Modelica.Blocks.Continuous.Der")131 if (CompilerProxy.getRestrictionType("Modelica.Blocks.Continuous.Der") 128 132 != Type.BLOCK) 129 133 { … … 131 135 "restriction type is wrong"); 132 136 } 133 if ( OMCProxy.getRestrictionType("Modelica.SIunits.Lethargy")137 if (CompilerProxy.getRestrictionType("Modelica.SIunits.Lethargy") 134 138 != Type.TYPE) 135 139 { … … 137 141 } 138 142 139 OMCProxy.loadFileInteractive(nested_models_mo);140 if ( OMCProxy.getRestrictionType("hepp.hehehe")143 CompilerProxy.loadFileInteractive(nested_models_mo); 144 if (CompilerProxy.getRestrictionType("hepp.hehehe") 141 145 != Type.CLASS) 142 146 { … … 144 148 } 145 149 } 146 147 // /**148 // * test OMCProxy.getPackages()149 // */150 // public void testGetPackages() throws CompilerException151 // {152 // OMCProxy.loadSystemLibrary();153 // String[] str = OMCProxy.getPackages("Modelica");154 //155 // assertNotNull("Could not fetch Modelica package", str);156 //157 // Vector<String> packages = new Vector<String>();158 // for(String s : str)159 // {160 // packages.addElement(s);161 // }162 //163 // assertTrue(packages.containsAll(modelicaLibraryPackages));164 // }165 150 166 151 /** 167 152 * test OMCProxy.getElementLocation() 153 * @throws CompilerInstantiationException 168 154 */ 169 155 public void testGetElementLocation() 170 throws ConnectException, UnexpectedReplyException, InvocationError 156 throws ConnectException, UnexpectedReplyException, InvocationError, 157 CompilerInstantiationException 171 158 { 172 OMCProxy.loadFileInteractive(nested_models_mo);159 CompilerProxy.loadFileInteractive(nested_models_mo); 173 160 174 161 /* 175 162 * we are basicaly only interested in getting the right line number 176 163 */ 177 ElementLocation loc = OMCProxy.getElementLocation("nested_models");164 IElementLocation loc = CompilerProxy.getElementLocation("nested_models"); 178 165 assertTrue(loc.getPath().endsWith("nested_models.mo")); 179 166 assertEquals(loc.getLine(), 1); 180 167 181 loc = OMCProxy.getElementLocation("nested_models.hepp");168 loc = CompilerProxy.getElementLocation("nested_models.hepp"); 182 169 assertEquals(loc.getLine(), 3); 183 170 184 loc = OMCProxy.getElementLocation("nested_models.foo");171 loc = CompilerProxy.getElementLocation("nested_models.foo"); 185 172 assertEquals(loc.getLine(), 4); 186 173 187 loc = OMCProxy.getElementLocation("nested_models.foo.bar");174 loc = CompilerProxy.getElementLocation("nested_models.foo.bar"); 188 175 assertEquals(loc.getLine(), 5); 189 176 190 loc = OMCProxy.getElementLocation("muu");177 loc = CompilerProxy.getElementLocation("muu"); 191 178 assertEquals(loc.getLine(), 8); 192 179 193 loc = OMCProxy.getElementLocation("foo");180 loc = CompilerProxy.getElementLocation("foo"); 194 181 assertEquals(loc.getLine(), 14); 195 182 196 loc = OMCProxy.getElementLocation("hej");183 loc = CompilerProxy.getElementLocation("hej"); 197 184 assertEquals(loc.getLine(), 19); 198 185 199 loc = OMCProxy.getElementLocation("hej.ine_paketen");186 loc = CompilerProxy.getElementLocation("hej.ine_paketen"); 200 187 assertEquals(loc.getLine(), 20); 201 188 202 loc = OMCProxy.getElementLocation("hej.hejhej");189 loc = CompilerProxy.getElementLocation("hej.hejhej"); 203 190 assertEquals(loc.getLine(), 22); 204 191 205 loc = OMCProxy.getElementLocation("hej.hejhej.foo");192 loc = CompilerProxy.getElementLocation("hej.hejhej.foo"); 206 193 assertEquals(loc.getLine(), 23); 207 194 208 loc = OMCProxy.getElementLocation("hepp");195 loc = CompilerProxy.getElementLocation("hepp"); 209 196 assertEquals(loc.getLine(), 30); 210 197 211 loc = OMCProxy.getElementLocation("hepp.hopp");198 loc = CompilerProxy.getElementLocation("hepp.hopp"); 212 199 assertEquals(loc.getLine(), 31); 213 200 214 loc = OMCProxy.getElementLocation("hepp.hehehe");201 loc = CompilerProxy.getElementLocation("hepp.hehehe"); 215 202 assertEquals(loc.getLine(), 33); 216 203
Note: See TracChangeset
for help on using the changeset viewer.