root/t/perl5/exception_handling.t

Revision 22090, 0.6 kB (checked in by lwall, 4 months ago)

[t] clean up various calls to try, system, etc

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1use v6;
2
3use Test;
4
5
6BEGIN {
7plan 3;
8unless (try { eval("1", :lang<perl5>) }) {
9    skip_rest('no perl 5 support'); exit;
10}
11}
12
13use perl5:Carp;
14
15my $err;
16lives_ok({ try { Carp.croak() }; $err = $! }, "Perl 5 exception (die) caught");
17like($err, rx:P5/Carp/, "Exception is propagated to Perl 6 land");
18
19eval(q[
20package Foo;
21
22sub new {
23        bless {}, __PACKAGE__;
24}
25
26sub error {
27        my $error = Foo->new;
28        die $error;
29}
30
31sub test { "1" }
32], :lang<perl5>);
33
34my $foo = eval("Foo->new",:lang<perl5>);
35try { $foo.error };
36lives_ok( {
37    my $err = $!;
38    $err.test;
39}, "Accessing Perl5 method doesn't die");
Note: See TracBrowser for help on using the browser.