/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Note that $opt$ is a marker for the optimizing compiler to test
// it does compile the method.
public class DivTest {

  public static void expectEquals(int expected, int result) {
    if (expected != result) {
      throw new Error("Expected: " + expected + ", found: " + result);
    }
  }

  public static void expectEquals(long expected, long result) {
    if (expected != result) {
      throw new Error("Expected: " + expected + ", found: " + result);
    }
  }

  public static void expectEquals(float expected, float result) {
    if (expected != result) {
      throw new Error("Expected: " + expected + ", found: " + result);
    }
  }

  public static void expectEquals(double expected, double result) {
    if (expected != result) {
      throw new Error("Expected: " + expected + ", found: " + result);
    }
  }

  public static void expectApproxEquals(float a, float b) {
    float maxDelta = 0.00001F;
    boolean aproxEquals = (a > b) ? ((a - b) < maxDelta) : ((b - a) < maxDelta);
    if (!aproxEquals) {
      throw new Error("Expected: " + a + ", found: " + b
          + ", with delta: " + maxDelta + " " + (a - b));
    }
  }

  public static void expectApproxEquals(double a, double b) {
    double maxDelta = 0.00001D;
    boolean aproxEquals = (a > b) ? ((a - b) < maxDelta) : ((b - a) < maxDelta);
    if (!aproxEquals) {
      throw new Error("Expected: " + a + ", found: "
          + b + ", with delta: " + maxDelta + " " + (a - b));
    }
  }

  public static void expectNaN(float a) {
    if (a == a) {
      throw new Error("Expected NaN: " + a);
    }
  }

  public static void expectNaN(double a) {
    if (a == a) {
      throw new Error("Expected NaN: " + a);
    }
  }

  public static void expectDivisionByZero(int value) {
    try {
      $opt$Div(value, 0);
      throw new Error("Expected RuntimeException when dividing by 0");
    } catch (java.lang.RuntimeException e) {
    }
    try {
      $opt$DivZero(value);
      throw new Error("Expected RuntimeException when dividing by 0");
    } catch (java.lang.RuntimeException e) {
    }
  }

  public static void expectDivisionByZero(long value) {
    try {
      $opt$Div(value, 0L);
      throw new Error("Expected RuntimeException when dividing by 0");
    } catch (java.lang.RuntimeException e) {
    }
    try {
      $opt$DivZero(value);
      throw new Error("Expected RuntimeException when dividing by 0");
    } catch (java.lang.RuntimeException e) {
    }
  }

  public static void main() {
    divInt();
    divLong();
    divFloat();
    divDouble();
  }

  private static void divInt() {
    expectEquals(2, $opt$DivConst(6));
    expectEquals(2, $opt$Div(6, 3));
    expectEquals(6, $opt$Div(6, 1));
    expectEquals(-2, $opt$Div(6, -3));
    expectEquals(1, $opt$Div(4, 3));
    expectEquals(-1, $opt$Div(4, -3));
    expectEquals(5, $opt$Div(23, 4));
    expectEquals(-5, $opt$Div(-23, 4));

    expectEquals(-Integer.MAX_VALUE, $opt$Div(Integer.MAX_VALUE, -1));
    expectEquals(Integer.MIN_VALUE, $opt$Div(Integer.MIN_VALUE, -1)); // overflow
    expectEquals(-1073741824, $opt$Div(Integer.MIN_VALUE, 2));

    expectEquals(0, $opt$Div(0, Integer.MAX_VALUE));
    expectEquals(0, $opt$Div(0, Integer.MIN_VALUE));

    expectDivisionByZero(0);
    expectDivisionByZero(1);
    expectDivisionByZero(Integer.MAX_VALUE);
    expectDivisionByZero(Integer.MIN_VALUE);
  }

  private static void divLong() {
    expectEquals(2L, $opt$DivConst(6L));
    expectEquals(2L, $opt$Div(6L, 3L));
    expectEquals(6L, $opt$Div(6L, 1L));
    expectEquals(-2L, $opt$Div(6L, -3L));
    expectEquals(1L, $opt$Div(4L, 3L));
    expectEquals(-1L, $opt$Div(4L, -3L));
    expectEquals(5L, $opt$Div(23L, 4L));
    expectEquals(-5L, $opt$Div(-23L, 4L));

    expectEquals(-Integer.MAX_VALUE, $opt$Div(Integer.MAX_VALUE, -1L));
    expectEquals(2147483648L, $opt$Div(Integer.MIN_VALUE, -1L));
    expectEquals(-1073741824L, $opt$Div(Integer.MIN_VALUE, 2L));

    expectEquals(-Long.MAX_VALUE, $opt$Div(Long.MAX_VALUE, -1L));
    expectEquals(Long.MIN_VALUE, $opt$Div(Long.MIN_VALUE, -1L)); // overflow

    expectEquals(11111111111111L, $opt$Div(33333333333333L, 3L));
    expectEquals(3L, $opt$Div(33333333333333L, 11111111111111L));

    expectEquals(0L, $opt$Div(0L, Long.MAX_VALUE));
    expectEquals(0L, $opt$Div(0L, Long.MIN_VALUE));

    expectDivisionByZero(0L);
    expectDivisionByZero(1L);
    expectDivisionByZero(Long.MAX_VALUE);
    expectDivisionByZero(Long.MIN_VALUE);
  }

