Esempio n. 1
0
  // Then JUnit calls this test on it
  @Test
  public void testStatement() {
    // Build up a little program
    EagleFileReader pgm = new EagleFileReader();
    pgm.add("IDENTIFICATION DIVISION.");
    if (_data != null) {
      pgm.add("DATA DIVISION.");
      pgm.add("WORKING-STORAGE SECTION.");
      pgm.add(_data);
    }
    pgm.add("PROCEDURE DIVISION.");
    pgm.add(_proc);
    COBOL_Program_Complete lang = new COBOL_Program_Free_Format();
    ParserManager parser = new ParserManager();
    parser.parseLines(pgm, lang, lang);

    // Now, run the program
    PrintStream saveOut = System.out;
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    PrintStream prt = new PrintStream(stream);
    System.setOut(prt); // Redirect into my byte stream

    _interpreter.execute(lang);

    System.setOut(saveOut); // Restore original stdout
    prt.close();
    String actualOutput = stream.toString();
    assert _expected == actualOutput : "Values didn't match";
    System.out.print("==== " + _testName + " ====\n");
    if (_data != null) System.out.print(_data + "\n");
    System.out.print(_proc + "\n");
    System.out.println("Printed " + _expected + "As expected.\n");
  }
Esempio n. 2
0
  @Override
  public boolean parse(EagleFileReader lines) {
    if (findStart(lines) == FOUND.EOF) return false;

    EagleLineReader rec = lines.get(_currentLine);
    if (rec.charAt(_currentChar) != ';') return false;

    int nc = rec.length();
    foundIt(_currentLine, nc);
    _comment = rec.substring(_currentChar, nc);
    return true;
  }
Esempio n. 3
0
  @Override
  public boolean parse(EagleFileReader lines) {
    if (findStart(lines) == FOUND.EOF) return false;

    EagleLineReader rec = lines.get(_currentLine);
    char ch = rec.charAt(_currentChar);
    if (ch == '{') {
      if (!super.possibleCommentPair1(lines, rec, '{', '}')) return false;
      if (_comment.startsWith("{$I ")) return true;
      return false;
    }
    return false;
  }