public static void main(String[] args) {
   try {
     divisionByZero();
   } catch (ArithmeticException e) {
     e.printStackTrace();
   }
 }
  private DynamicObject translate(ArithmeticException exception) {
    if (getContext().getOptions().EXCEPTIONS_PRINT_JAVA) {
      exception.printStackTrace();
    }

    return getContext().getCoreLibrary().zeroDivisionError(this);
  }
Exemple #3
0
  // test client
  public static void main(String[] args) {

    try {
      test1();
    } catch (ArithmeticException e) {
      e.printStackTrace();
    }
    System.out.println("--------------------------------");

    try {
      test2();
    } catch (ArithmeticException e) {
      e.printStackTrace();
    }
    System.out.println("--------------------------------");

    try {
      test3();
    } catch (ArithmeticException e) {
      e.printStackTrace();
    }
    System.out.println("--------------------------------");

    try {
      test4();
    } catch (ArithmeticException e) {
      e.printStackTrace();
    }
    System.out.println("--------------------------------");

    int M = Integer.parseInt(args[0]);
    int N = Integer.parseInt(args[1]);
    double[] c = new double[N];
    double[] b = new double[M];
    double[][] A = new double[M][N];
    for (int j = 0; j < N; j++) c[j] = Math.random() * 1000;
    for (int i = 0; i < M; i++) b[i] = Math.random() * 1000;
    for (int i = 0; i < M; i++) for (int j = 0; j < N; j++) A[i][j] = Math.random() * 1000;
    Simplex lp = new Simplex(A, b, c);
    System.out.println(lp.value());
  }
Exemple #4
0
  protected static void validateRowOfLongs(String messagePrefix, VoltTable vt, long[] expected) {
    int len = expected.length;
    assertTrue(vt.advanceRow());
    for (int i = 0; i < len; i++) {
      String message = messagePrefix + "at column " + i + ", ";

      long actual = -10000000;
      // ENG-4295: hsql bug: HSQLBackend sometimes returns wrong column type.
      try {
        actual = vt.getLong(i);
      } catch (IllegalArgumentException ex) {
        try {
          actual = (long) vt.getDouble(i);
        } catch (IllegalArgumentException newEx) {
          try {
            actual = vt.getTimestampAsLong(i);
          } catch (IllegalArgumentException exTm) {
            try {
              actual = vt.getDecimalAsBigDecimal(i).longValueExact();
            } catch (IllegalArgumentException newerEx) {
              newerEx.printStackTrace();
              fail(message);
            }
          } catch (ArithmeticException newestEx) {
            newestEx.printStackTrace();
            fail(message);
          }
        }
      }

      // Long.MIN_VALUE is like a NULL
      if (expected[i] != Long.MIN_VALUE) {
        assertEquals(message, expected[i], actual);
      } else {
        VoltType type = vt.getColumnType(i);
        assertEquals(
            message + "expected null: ", Long.parseLong(type.getNullValue().toString()), actual);
      }
    }
  }