@@ -13,7 +13,7 @@ no feature 'switch';
1313use open ' :std' , ' :encoding(UTF-8)' ; # force stdin, stdout, stderr into utf8
1414
1515use Test2::Warnings qw( warnings :no_end_test had_no_warnings allow_warnings) ;
16- use Test::Fatal ;
16+ use Test2::Tools::Exception ;
1717use lib ' t/lib' ;
1818use Helper;
1919
@@ -1691,27 +1691,27 @@ subtest 'custom vocabulary classes with add_vocabulary()' => sub {
16911691 my $js = JSON::Schema::Modern-> new;
16921692
16931693 like(
1694- exception { $js -> add_vocabulary(' MyVocabulary::Does::Not::Exist' ) },
1694+ dies { $js -> add_vocabulary(' MyVocabulary::Does::Not::Exist' ) },
16951695 qr ! an't locate MyVocabulary/Does/Not/Exist.pm in \@ INC! ,
16961696 ' vocabulary class must exist' ,
16971697 );
16981698
16991699 like(
1700- exception { $js -> add_vocabulary(' MyVocabulary::MissingRole' ) },
1700+ dies { $js -> add_vocabulary(' MyVocabulary::MissingRole' ) },
17011701 qr / Value "MyVocabulary::MissingRole" did not pass type constraint/ ,
17021702 ' vocabulary class must implement the role' ,
17031703 );
17041704
17051705 like(
1706- exception { $js -> add_vocabulary(' MyVocabulary::MissingSub' ) },
1706+ dies { $js -> add_vocabulary(' MyVocabulary::MissingSub' ) },
17071707 qr / Can't apply JSON::Schema::Modern::Vocabulary to MyVocabulary::MissingSub - missing vocabulary, keywords/ ,
17081708 ' vocabulary class must implement some subs' ,
17091709 );
17101710
17111711 cmp_result(
17121712 [ warnings {
17131713 like(
1714- exception { $js -> add_vocabulary(' MyVocabulary::BadVocabularySub1' ) },
1714+ dies { $js -> add_vocabulary(' MyVocabulary::BadVocabularySub1' ) },
17151715 qr / Undef did not pass type constraint/ ,
17161716 ' vocabulary() sub in the vocabulary class must return uri => specification_version pairs' ,
17171717 )
@@ -1721,21 +1721,20 @@ subtest 'custom vocabulary classes with add_vocabulary()' => sub {
17211721 );
17221722
17231723 like(
1724- exception { $js -> add_vocabulary(' MyVocabulary::BadVocabularySub2' ) },
1724+ dies { $js -> add_vocabulary(' MyVocabulary::BadVocabularySub2' ) },
17251725 qr ! Value "https://some/uri#/invalid/uri" did not pass type constraint! ,
17261726 ' vocabulary() sub in the vocabulary class must contain valid absolute, fragmentless URIs' ,
17271727 );
17281728
17291729 like(
1730- exception { $js -> add_vocabulary(' MyVocabulary::BadVocabularySub3' ) },
1730+ dies { $js -> add_vocabulary(' MyVocabulary::BadVocabularySub3' ) },
17311731 qr / Value "wrongdraft" did not pass type constraint/ ,
17321732 ' vocabulary() sub in the vocabulary class must reference a known specification version' ,
17331733 );
17341734
17351735
1736- is(
1737- exception { $js -> add_vocabulary(' MyVocabulary::BadEvaluationOrder' ) },
1738- undef ,
1736+ ok(
1737+ lives { $js -> add_vocabulary(' MyVocabulary::BadEvaluationOrder' ) },
17391738 ' added a vocabulary sub' ,
17401739 );
17411740
@@ -1774,9 +1773,8 @@ subtest 'custom vocabulary classes with add_vocabulary()' => sub {
17741773 ' custom vocabulary class has a conflicting evaluation_order' ,
17751774 );
17761775
1777- is(
1778- exception { $js -> add_vocabulary(' MyVocabulary::StringComparison' ) },
1779- undef ,
1776+ ok(
1777+ lives { $js -> add_vocabulary(' MyVocabulary::StringComparison' ) },
17801778 ' added another vocabulary sub' ,
17811779 );
17821780
@@ -1813,15 +1811,14 @@ subtest 'custom vocabulary classes with add_vocabulary()' => sub {
18131811
18141812
18151813 like(
1816- exception { $js -> add_vocabulary(' MyVocabulary::ReservedKeyword' ) },
1814+ dies { $js -> add_vocabulary(' MyVocabulary::ReservedKeyword' ) },
18171815 qr / ^keywords starting with "\$ " are reserved for core and cannot be used/ ,
18181816 ' $ keywords are prohibited' ,
18191817 );
18201818
18211819
1822- is(
1823- exception { $js -> add_vocabulary(' MyVocabulary::ConflictingKeyword' ) },
1824- undef ,
1820+ ok(
1821+ lives { $js -> add_vocabulary(' MyVocabulary::ConflictingKeyword' ) },
18251822 ' added another vocabulary sub' ,
18261823 );
18271824
0 commit comments