Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Change exception types to new type
  • Loading branch information
lizmat committed Jan 15, 2015
1 parent 22f9e21 commit 4b5a806
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions S02-types/array.t
Expand Up @@ -225,11 +225,11 @@ my @array2 = ("test", 1, Mu);
ok !(try { @arr[*-1] }), "readonly accessing [*-1] of an empty array is not fatal";
# RT #111924
throws_like { @arr[*-1] },
X::Subscript::Negative,
"readonly accessing [*-1] of an empty array throws X::Subscript::Negative";
X::OutOfRange,
"readonly accessing [*-1] of an empty array throws X::OutOfRange";
throws_like { @arr[*-1] = 42 },
X::Subscript::Negative,
"assigning to [*-1] of an empty array throws X::Subscript::Negative";
X::OutOfRange,
"assigning to [*-1] of an empty array throws X::OutOfRange";
throws_like { @arr[*-1] := 42 },
X::Bind::Slice,
"binding [*-1] of an empty array throws X::Bind::Slice";
Expand All @@ -239,11 +239,11 @@ my @array2 = ("test", 1, Mu);
my @arr = (23);
ok !(try { @arr[*-2] }), "readonly accessing [*-2] of an one-elem array is not fatal";
throws_like { @arr[*-2] },
X::Subscript::Negative,
"readonly accessing [*-2] of an one-elem array throws X::Subscript::Negative";
X::OutOfRange,
"readonly accessing [*-2] of an one-elem array throws X::OutOfRange";
throws_like { @arr[*-2] = 42 },
X::Subscript::Negative,
"assigning to [*-2] of an one-elem array throws X::Subscript::Negative";
X::OutOfRange,
"assigning to [*-2] of an one-elem array throws X::OutOfRange";
throws_like { @arr[*-2] := 42 },
X::Bind::Slice,
"binding [*-2] of an one-elem array throws X::Bind::Slice";
Expand All @@ -259,11 +259,12 @@ my @array2 = ("test", 1, Mu);
"readonly accessing [-2] of normal array throws X::Obsolete and is fatal";
#?niecza todo '@arr[-1] returns undef'
throws_like { @arr[ $minus_one ] },
X::Subscript::Negative,
"indirectly accessing [-1] through a variable throws X::Subscript::Negative";
X::OutOfRange,
"indirectly accessing [-1] through a variable throws X::OutOfRange";
throws_like { @arr[$minus_one] = 42 },
X::Subscript::Negative,
"assigning to [-1] of a normal array throws X::Subscript::Negative";
X::OutOfRange,
"assigning to [-1] of a normal array throws X::OutOfRange";
#?rakudo todo 'bind_pos NYI'
throws_like { @arr[$minus_one] := 42 },
X::Subscript::Negative,
"binding [-1] of a normal array throws X::Subscript::Negative";
Expand Down
2 changes: 1 addition & 1 deletion S02-types/lists.t
Expand Up @@ -31,7 +31,7 @@ plan 32;
eval_dies_ok q/sub foo { @_[0..-1] }/, "indexing lists by range ending with negative index is parsefail (compact)";
eval_dies_ok q/sub foo { @_[ 0 .. -42 ] }/, "indexing lists by range ending with negative index is parsefail (spaced)";
throws_like { EVAL q/my @a = <one two>; @a[*-3] = 'zero'/ },
X::Subscript::Negative,
X::OutOfRange,
"indexing lists by an effective negative index with * dies";
}

Expand Down

0 comments on commit 4b5a806

Please sign in to comment.