Ignore:
Timestamp:
12/21/05 11:21:12 (19 years ago)
Author:
boris
Message:
  • moved out code that handles communication with OMC to a separate plugin
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestProxyParser.java

    r215 r240  
    4242package org.modelica.mdt.test;
    4343
    44 import java.util.Vector;
    45 
    46 import org.modelica.mdt.internal.omcproxy.CompileError;
    47 import org.modelica.mdt.internal.omcproxy.ProxyParser;
    48 import org.modelica.mdt.internal.omcproxy.UnexpectedReplyException;
     44import org.modelica.mdt.compiler.ICompileError;
     45import org.modelica.mdt.compiler.UnexpectedReplyException;
     46import org.modelica.mdt.omc.internal.OMCParser;
    4947
    5048import junit.framework.TestCase;
    5149
    5250/**
    53  * Test various methods in org.modelica.mdt.internal.omcproxy.ProxyParser
     51 * Test various methods in org.modelica.mdt.omc.internal.OMCParser
    5452 * @author Elmir Jagudin
    5553 */
     
    5856
    5957    /**
    60      * test parsing some single nested lists with ProxyParser.parseList()
    61      */
    62     public void testParseSimpleList()
    63     {
    64         /*
    65          * some combinations of empty lists
    66          */
    67         Vector<Object> res;
    68        
    69         res = ProxyParser.parseList("{}");
    70         assertEquals(0, res.size());
    71    
    72         res = ProxyParser.parseList("{ }");
    73         assertEquals(0, res.size());
    74        
    75         res = ProxyParser.parseList("{    }");
    76         assertEquals(0, res.size());
    77 
    78        
    79         res = ProxyParser.parseList("{ \n}");
    80         assertEquals(0, res.size());
    81        
    82         res = ProxyParser.parseList("{   \n    }");
    83         assertEquals(0, res.size());
    84 
    85         /*
    86          * single element lists
    87          */
    88         res = ProxyParser.parseList("{hej}");
    89         assertEquals(1, res.size());
    90         assertEquals("hej", (String)res.elementAt(0));
    91        
    92         res = ProxyParser.parseList("{  muu}");
    93         assertEquals(1,res.size());
    94         assertEquals("muu", (String)res.elementAt(0));
    95        
    96         res = ProxyParser.parseList("{  muu   }");
    97         assertEquals(1, res.size());
    98         assertEquals("muu", (String)res.elementAt(0));
    99 
    100         res = ProxyParser.parseList("{muu   }");
    101         assertEquals(1, res.size());
    102         assertEquals("muu", (String)res.elementAt(0));
    103 
    104 
    105         /*
    106          * two element lists
    107          */
    108         res = ProxyParser.parseList("{hej,peter}");
    109         assertEquals(2, res.size());
    110         assertEquals("hej", (String)res.elementAt(0));
    111         assertEquals("peter", (String)res.elementAt(1));
    112        
    113         res = ProxyParser.parseList("{peter,  labb}");
    114         assertEquals("peter", (String)res.elementAt(0));
    115         assertEquals("labb", (String)res.elementAt(1));
    116        
    117         res = ProxyParser.parseList("{peter ,labb}");
    118         assertEquals("peter", (String)res.elementAt(0));
    119         assertEquals("labb", (String)res.elementAt(1));
    120        
    121         res = ProxyParser.parseList("{peter   ,labb}");
    122         assertEquals("peter", (String)res.elementAt(0));
    123         assertEquals("labb", (String)res.elementAt(1));
    124        
    125         /*
    126          * tree elements list
    127          */
    128         res = ProxyParser.parseList("{alan, l, cox}");
    129         assertEquals(3, res.size());
    130         assertEquals("alan", (String)res.elementAt(0));
    131         assertEquals("l", (String)res.elementAt(1));
    132         assertEquals("cox", (String)res.elementAt(2));
    133        
    134         res = ProxyParser.parseList("{alan,l,cox}");
    135         assertEquals(3, res.size());
    136         assertEquals("alan", (String)res.elementAt(0));
    137         assertEquals("l", (String)res.elementAt(1));
    138         assertEquals("cox", (String)res.elementAt(2));
    139 
    140     }
    141    
    142     public void testParseList()
    143     {
    144         Vector v = ProxyParser.parseList("{{a    ,b   }  ,   c   }");
    145         assertTrue(v.get(0) instanceof Vector);
    146         assertTrue(v.size() == 2);
    147         assertTrue(((Vector)v.get(0)).get(0).equals("a"));
    148         assertTrue(((Vector)v.get(0)).get(1).equals("b"));
    149         assertTrue(v.get(1).equals("c"));
    150        
    151         v = ProxyParser.parseList("{a, b, c}");
    152         assertTrue(v.size() == 3);
    153         assertTrue(v.get(0).equals("a"));
    154         assertTrue(v.get(1).equals("b"));
    155         assertTrue(v.get(2).equals("c"));
    156        
    157         v = ProxyParser.parseList("{a, b, c={a, b, c}}");
    158         assertTrue(v.size() == 3);
    159         assertTrue(v.get(0).equals("a"));
    160         assertTrue(v.get(1).equals("b"));
    161         assertTrue(v.get(2).equals("c={a, b, c}"));
    162        
    163         v = ProxyParser.parseList("{,,}");
    164         assertTrue(v.size() == 0);
    165        
    166         v = ProxyParser.parseList("{foo={bar, gzonk}}");
    167         assertTrue(v.size() == 1);
    168         assertTrue(v.get(0).equals("foo={bar, gzonk}"));
    169     }
    170                
    171 
    172 
    173     /**
    174      * Test if ProxyParser.parseErrorString() works as prescribed.
     58     * Test if OMCParser.parseErrorString() works as prescribed.
    17559     * @throws UnexpectedReplyException
    17660     */
     
    18266            String errorString =
    18367                "[c:/folde/hej.mo:2:1]: error: unexpected tooken: muu\n";
    184             CompileError[] errors = ProxyParser.parseErrorString(errorString);
     68            ICompileError[] errors = OMCParser.parseErrorString(errorString);
    18569   
    18670            assertEquals(1, errors.length);     
    187             CompileError error = errors[0];
     71            ICompileError error = errors[0];
    18872            assertEquals(2, error.getLine());
    18973            assertEquals("unexpected tooken: muu", error.getErrorDescription());
     
    19377                "[c:/folder he/hej.mo:4:1]: error: unexpected end of file\n" +
    19478                "[c:/folder he/hej.mo:15:1]: error: hej remar\n";
    195             errors = ProxyParser.parseErrorString(errorString);
     79            errors = OMCParser.parseErrorString(errorString);
    19680            assertEquals(2, errors.length);
    19781           
     
    20791            errorString =
    20892                "[/usr/folde/hej.mo:12:1]: error: unexpected tooken: muu\n";
    209             errors = ProxyParser.parseErrorString(errorString);
     93            errors = OMCParser.parseErrorString(errorString);
    21094   
    21195            assertEquals(1, errors.length);     
     
    218102                "[/hej/hop/hej.mo:453:1]: error: unexpected end of file\n" +
    219103                "[/usr/local/modelica/hej.mo:715:1]: error: hej remar\n";
    220             errors = ProxyParser.parseErrorString(errorString);
     104            errors = OMCParser.parseErrorString(errorString);
    221105            assertEquals(2, errors.length);
    222106           
     
    230114   
    231115            /* no errors aka empty error string */
    232             errors = ProxyParser.parseErrorString("");
     116            errors = OMCParser.parseErrorString("");
    233117            assertEquals(0, errors.length);
    234118        }
Note: See TracChangeset for help on using the changeset viewer.