Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Unfudge and adjust tests for array shapes RT #124502
  • Loading branch information
usev6 committed Nov 21, 2015
1 parent 37a7757 commit 4a5edf7
Showing 1 changed file with 35 additions and 34 deletions.
69 changes: 35 additions & 34 deletions S02-types/array-shapes.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 25;
plan 26;

# L<S09/Fixed-size arrays>

Expand All @@ -11,26 +11,26 @@ plan 25;
is(+@arr, 43, 'my @arr[*] autoextends like my @arr');
}

#?rakudo skip 'array shapes NYI RT #124502'
{
my @arr[7] = <a b c d e f g>;
is(@arr, [<a b c d e f g>], 'my @arr[num] can hold num things');
throws-like {push @arr, 'h'},
Exception, # XXX fix when this block is no longer skipped
throws-like q[push @arr, 'h'],
X::IllegalOnFixedDimensionArray,
operation => 'push',
'adding past num items in my @arr[num] dies';
throws-like {@arr[7]},
Exception, # XXX fix when this block is no longer skipped
throws-like '@arr[7]',
Exception,
'accessing past num items in my @arr[num] dies';
}

#?rakudo skip 'array shapes NYI RT #124502'
{
lives-ok { my @arr\ [7]},
'array with fixed size with unspace');
throws-like { EVAL 'my @arr.[8]' },
lives-ok { my @arr\ [7] },
'array with fixed size with unspace';
#?rakudo 2 todo 'code does not die, array shapes RT #124502'
throws-like 'my @arr.[8]',
Exception, # XXX fix when this block is no longer skipped
'array with dot form dies';
throws-like { EVAL 'my @arr\ .[8]' },
throws-like 'my @arr\ .[8]',
Exception, # XXX fix when this block is no longer skipped
'array with dot form and unspace dies';
}
Expand All @@ -39,38 +39,38 @@ plan 25;
{
my @arr of Int = 1, 2, 3, 4, 5;
is(@arr, <1 2 3 4 5>, 'my @arr of Type works');
throws-like {push @arr, 's'},
throws-like q[push @arr, 's'],
X::TypeCheck,
'type constraints on my @arr of Type works (1)';
throws-like {push @arr, 4.2},
throws-like 'push @arr, 4.2',
X::TypeCheck,
'type constraints on my @arr of Type works (2)';
}
{
my Int @arr = 1, 2, 3, 4, 5;
is(@arr, <1 2 3 4 5>, 'my Type @arr works');
throws-like {push @arr, 's'},
throws-like q[push @arr, 's'],
X::TypeCheck,
'type constraints on my Type @arr works (1)';
throws-like {push @arr, 4.2},
throws-like 'push @arr, 4.2',
X::TypeCheck,
'type constraints on my Type @arr works (2)';
}

#?rakudo skip 'array shapes NYI RT #124502'
{
my @arr[5] of Int = <1 2 3 4 5>;
is(@arr, <1 2 3 4 5>, 'my @arr[num] of Type works');

throws-like {push @arr, 123},
#?rakudo todo 'code does not die, array shapes RT #124502'
throws-like 'push @arr, 123',
Exception,
'boundary constraints on my @arr[num] of Type works';
pop @arr; # remove the last item to ensure the next ones are type constraints
throws-like {push @arr, 's'},
Exception,
throws-like q[push @arr, 's'],
X::TypeCheck,
'type constraints on my @arr[num] of Type works (1)';
throws-like {push @arr, 4.2},
Exception,
throws-like 'push @arr, 4.2',
X::TypeCheck,
'type constraints on my @arr[num] of Type works (2)';
}

Expand All @@ -79,27 +79,28 @@ plan 25;
is(@arr, <1 2 3 4 5>, 'my type @arr works');
is push(@arr, 6), [1,2,3,4,5,6], 'push on native @arr works';
# RT #125123'
throws-like { EVAL 'push @arr, "s"' },
throws-like 'push @arr, "s"',
X::TypeCheck,
'type constraints on my type @arr works (1)';
throws-like { EVAL 'push @arr, 4.2' },
throws-like 'push @arr, 4.2',
X::TypeCheck,
'type constraints on my type @arr works (2)';
}

#?rakudo skip 'array shapes NYI RT #124502'
{
my int @arr[5] = <1 2 3 4 5>;
is(@arr, <1 2 3 4 5>, 'my Type @arr[num] works');

throws-like {push @arr, 123},
Exception,
'boundary constraints on my Type @arr[num] works';
pop @arr; # remove the last item to ensure the next ones are type constraints
throws-like {push @arr, 's'},
Exception, # XXX fix when this block is no longer skipped
'type constraints on my Type @arr[num] works (1)';
throws-like {push @arr, 4.2},
Exception, # XXX fix when this block is no longer skipped
'type constraints on my Type @arr[num] works (2)';
throws-like 'push @arr, 123',
X::IllegalOnFixedDimensionArray,
operation => 'push';
throws-like 'pop @arr',
X::IllegalOnFixedDimensionArray,
operation => 'pop';
throws-like q[push @arr, 's'],
X::IllegalOnFixedDimensionArray,
operation => 'push';
throws-like 'push @arr, 4.2',
X::IllegalOnFixedDimensionArray,
operation => 'push';
}

0 comments on commit 4a5edf7

Please sign in to comment.