class TestCase::Statement::If {
  use Point;
  
  static method condition_types : int () {
    
    # Condition - byte
    {
      my $pass = 0;
      if ((byte)1) {
        $pass = 1;
      }
      else {
        $pass = 0;
      }
      
      unless ($pass) {
        return 0;
      }
    }

    # Condition - short
    {
      my $pass = 0;
      if ((short)1) {
        $pass = 1;
      }
      if ((short)0) {
        $pass = 0;
      }
      unless ($pass) {
        return 0;
      }
    }
    
    # Condition - int
    {
      my $pass = 0;
      if (1) {
        $pass = 1;
      }
      if (0) {
        $pass = 0;
      }
      unless ($pass) {
        return 0;
      }
    }

    # Condition - long
    {
      my $pass = 0;
      if (1L) {
        $pass = 1;
      }
      if (0L) {
        $pass = 0;
      }
      unless ($pass) {
        return 0;
      }
    }

    # Condition - float
    {
      my $pass = 0;
      if (1.5f) {
        $pass = 1;
      }
      if (0.0f) {
        $pass = 0;
      }
      unless ($pass) {
        return 0;
      }
    }

    # Condition - double
    {
      my $pass = 0;
      if (1.5) {
        $pass = 1;
      }
      if (0.0) {
        $pass = 0;
      }
      unless ($pass) {
        return 0;
      }
    }

    # Condition - undef
    {
      my $pass = 0;
      if (undef) {
        $pass = 1;
      }
      unless ($pass == 0) {
        return 0;
      }
    }

    # Condition - object
    {
      # Defined object
      {
        my $pass = 0;
        my $point = Point->new;
        if ($point) {
          $pass = 1;
        }
        unless ($pass == 1) {
          return 0;
        }
      }

      # Undefined object
      {
        my $pass = 0;
        my $point : Point = undef;
        if ($point) {
          $pass = 1;
        }
        unless ($pass == 0) {
          return 0;
        }
      }
    }

    # Condition - Bool object
    {
      # Bool->TRUE
      {
        my $pass = 0;
        if (Bool->TRUE) {
          $pass = 1;
        }
        unless ($pass == 1) {
          return 0;
        }
      }
      
      # Bool->FALSE
      {
        my $pass = 0;
        if (Bool->FALSE) {
          $pass = 1;
        }
        unless ($pass == 0) {
          return 0;
        }
      }
      
      # true
      {
        my $pass = 0;
        if (true) {
          $pass = 1;
        }
        unless ($pass == 1) {
          return 0;
        }
      }
      
      # false
      {
        my $pass = 0;
        if (false) {
          $pass = 1;
        }
        unless ($pass == 0) {
          return 0;
        }
      }
    }
    
    return 1;
  }
  
  static method condition_true : int () {
    
    if (1) {
      return 1;
    }
    
    return 0;
  }

  static method condition_false : int () {
    
    if (0) {
      return 0;
    }
    
    return 1;
  }
  
  static method elsif_condition_true : int () {
    
    my $num = 2;
    if ($num == 1) {
      return 0;
    }
    elsif ($num == 2) {
      return 1;
    }
    elsif ($num == 3) {
      return 0;
    }
    else {
      return 0;
    }
    
    return 0;
  }

  static method elsif_condition_false : int () {
    
    my $num = 4;
    if ($num == 1) {
      return 0;
    }
    elsif ($num == 2) {
      return 0;
    }
    elsif ($num == 3) {
      return 0;
    }
    else {
      return 1;
    }
    return 0;
  }

  static method elsif_only : int () {
    
    my $num = 2;
    if ($num == 1) {
      return 0;
    }
    elsif ($num == 2) {
      return 1;
    }
    
    return 0;
  }

  static method else_only : int () {
    
    my $num = 2;
    if ($num == 1) {
      return 0;
    }
    else {
      return 1;
    }
    
    return 0;
  }

  static method condition_my : int () {
    # Check my declaration in if condition part - if condition part is true
    {
      my $check1 = 0;
      my $check2 = 0;
      
      my $num = 1;
      if (my $num = 2) {
        if ($num == 2) {
          $check1 = 1;
        }
      }
      elsif (my $num = 3) {
        
      }
      else {
        
      }
      if ($num == 1) {
        $check2 = 1;
      }
      
      unless ($check1 && $check2) {
        return 0;
      }
    }

    # Check my declaration in if condition part - elsif condition part is true
    {
      my $check1 = 0;
      my $check2 = 0;
      
      my $num = 1;
      if (my $num = 0) {
      }
      elsif (my $num = 3) {
        if ($num == 3) {
          $check1 = 1;
        }
      }
      else {
        
      }
      if ($num == 1) {
        $check2 = 1;
      }
      
      unless ($check1 && $check2) {
        return 0;
      }
    }
    
    # Extra
    {
      my $num = 5;
      if (my $num = 3) {
        unless ($num == 3) {
          return 0;
        }
      }
    }
    
    return 1;
  }
}