  private static void divFloat() {
    expectApproxEquals(1.6666666F, $opt$Div(5F, 3F));
    expectApproxEquals(0F, $opt$Div(0F, 3F));
    expectApproxEquals(-0.3333333F, $opt$Div(1F, -3F));
    expectApproxEquals(4F, $opt$Div(-12F, -3F));
    expectApproxEquals(0.5, $opt$Div(0.1F, 0.2F));
    expectApproxEquals(-2.5F, $opt$Div(-0.5F, 0.2F));

    expectEquals(0F, $opt$Div(0F, Float.POSITIVE_INFINITY));
    expectEquals(0F, $opt$Div(11F, Float.POSITIVE_INFINITY));
    expectEquals(0F, $opt$Div(0F, Float.NEGATIVE_INFINITY));
    expectEquals(0F, $opt$Div(11F, Float.NEGATIVE_INFINITY));

    expectNaN($opt$Div(0F, 0F));
    expectNaN($opt$Div(Float.NaN, 11F));
    expectNaN($opt$Div(-11F, Float.NaN));
    expectNaN($opt$Div(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY));
    expectNaN($opt$Div(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY));
    expectNaN($opt$Div(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY));
    expectNaN($opt$Div(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
    expectNaN($opt$Div(Float.NaN, Float.NEGATIVE_INFINITY));
    expectNaN($opt$Div(Float.POSITIVE_INFINITY, Float.NaN));

    expectEquals(Float.POSITIVE_INFINITY, $opt$Div(3F, 0F));
    expectEquals(Float.NEGATIVE_INFINITY, $opt$Div(-3F, 0F));
    expectEquals(Float.POSITIVE_INFINITY, $opt$Div(Float.MAX_VALUE, Float.MIN_VALUE));
    expectEquals(Float.NEGATIVE_INFINITY, $opt$Div(-Float.MAX_VALUE, Float.MIN_VALUE));
  }

  private static void divDouble() {
    expectApproxEquals(1.6666666D, $opt$Div(5D, 3D));
    expectApproxEquals(0D, $opt$Div(0D, 3D));
    expectApproxEquals(-0.3333333D, $opt$Div(1D, -3D));
    expectApproxEquals(4D, $opt$Div(-12D, -3D));
    expectApproxEquals(0.5, $opt$Div(0.1D, 0.2D));
    expectApproxEquals(-2.5D, $opt$Div(-0.5D, 0.2D));

    expectEquals(0D, $opt$Div(0D, Float.POSITIVE_INFINITY));
    expectEquals(0D, $opt$Div(11D, Float.POSITIVE_INFINITY));
    expectEquals(0D, $opt$Div(0D, Float.NEGATIVE_INFINITY));
    expectEquals(0D, $opt$Div(11D, Float.NEGATIVE_INFINITY));

    expectNaN($opt$Div(0D, 0D));
    expectNaN($opt$Div(Float.NaN, 11D));
    expectNaN($opt$Div(-11D, Float.NaN));
    expectNaN($opt$Div(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY));
    expectNaN($opt$Div(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY));
    expectNaN($opt$Div(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY));
    expectNaN($opt$Div(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
    expectNaN($opt$Div(Float.NaN, Float.NEGATIVE_INFINITY));
    expectNaN($opt$Div(Float.POSITIVE_INFINITY, Float.NaN));

    expectEquals(Float.POSITIVE_INFINITY, $opt$Div(3D, 0D));
    expectEquals(Float.NEGATIVE_INFINITY, $opt$Div(-3D, 0D));
    expectEquals(Float.POSITIVE_INFINITY, $opt$Div(Float.MAX_VALUE, Float.MIN_VALUE));
    expectEquals(Float.NEGATIVE_INFINITY, $opt$Div(-Float.MAX_VALUE, Float.MIN_VALUE));
  }

  static int $opt$Div(int a, int b) {
    return a / b;
  }

  static int $opt$DivZero(int a) {
    return a / 0;
  }

  // Division by literals != 0 should not generate checks.
  static int $opt$DivConst(int a) {
    return a / 3;
  }

  static long $opt$DivConst(long a) {
    return a / 3L;
  }

  static long $opt$Div(long a, long b) {
    return a / b;
  }

  static long $opt$DivZero(long a) {
    return a / 0L;
  }

  static float $opt$Div(float a, float b) {
    return a / b;
  }

  static double $opt$Div(double a, double b) {
    return a / b;
  }
}
