package TestCase::If {
  
  sub if_true : int () {
    
    if (1) {
      return 1;
    }
    
    return 0;
  }

  sub if_false : int () {
    
    if (0) {
      return 0;
    }
    
    return 1;
  }
  
  sub elsif_match : int () {
    
    my $num = 2;
    if ($num == 1) {
      return 0;
    }
    elsif ($num == 2) {
      return 1;
    }
    elsif ($num == 3) {
      return 0;
    }
    else {
      return 0;
    }
    return 0;
  }

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

  sub 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;
      }
    }

    # Optional tests
    {
      my $num = 5;
      if (my $num = 3) {
        unless ($num == 3) {
          return 0;
        }
      }
    }
    
    return 1;
  }
}
