From a6ce8eaa2d2c31a67f6caa80235ed2d12c63d493 Mon Sep 17 00:00:00 2001 From: rod Date: Fri, 25 Mar 2016 12:57:07 +0100 Subject: [PATCH] Try::Tiny interaction failing test case --- Makefile.PL | 1 + t/nested.t | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Makefile.PL b/Makefile.PL index 70e9af7..93c0eb0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -24,5 +24,6 @@ WriteMakefile( }, TEST_REQUIRES => { 'Test::Fatal' => '0.014', + 'Try::Tiny' => '0.24', } ); diff --git a/t/nested.t b/t/nested.t index 9cbdbae..0fee2c0 100644 --- a/t/nested.t +++ b/t/nested.t @@ -5,6 +5,31 @@ use JavaScript::Duktape; use Test::More; use Test::Fatal; +use Try::Tiny; + +subtest 'try-tiny interaction' => sub { + sub eval_js { + my $code = shift; + + my $js = JavaScript::Duktape->new; + + try { + $js->eval( $code ); + } catch { + my $err = $_; + warn "CAUGHT ERR: $err"; + die "JS ERR: $err"; + }; + } + + eval { + eval_js(q{ + throw new Error('oh boy!'); + }); + }; + isnt $@, '', 'error message comes through'; +}; + subtest 'simple nested thrown exception' => sub{ my $js = JavaScript::Duktape->new(); $js->set( each => sub{