class TestCase::Operator::ArrayBigSize {
  use TestCase::Minimal;
  use Fn;
  use Array;
  
  our $BIG_INDEX : int;
  INIT {
    $BIG_INDEX = 200_000_000;
  }
  
  static method array_max_index_byte : int () {
    my $nums = new byte[Fn->INT32_MAX()];
    
    $nums->[0] = 1;
    $nums->[Fn->INT32_MAX() - 1] = 2;
    
    unless ($nums->[0] == 1) {
      return 0;
    }
    
    unless ($nums->[Fn->INT32_MAX() - 1] == 2) {
      return 0;
    }
    
    eval {
      $nums->[Fn->INT32_MAX()];
    };
    unless ($@) {
      return 0;
    }
    
    # Additional use memory
    my $nums1 = new byte[Fn->INT32_MAX()];
    my $nums2 = new byte[Fn->INT32_MAX()];
    my $nums3 = new byte[Fn->INT32_MAX()];
    
    return 1;
  }

  static method array_big_index_byte : int () {
    my $index = $BIG_INDEX;
    my $nums = new byte[$index];
    
    $nums->[0] = 1;
    $nums->[$index - 1] = 2;
    
    unless ($nums->[0] == 1) {
      return 0;
    }
    
    unless ($nums->[$index - 1] == 2) {
      return 0;
    }
    
    eval {
      $nums->[$index];
    };
    unless ($@) {
      return 0;
    }
    
    return 1;
  }

  static method array_big_index_short : int () {
    my $index = $BIG_INDEX;
    my $nums = new short[$index];
    
    $nums->[0] = 1;
    $nums->[$index - 1] = 2;
    
    unless ($nums->[0] == 1) {
      return 0;
    }
    
    unless ($nums->[$index - 1] == 2) {
      return 0;
    }
    
    eval {
      $nums->[$index];
    };
    unless ($@) {
      return 0;
    }
    
    return 1;
  }

  static method array_big_index_int : int () {
    my $index = $BIG_INDEX;
    my $nums = new int[$index];
    
    $nums->[0] = 1;
    $nums->[$index - 1] = 2;
    
    unless ($nums->[0] == 1) {
      return 0;
    }
    
    unless ($nums->[$index - 1] == 2) {
      return 0;
    }
    
    eval {
      $nums->[$index];
    };
    unless ($@) {
      return 0;
    }
    
    return 1;
  }

  static method array_big_index_long : int () {
    my $index = $BIG_INDEX;
    my $nums = new long[$index];
    
    $nums->[0] = 1;
    $nums->[$index - 1] = 2;
    
    unless ($nums->[0] == 1) {
      return 0;
    }
    
    unless ($nums->[$index - 1] == 2) {
      return 0;
    }
    
    eval {
      $nums->[$index];
    };
    unless ($@) {
      return 0;
    }
    
    return 1;
  }

  static method array_big_index_float : int () {
    my $index = $BIG_INDEX;
    my $nums = new float[$index];
    
    $nums->[0] = 1;
    $nums->[$index - 1] = 2;
    
    unless ($nums->[0] == 1) {
      return 0;
    }
    
    unless ($nums->[$index - 1] == 2) {
      return 0;
    }
    
    eval {
      $nums->[$index];
    };
    unless ($@) {
      return 0;
    }
    
    return 1;
  }

  static method array_big_index_double : int () {
    my $index = $BIG_INDEX;
    my $nums = new double[$index];
    
    $nums->[0] = 1;
    $nums->[$index - 1] = 2;
    
    unless ($nums->[0] == 1) {
      return 0;
    }
    
    unless ($nums->[$index - 1] == 2) {
      return 0;
    }
    
    eval {
      $nums->[$index];
    };
    unless ($@) {
      return 0;
    }
    
    return 1;
  }

}
