Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace some eval-dies-ok in S14-* with throws-like
  • Loading branch information
usev6 committed Sep 28, 2015
1 parent 347a9f9 commit 106b31a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions S14-roles/basic.t
Expand Up @@ -37,7 +37,7 @@ my $baz = { };
ok defined($baz does Foo), 'mixing in our Foo role into $baz worked';
ok $baz.HOW.does($baz, Foo), '.HOW.does said our $baz now does Foo';
ok $baz.^does(Foo), '.^does said our $baz now does Foo';
eval-dies-ok q{ $baz ~~ Baz }, 'smartmatch against non-existent type dies';
throws-like q{ $baz ~~ Baz }, X::Undeclared::Symbols, 'smartmatch against non-existent type dies';

# L<S14/Roles/but with a role keyword:>
# Roles may have methods
Expand Down Expand Up @@ -86,7 +86,7 @@ lives-ok { HasC.new.x = DoesC.new },
dies-ok { HasC.new.x = Mu }, 'typed attribute rejects things it should';
dies-ok { HasC.new.x = 42 }, 'typed attribute rejects things it should';

eval-dies-ok '0 but RT66178', '"but" with non-existent role dies';
throws-like '0 but RT66178', X::Undeclared::Symbols, '"but" with non-existent role dies';

{
dies-ok { EVAL 'class Animal does NonExistentRole { }; 1' },
Expand Down
2 changes: 1 addition & 1 deletion S14-roles/lexical.t
Expand Up @@ -15,7 +15,7 @@ Tests for lexical roles delcared with 'my role'
eval-lives-ok 'my role R1 {}', 'my role parses OK';
eval-lives-ok '{ my role R2 {} }; { my role R2 {} }',
'declare roles with the same name in two scopes.';
eval-dies-ok '{ my class R3 {}; R3; }; R3',
throws-like '{ my class R3 {}; R3; }; R3', X::Undeclared::Symbols,
'scope is correctly restricted';

{
Expand Down
11 changes: 7 additions & 4 deletions S14-roles/parameterized-basic.t
Expand Up @@ -128,8 +128,9 @@ is(AP_1.new.y, 'b', 'use of type params in attr initialization works after 2n
'same with class methods (1)';
is COdd.what, 'odd',
'same with class methods (2)';
eval-dies-ok 'class MD_not_Int does MD_block["foo"] { }',
"Can't compose without matching role multi";
throws-like 'class MD_not_Int does MD_block["foo"] { }',
X::Role::Parametric::NoSuchCandidate,
"Can't compose without matching role multi";
}

{
Expand All @@ -151,15 +152,17 @@ is(AP_1.new.y, 'b', 'use of type params in attr initialization works after 2n
'MD with generics at class composition time (class method) (1)';
is CDiff.what, 'different type',
'MD with generics at class composition time (class method) (2)';
eval-dies-ok 'class WrongFu does MD_generics[3] { }',
throws-like 'class WrongFu does MD_generics[3] { }',
X::Role::Parametric::NoSuchCandidate,
'MD with generics at class composition times fails (wrong arity)';
}

# RT #77338
{
lives-ok { role A[::T $?] {}; class B does A[] {} },
'question mark for optional parameter is parsed correctly';
eval-dies-ok 'role A[::T?] {}; class B does A[] {}',
throws-like 'role A[::T?] {}; class B does A[] {}',
X::Syntax::Malformed,
'cannot put question mark on a type constraint';
}

Expand Down
2 changes: 1 addition & 1 deletion S14-roles/parameterized-type.t
Expand Up @@ -57,7 +57,7 @@ is R2[C3].new.call_test, 'ok', 'classes being used as type constraints insid
dies-ok { R2[C3].new.call_fail }, 'classes being used as type constraints inside roles work';

# RT #72694
eval-dies-ok 'role ABCD[EFGH] { }', 'role with undefined type as parameter dies';
throws-like 'role ABCD[EFGH] { }', X::Parameter::InvalidType, 'role with undefined type as parameter dies';

# RT #68136
{
Expand Down

0 comments on commit 106b31a

Please sign in to comment.