Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace some more eval-dies-ok with throws-like
  • Loading branch information
usev6 committed Sep 24, 2015
1 parent 8f437db commit cfdc4ba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
11 changes: 7 additions & 4 deletions S05-metasyntax/regex.t
Expand Up @@ -3,11 +3,12 @@ use Test;

plan 32;

eval-dies-ok('qr/foo/', 'qr// is gone');
throws-like 'qr/foo/', X::Obsolete, 'qr// is gone';

isa-ok(rx/oo/, Regex);
isa-ok(rx (o), Regex);
eval-dies-ok('rx(o)', 'rx () whitespace if the delims are parens');
throws-like 'rx(o)', X::Undeclared::Symbols,
'rx () requires whitespace if the delims are parens';
isa-ok(regex {oo}, Regex);

eval-dies-ok('rx :foo:', 'colons are not allowed as rx delimiters');
Expand Down Expand Up @@ -72,8 +73,10 @@ eval-dies-ok q['x' ~~ m/RT (#)67612 /], 'commented capture end = parse error';

# L<S05/Simplified lexical parsing of patterns/The semicolon character>

eval-dies-ok 'rx/;/', 'bare ";" in rx is not allowed';
eval-dies-ok q{';' ~~ /;/}, 'bare ";" in match is not allowed';
throws-like 'rx/;/', X::Syntax::Regex::UnrecognizedMetachar,
'bare ";" in rx is not allowed';
throws-like q{';' ~~ /;/}, X::Syntax::Regex::UnrecognizedMetachar,
'bare ";" in match is not allowed';
isa-ok rx/\;/, Regex, 'escaped ";" in rx// works';
ok ';' ~~ /\;/, 'escaped ";" in m// works';

Expand Down
4 changes: 2 additions & 2 deletions S05-metasyntax/repeat.t
Expand Up @@ -38,8 +38,8 @@ ok("abcabcabcabcd" ~~ m/'abc'**{2..*}/, 'Open range repetition using closure');
ok(!( "abcd" ~~ m/'abc'**{2..*}/), 'Fail open range repetition using closure');

# It is illegal to return a list, so this easy mistake fails:
eval-dies-ok('"foo" ~~ m/o{1,3}/', 'P5-style {1,3} range mistake is caught');
eval-dies-ok('"foo" ~~ m/o{1,}/', 'P5-style {1,} range mistake is caught');
throws-like '"foo" ~~ m/o{1,3}/', X::Obsolete, 'P5-style {1,3} range mistake is caught';
throws-like '"foo" ~~ m/o{1,}/', X::Obsolete, 'P5-style {1,} range mistake is caught';

is(~('foo,bar,baz,' ~~ m/[<alpha>+]+ % ','/), 'foo,bar,baz', '% with a term worked');
is(~('foo,bar,baz,' ~~ m/[<alpha>+]+ %% ','/), 'foo,bar,baz,', '%% with a term worked');
Expand Down
3 changes: 2 additions & 1 deletion S05-metasyntax/unknown.t
Expand Up @@ -7,7 +7,8 @@ plan 13;

# testing unknown metasyntax handling

eval-dies-ok('"aa!" ~~ /!/', '"!" is not valid metasyntax');
throws-like '"aa!" ~~ /!/', X::Syntax::Regex::UnrecognizedMetachar,
'"!" is not valid metasyntax';
lives-ok({"aa!" ~~ /\!/}, 'escaped "!" is valid');
lives-ok({"aa!" ~~ /'!'/}, 'quoted "!" is valid');

Expand Down

0 comments on commit cfdc4ba

Please sign in to comment.