Changeset 2263


Ignore:
Timestamp:
Jan 21, 2007, 2:05:52 PM (14 years ago)
Author:
roman
Message:

Some refactoring

Location:
devel-tools/trunk/eclipse/org.refal.plus.comp.test/src/org/refal/plus/comp/test
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.plus.comp.test/src/org/refal/plus/comp/test/FenceAndCutCheckerTest.java

    r2256 r2263  
    88import org.refal.plus.comp.FenceAndCutChecker;
    99import org.refal.plus.comp.MsgCode;
    10 import org.refal.plus.comp.ast.AstFuncDef;
     10import org.refal.plus.comp.ast.AstImplem;
    1111
    1212public class FenceAndCutCheckerTest {
     
    2323        private static void expectOK(String input) {
    2424                MsgAccumulator msgAcc = parseAndReturnMessages(input);
    25                 assertTrue(msgAcc.messages.size() == 0);
     25                assertTrue(msgAcc.messages.isEmpty());
    2626        }
    2727
    2828        private static MsgAccumulator parseAndReturnMessages(String input) {
    2929                MsgAccumulator msgAcc = new MsgAccumulator();
    30                 AstFuncDef astFuncDef = Util.parseAndGetFuncDef(input, msgAcc);
    31                 FenceAndCutChecker fcc = new FenceAndCutChecker(msgAcc);
    32                 fcc.visit(astFuncDef.body, 0);
     30                AstImplem astImplem = Util.parseImplemString(input, msgAcc);
     31                assertTrue("Syntax is OK", msgAcc.messages.isEmpty());
     32                FenceAndCutChecker v = new FenceAndCutChecker(msgAcc);
     33                v.visit(astImplem, 0);
    3334                return msgAcc;
    3435        }
  • devel-tools/trunk/eclipse/org.refal.plus.comp.test/src/org/refal/plus/comp/test/ScannerErrorTest.java

    r2254 r2263  
    33import java.io.IOException;
    44import java.io.Reader;
     5import java.io.StringReader;
    56
    67import org.junit.After;
     
    2223                MsgAccumulator msgAcc = new MsgAccumulator();
    2324                @SuppressWarnings("unused")
    24                 Object[] actual = Util.scanString(input, msgAcc);
     25                Object[] actual = Util.scan( new StringReader(input), msgAcc);
    2526                Util.checkMsg(msgAcc, msgCode);
    2627        }
  • devel-tools/trunk/eclipse/org.refal.plus.comp.test/src/org/refal/plus/comp/test/ScannerTest.java

    r2254 r2263  
    22
    33import static org.junit.Assert.assertEquals;
     4import static org.junit.Assert.assertTrue;
    45import static org.refal.plus.comp.TkTags.COL;
    56import static org.refal.plus.comp.TkTags.COL_CURL;
     
    3637import static org.refal.plus.comp.test.Token.tWord;
    3738
     39import java.io.StringReader;
     40
    3841import org.junit.After;
    3942import org.junit.Before;
     
    5457
    5558        private void scan(String input, Object[] expected) {
    56                 Object[] actual = Util.scanString(input);
     59                MsgAccumulator msgAcc = new MsgAccumulator();
     60                Object[] actual = Util.scan(new StringReader(input), msgAcc);
     61                assertTrue(msgAcc.messages.isEmpty());
    5762                assertEquals("Tokens are OK", expected, actual);
    5863        }
     
    163168                        int[] expectedLines, int[] expectedCharStarts,
    164169                        int[] expectedCharEnds) {
    165                 Object[] actual = Util.scanString(input);
     170                MsgAccumulator msgAcc = new MsgAccumulator();
     171                Object[] actual = Util.scan(new StringReader(input), msgAcc);
     172                assertTrue(msgAcc.messages.isEmpty());
    166173                assertEquals("Tokens are OK", expected, actual);
    167174                for (int i = 0; i < actual.length; i++) {
    168175                        Token t = (Token) actual[i];
    169176                        assertEquals("Line number is OK", expectedLines[i], t.pos.line);
    170                         assertEquals("CharStart is OK", expectedCharStarts[i], t.pos.charStart);
     177                        assertEquals("CharStart is OK", expectedCharStarts[i],
     178                                        t.pos.charStart);
    171179                        assertEquals("CharEnd is OK", expectedCharEnds[i], t.pos.charEnd);
    172180                }
  • devel-tools/trunk/eclipse/org.refal.plus.comp.test/src/org/refal/plus/comp/test/Util.java

    r2254 r2263  
    1010import java.util.ArrayList;
    1111
    12 import org.refal.plus.comp.ConsoleMsgHandler;
    1312import org.refal.plus.comp.MsgCode;
    1413import org.refal.plus.comp.MsgHandler;
    1514import org.refal.plus.comp.Parser;
    1615import org.refal.plus.comp.Scanner;
    17 import org.refal.plus.comp.ast.AstFuncDef;
    1816import org.refal.plus.comp.ast.AstImplem;
    1917import org.refal.plus.comp.ast.AstInterf;
    20 import org.refal.plus.comp.ast.AstTopNode;
    2118import org.refal.plus.comp.test.MsgAccumulator.Message;
    2219
    2320public class Util {
    24 
    25         static AstFuncDef parseAndGetFuncDef(String input,
    26                         MsgAccumulator msgAcc) {
    27                 AstImplem astImplem = Util.parseImplemString(input, msgAcc);
    28                 assertTrue("Syntax is OK", msgAcc.messages.isEmpty());
    29                 assertTrue("Single top node", astImplem.topNodes.length == 1);
    30                 AstTopNode astTopNode = astImplem.topNodes[0];
    31                 assertTrue("Top node is AstFuncDef", astTopNode instanceof AstFuncDef);
    32                 return (AstFuncDef) astImplem.topNodes[0];
    33         }
    3421
    3522        public static void checkMsg(MsgAccumulator msgAcc, MsgCode msgCode) {
     
    6249        }
    6350
    64         public static AstInterf parseInterfString(String input) {
    65                 MsgHandler msgHandler = new ConsoleMsgHandler();
    66                 return parseInterfString(input, msgHandler);
    67         }
    68 
    6951        public static Object[] scan(Reader reader, MsgHandler msgHandler) {
    7052                ArrayList<Token> tokens = new ArrayList<Token>();
     
    8163                return tokens.toArray();
    8264        }
    83 
    84         public static Object[] scanString(String input, MsgHandler msgHandler) {
    85                 return scan( new StringReader(input), msgHandler);
    86         }
    87 
    88         public static Object[] scanString(String input) {
    89                 return scanString(input, new ConsoleMsgHandler());
    90         }
    91 
    9265}
  • devel-tools/trunk/eclipse/org.refal.plus.comp.test/src/org/refal/plus/comp/test/VariableScopeCheckerTest.java

    r2256 r2263  
    1010import org.junit.Before;
    1111import org.junit.Test;
    12 import org.refal.plus.comp.LexicalEnvironment;
    1312import org.refal.plus.comp.MsgCode;
    1413import org.refal.plus.comp.VariableCollector;
     
    1817import org.refal.plus.comp.ast.AstCharSymbol;
    1918import org.refal.plus.comp.ast.AstExp;
    20 import org.refal.plus.comp.ast.AstFuncDef;
     19import org.refal.plus.comp.ast.AstImplem;
    2120import org.refal.plus.comp.ast.AstName;
    2221import org.refal.plus.comp.ast.AstNumberSymbol;
     
    4140        private static MsgAccumulator parseAndReturnMessages(String input) {
    4241                MsgAccumulator msgAcc = new MsgAccumulator();
    43                 AstFuncDef astFuncDef = Util.parseAndGetFuncDef(input, msgAcc);
    44                 VariableScopeChecker vsc = new VariableScopeChecker(msgAcc);
    45                 vsc.visit(astFuncDef.body, new LexicalEnvironment<VarType>(null));
     42                AstImplem astImplem = Util.parseImplemString(input, msgAcc);
     43                assertTrue("Syntax is OK", msgAcc.messages.isEmpty());
     44                VariableScopeChecker v = new VariableScopeChecker(msgAcc);
     45                v.visit(astImplem, null);
    4646                return msgAcc;
    4747        }
Note: See TracChangeset for help on using the changeset viewer.