package TestCase::CoreFunc::Math {

  sub test_join : int () {
    my $strings = ["abc", "def", "hij"];
    
    my $join = join(",", $strings);
    
    if ($join eq "abc,def,hij") {
      return 1;
    }
    
    return 0;
  }

  sub test_sin : int () {
    my $value = sin(PI());
    
    if ($value < 0.000001 && $value > -0.000001) {
      return 1;
    }
    return 0;
  }

  sub test_cos : int () {
    my $value = cos(PI() / 2.0);
    
    if ($value < 0.000001 && $value > -0.000001) {
      return 1;
    }
    return 0;
  }
  
  sub test_tan : int () {
    my $value = tan(PI() / 4.0);
    
    if ($value - 1.0 < 0.000001 && $value - 1.0 > -0.000001) {
      return 1;
    }
    return 0;
  }

  sub test_isinff: int () {
    if (isinff(INFINITYF())) {
      if (!isinff(NANF())) {
        if (!isinff(0.1f)) {
          return 1;
        }
      }
    }
    
    return 0;
  }

  sub test_isfinitef: int () {
    if (!isfinitef(INFINITYF())) {
      if (!isfinitef(NANF())) {
        if (isfinitef(0.1f)) {
          return 1;
        }
      }
    }
    
    return 0;
  }

  sub test_isnanf: int () {
    if (!isnanf(INFINITYF())) {
      if (isnanf(NANF())) {
        if (!isnanf(0.1f)) {
          return 1;
        }
      }
    }
    
    return 0;
  }
  
  sub test_float_pass_positive_infinity : int ($value : float) {
    if ($value == INFINITYF()) {
      return 1;
    }
    
    return 0;
  }
  
  sub test_float_pass_nan : int ($value : float) {
    if (isnanf($value)) {
      return 1;
    }
    
    return 0;
  }

  sub test_isinf : int () {
    if (isinf(INFINITY())) {
      if (!isinf(NAN())) {
        if (!isinf(0.1)) {
          return 1;
        }
      }
    }
    
    return 0;
  }

  sub test_isfinite : int () {
    if (!isfinite(INFINITY())) {
      if (!isfinite(NAN())) {
        if (isfinite(0.1)) {
          return 1;
        }
      }
    }
    
    return 0;
  }

  sub test_isnan : int () {
    if (!isnan(INFINITY())) {
      if (isnan(NAN())) {
        if (!isnan(0.1)) {
          return 1;
        }
      }
    }
    
    return 0;
  }
  
  sub test_double_pass_nan : int ($value : double) {
    if (isnan($value)) {
      return 1;
    }
    
    return 0;
  }
  
  sub test_double_pass_positive_infinity : int ($value : double) {
    if ($value == INFINITY()) {
      return 1;
    }
    
    return 0;
  }

  sub test_byte_constant : int () {
    if ((int)INT8_MIN() == (int)(byte)-128) {
      if ((int)INT8_MAX() == (int)(byte)127) {
        return 1;
      }
    }
    
    return 0;
  }

  sub test_short_constant : int () {
    if ((int)INT16_MIN() == (int)(short)-32768) {
      if ((int)INT16_MAX() == (int)(short)32767) {
        return 1;
      }
    }
    
    return 0;
  }

  sub test_int_constant : int () {
    if (INT32_MIN() == -2147483648) {
      if (INT32_MAX() == 2147483647) {
        return 1;
      }
    }
    
    return 0;
  }

  sub test_long_constant : int () {
    if (INT64_MIN() == -9223372036854775808L) {
      if (INT64_MAX() == 9223372036854775807L) {
        return 1;
      }
    }
    
    return 0;
  }
}
