Skip to content

Commit

Permalink
Add more Exceptions::JSON tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Oct 10, 2016
1 parent ff86ab8 commit 412539a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions S04-exceptions/exceptions-json.t
Expand Up @@ -4,19 +4,24 @@ use Test;
use Test::Util;

# Tests for alternate exception handler Exceptions::JSON
plan 2;
plan 3;

sub json-ex ($code) {
'use MONKEY-SEE-NO-EVAL; %*ENV<RAKUDO_EXCEPTIONS_HANDLER>="JSON";'
~ 'EVAL "' ~ $code.subst(:g, '"', '\"') ~ '";'
~ 'EVAL q|' ~ $code.subst(:g, '|', '\|') ~ '|;'
}

is_run json-ex('class X::Foo is Exception {}.new.throw'), {
:err(/'"X::Foo"' .+ 'message' .+ 'null'/),
:out(''),
:1status,
}, 'can handle exception without `message` method';

is_run json-ex('justsomerandomsyntaxerror'), {
:err(/'"X::Undeclared::Symbols"' .+ 'justsomerandomsyntaxerror'/),
:out(''),
:1status,
}, 'can handle exceptions with no `message` methods';

}, 'can handle X::Undeclared::Symbols exception';

{ # RT#129810
is_run json-ex('use FakeModuleRT129810'), {
Expand Down

0 comments on commit 412539a

Please sign in to comment.