package TestCase::NumericOperator {
  # Negate
  sub negate : int () {
    my $num_byte = (byte)1;
    my $num_short = (short)1;
    my $num_int = 1;
    my $num_long = 1L;
    my $num_float = 1f;
    my $num_double = 1d;
    
    my $num_byte_negate : int = -$num_byte;
    my $num_short_negate : int = -$num_short;
    my $num_int_negate = -$num_int;
    my $num_long_negate = -$num_long;
    my $num_float_negate = -$num_float;
    my $num_double_negate = -$num_double;
    
    if ($num_byte_negate == -1) {
      if ($num_short_negate == -1) {
        if ($num_int_negate == -1) {
          if ($num_long_negate == -1L) {
            if ($num_float_negate == -1f) {
              if ($num_double_negate == -1d) {
                return 1;
              }
            }
          }
        }
      }
    }
    
    return 0;
  }

  # Negate
  sub plus : int () {
    my $num_byte = (byte)1;
    my $num_short = (short)1;
    my $num_int = 1;
    my $num_long = 1L;
    my $num_float = 1f;
    my $num_double = 1d;
    
    my $num_byte_plus : int = +$num_byte;
    my $num_short_plus : int = +$num_short;
    my $num_int_plus = +$num_int;
    my $num_long_plus = +$num_long;
    my $num_float_plus = +$num_float;
    my $num_double_plus = +$num_double;
    
    if ($num_byte_plus == 1) {
      if ($num_short_plus == 1) {
        if ($num_int_plus == 1) {
          if ($num_long_plus == 1L) {
            if ($num_float_plus == 1f) {
              if ($num_double_plus == 1d) {
                return 1;
              }
            }
          }
        }
      }
    }
    
    return 0;
  }
  sub add : int () {

    # float
    my $float_success = 0;
    {
      my $value1 : float = 0.25f + 0.5f;
      my $value2 : float = (byte)2 + 0.5f;
      my $value3 : float = 0.5f + (byte)2;
      my $value4 : float = (short)2 + 0.5f;
      my $value5 : float = 0.5f + (short)2;
      my $value6 : float = 2 + 0.5f;
      my $value7 : float = 0.5f + 2;
      if ($value1 == 0.75f) {
        if ($value2 == 2.5f) {
          if ($value3 == 2.5f) {
            if ($value4 == 2.5f) {
              if ($value5 == 2.5f) {
                if ($value6 == 2.5f) {
                  if ($value7 == 2.5f) {
                    $float_success = 1;
                  }
                }
              }
            }
          }
        }
      }
    }
    
    # double
    my $double_success = 0;
    {
      my $value1 : double = (byte)2 + 0.5;
      my $value2 : double = 0.5 + (byte)2;
      my $value3 : double = (short)2 + 0.5;
      my $value4 : double = 0.5 + (short)2;
      my $value5 : double = 2 + 0.5;
      my $value6 : double = 0.5 + 2;
      my $value7 : double = 0.5 + 0.25;
      my $value8 : double = 0.5 + 0.25f;
      my $value9 : double = 0.25f + 0.5;
      if ($value1 == 2.5) {
        if ($value2 == 2.5) {
          if ($value3 == 2.5) {
            if ($value4 == 2.5) {
              if ($value5 == 2.5) {
                if ($value6 == 2.5) {
                  if ($value7 == 0.75) {
                    if ($value8 == 0.75) {
                      if ($value9 == 0.75) {
                        $double_success = 1;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    
    if ($float_success && $double_success) {
      return 1;
    }

    return 0;
  }

  # Multiply
  sub multiply : int () {
    # int
    my $int_success = 0;
    {
      my $value1 : int = -2 * 2;
      my $value2 : int = (byte)-2 * 3;
      my $value3 : int = -2 * (byte)4;
      my $value4 : int = (short)-2 * 5;
      my $value5 : int = -2 * (short)6;
      my $value6 : int = (byte)-2 * (byte)7;
      my $value7 : int = (short)-2 * (short)8;
      my $value8 : int = (byte)-2 * (short)9;
      if ($value1 == -4) {
        if ($value2 == -6) {
          if ($value3 == -8) {
            if ($value4 == -10) {
              if ($value5 == -12) {
                if ($value6 == -14) {
                  if ($value7 == -16) {
                    if ($value8 == -18) {
                      $int_success = 1;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    
    # float
    my $float_success = 0;
    {
      my $value1 : float = 0.25f * 0.5f;
      my $value2 : float = (byte)2 * 0.5f;
      my $value3 : float = 0.5f * (byte)2;
      my $value4 : float = (short)2 * 0.5f;
      my $value5 : float = 0.5f * (short)2;
      my $value6 : float = 2 * 0.5f;
      my $value7 : float = 0.5f * 2;
      if ($value1 == 0.125f) {
        if ($value2 == 1.0f) {
          if ($value3 == 1.0f) {
            if ($value4 == 1.0f) {
              if ($value5 == 1.0f) {
                if ($value6 == 1.0f) {
                  if ($value7 == 1.0f) {
                    $float_success = 1;
                  }
                }
              }
            }
          }
        }
      }
    }
    
    # double
    my $double_success = 0;
    {
      my $value1 : double = (byte)2 * 0.5;
      my $value2 : double = 0.5 * (byte)2;
      my $value3 : double = (short)2 * 0.5;
      my $value4 : double = 0.5 * (short)2;
      my $value5 : double = 2 * 0.5;
      my $value6 : double = 0.5 * 2;
      my $value7 : double = 0.5 * 0.25;
      my $value8 : double = 0.5 * 0.25f;
      my $value9 : double = 0.25f * 0.5;
      if ($value1 == 1.0) {
        if ($value2 == 1.0) {
          if ($value3 == 1.0) {
            if ($value4 == 1.0) {
              if ($value5 == 1.0) {
                if ($value6 == 1.0) {
                  if ($value7 == 0.125) {
                    if ($value8 == 0.125) {
                      if ($value9 == 0.125) {
                        $double_success = 1;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    
    if ($int_success && $float_success && $double_success) {
      return 1;
    }

    return 0;
  }
  
  # Multiply
  sub multiply_int_plus : int () {
    return (int)536870912 * (int)2;
  }
  
  sub multiply_int_minus : int () {
    return (int)536870912 * (int)-2;
  }
  
  sub multiply_int_overflow : int () {
    return (int)1073741824 * (int)2;
  }
  
  sub multiply_long_plus : long () {
    return (long)2305843009213693952L * (long)2L;
  }
  
  sub multiply_long_minus : long () {
    return (long)2305843009213693952L * (long)-2L;
  }
  
  sub multiply_long_overflow : long () {
    return (long)4611686018427387904L * (long)2L;
  }
  # Multiply
  sub divide : int () {
    # int
    my $int_success = 0;
    {
      my $value1 : int = 8 / 4;
      my $value2 : int = (byte)8 / 4;
      my $value3 : int = 8 / (byte)4;
      my $value4 : int = (short)8 / 4;
      my $value5 : int = 8 / (short)4;
      my $value6 : int = (byte)8 / (byte)4;
      my $value7 : int = (short)8 / (short)4;
      my $value8 : int = (byte)8 / (short)4;
      my $value9 : int = 8 / 3;
      if ($value1 == 2) {
        if ($value2 == 2) {
          if ($value3 == 2) {
            if ($value4 == 2) {
              if ($value5 == 2) {
                if ($value6 == 2) {
                  if ($value7 == 2) {
                    if ($value8 == 2) {
                      if ($value9 == 2) {
                        $int_success = 1;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    
    # float
    my $float_success = 0;
    {
      my $value1 : float = 1.0f / 2.0f;
      my $value2 : float = (byte)1 / 2.0f;
      my $value3 : float = 1.0f / (byte)2;
      my $value4 : float = (short)1 / 2.0f;
      my $value5 : float = 1.0f / (short)2;
      my $value6 : float = 1 / 2.0f;
      my $value7 : float = 1.0f / 2;
      if ($value1 == 0.5f) {
        if ($value2 == 0.5f) {
          if ($value3 == 0.5f) {
            if ($value4 == 0.5f) {
              if ($value5 == 0.5f) {
                if ($value6 == 0.5f) {
                  if ($value7 == 0.5f) {
                    $float_success = 1;
                  }
                }
              }
            }
          }
        }
      }
    }
    
    # double
    my $double_success = 0;
    {
      my $value1 : double = 1.0 / 2.0;
      my $value2 : double = (byte)1 / 2.0;
      my $value3 : double = 1.0 / (byte)2;
      my $value4 : double = (short)1 / 2.0;
      my $value5 : double = 1.0 / (short)2;
      my $value6 : double = 1 / 2.0;
      my $value7 : double = 1.0 / 2;
      my $value8 : double = 1.0 / 2.0f;
      my $value9 : double = 1.0f / 2.0;
      if ($value1 == 0.5f) {
        if ($value2 == 0.5f) {
          if ($value3 == 0.5f) {
            if ($value4 == 0.5f) {
              if ($value5 == 0.5f) {
                if ($value6 == 0.5f) {
                  if ($value7 == 0.5f) {
                    if ($value8 == 0.5f) {
                      if ($value9 == 0.5f) {
                        $double_success = 1;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    
    if ($int_success && $float_success && $double_success) {
      return 1;
    }

    return 0;
  }
  
  sub remainder : int () {
    my $num1 = (byte)((byte)5 % (byte)3);
    my $num2 = (byte)((byte)-3 % (byte)5);
    my $num3 = (short)((int)(short)5 % (int)(short)3);
    my $num4 = (short)((int)(short)-3 % (int)(short)5);
    my $num5 = 5 % 3;
    my $num6 = -3 % 5;
    my $num7 = 5L % 3L;
    my $num8 = -3L % 5L;
    
    if ($num1 == 2) {
      if ($num2 == -3) {
        if ($num3 == 2) {
          if ($num4 == -3) {
            if ($num5 == 2) {
              if ($num6 == -3) {
                if ($num7 == 2L) {
                  if ($num8 == -3L) {
                    return 1;
                  }
                }
              }
            }
          }
        }
      }
    }
    
    return 0;
  }
}
