package TestCase::Exception {
  use TestCase::Minimal;
  use TestCase;
  
  sub exception_get_field_object_undef : int () {
    
    my $test_case : TestCase = undef;
    
    eval {
      $test_case->{x_byte};
    }
    if ($@) {
      return 1;
      
      eval {
        $test_case->{x_short};
      }
      
      if ($@) {
        return 1;

        eval {
          $test_case->{x_int};
        }
        
        if ($@) {
          eval {
            $test_case->{x_long};
          }
          
          if ($@) {
            eval {
              $test_case->{x_float};
            }
            
            if ($@) {
              eval {
                $test_case->{x_double};
              }
              
              if ($@) {
                eval {
                  $test_case->{x_test_case};
                }
                
                if ($@) {

                  return 1;
                }
              }
            }
          }
        }

      }
      
    }
    
    return 0;
  }
  
  sub exception_set_field_object_undef : int () {
    
    my $test_case : TestCase = undef;
    
    eval {
      $test_case->{x_byte} = (byte)1;
    }
    if ($@) {
      return 1;
      
      eval {
        $test_case->{x_short} = (short)1;
      }
      
      if ($@) {
        return 1;

        eval {
          $test_case->{x_int} = 1;
        }
        
        if ($@) {
          eval {
            $test_case->{x_long} = 1L;
          }
          
          if ($@) {
            eval {
              $test_case->{x_float} = 1f;
            }
            
            if ($@) {
              eval {
                $test_case->{x_double} = 1d;
              }
              
              if ($@) {
                eval {
                  $test_case->{x_test_case} = undef;
                }
                
                if ($@) {

                  return 1;
                }
              }
            }
          }
        }
      }
      
    }
    
    return 0;
  }
  sub exception_eval_call_sub : int () {
    eval {
      exception_croak_return_int();
    };
    
    if ($@) {
      return 1;
    }
    
    return 0;
  }
  
  sub exception_call_stack : int () {
    exception_croak_return_int();
  }
  
  sub exception_croak_return_byte : byte () {
    croak "Error";
  }
  
  sub exception_croak_return_short : short () {
    croak "Error";
  }
  
  sub exception_croak_return_int : int () {
    croak "Error";
  }
  
  sub exception_croak_return_long : long () {
    croak "Error";
  }
  
  sub exception_croak_return_float : float () {
    croak "Error";
  }
  
  sub exception_croak_return_double : double () {
    croak "Error";
  }
  
  sub exception_croak_return_object : TestCase::Minimal () {
    croak "Error";
  }
  
  sub exception_croak_return_void : void () {
    croak "Error";
  }

  sub exception_croak_return_int_eval_catch : int () {
    eval {
      croak "Error";
    };
    
    
    if ($@) {
      return 1;
    }
    
    return 0;
  }
  # Exception
  sub exception_zero_divide_int : int () {
    1 / 0;
  }
}
