class TestCase::Operator::ArrayMiddleSize {
our $MIDDLE_INDEX : int;
INIT {
$MIDDLE_INDEX = 1_000_000;
}
static method array_middle_index_byte : int () {
my $index = $MIDDLE_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;
}
$@ = undef;
return 1;
}
static method array_middle_index_short : int () {
my $index = $MIDDLE_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;
}
$@ = undef;
return 1;
}
static method array_middle_index_int : int () {
my $index = $MIDDLE_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;
}
$@ = undef;
return 1;
}
static method array_middle_index_long : int () {
my $index = $MIDDLE_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;
}
$@ = undef;
return 1;
}
static method array_middle_index_float : int () {
my $index = $MIDDLE_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;
}
$@ = undef;
return 1;
}
static method array_middle_index_double : int () {
my $index = $MIDDLE_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;
}
$@ = undef;
return 1;
}
}