Example #1
0
  @Test
  public void testInput() throws ParseException {

    try {
      Programa programa = Func2Parser.Input();
      boolean tipoOK = programa.checaTipo();

      assertThat("Erro de Tipo no programa: \n" + input, tipoOK, is(this.aceitoTipo));

      if (tipoOK) {
        String valor = programa.executar().toString();
        boolean valorOK = valor.equalsIgnoreCase(resultado);
        assertThat(
            "Resultado errado para a avaliação de:\n" + input, valorOK, is(this.aceitoValor));
      }

      if (this.aceitoExcecao) {
        fail("Deveria lançar Excecao");
      }

    } catch (Exception e) {
      if (!this.aceitoExcecao) {
        System.out.println(input);
        e.printStackTrace();
      }
    }
  }
  public static void main(String[] args) {

    Programa p1 = new Programa();
    p1.setId(1);

    Thread t1 = new Thread(p1);
    t1.start();

    Programa p2 = new Programa();
    p2.setId(2);

    Thread t2 = new Thread(p2);
    t2.start();
  }
Example #3
0
 public static void main(String args[]) {
   Exp1Parser parser;
   if (args.length == 0) {
     System.out.println(
         "Expressoes 1 PLP Parser Version 0.0.1:  Reading from standard input . . .");
     parser = new Exp1Parser(System.in);
   } else if (args.length == 1) {
     System.out.println(
         "Expressoes 1 PLP Parser Version 0.0.1:  Reading from file " + args[0] + " . . .");
     try {
       parser = new Exp1Parser(new java.io.FileInputStream(args[0]));
     } catch (java.io.FileNotFoundException e) {
       System.out.println("Java Parser Version 1.0.2:  File " + args[0] + " not found.");
       return;
     }
   } else {
     System.out.println("Expressoes 1 PLP Parser Version 0.0.1:  Usage is one of:");
     System.out.println("         java Exp1Parser < inputfile");
     System.out.println("OR");
     System.out.println("         java Exp1Parser inputfile");
     return;
   }
   try {
     Programa programa = parser.Input();
     System.out.println(
         "Expressoes 1 PLP Parser Version 0.0.1:  Expressoes1 program parsed successfully.");
     if (!programa.checaTipo()) {
       System.out.println("Erro de tipo");
     } else {
       programa.executar();
     }
   } catch (ParseException e) {
     System.out.println(
         "Expressoes 1 PLP Parser Version 0.0.1:  Encountered errors during parse.");
   }
 }