| 1 |
# vim: set ts=8 sts=2 sw=2 tw=100 et : |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use 5.020; |
| 5 |
use strictures 2; |
| 6 |
use stable 0.031 'postderef'; |
| 7 |
use experimental 'signatures'; |
| 8 |
no autovivification warn => qw(fetch store exists delete); |
| 9 |
use if "$]" >= 5.022, experimental => 're_strict'; |
| 10 |
no if "$]" >= 5.031009, feature => 'indirect'; |
| 11 |
no if "$]" >= 5.033001, feature => 'multidimensional'; |
| 12 |
no if "$]" >= 5.033006, feature => 'bareword_filehandles'; |
| 13 |
no if "$]" >= 5.041009, feature => 'smartmatch'; |
| 14 |
|
| 15 |
use Test2::API 'intercept'; |
| 16 |
use Test2::V0 qw(!bag !bool !warnings), -no_pragmas => 1; |
| 17 |
use Test2::Warnings qw(warnings had_no_warnings :no_end_test); |
| 18 |
use Test::JSON::Schema::Acceptance; |
| 19 |
use Test::File::ShareDir -share => { -dist => { 'Test-JSON-Schema-Acceptance' => 'share' } }; |
| 20 |
|
| 21 |
use lib 't/lib'; |
| 22 |
use SchemaParser; |
| 23 |
use Helper; |
| 24 |
|
| 25 |
my $accepter = Test::JSON::Schema::Acceptance->new(test_dir => 't/tests/subset'); |
| 26 |
my $parser = SchemaParser->new; |
| 27 |
|
| 28 |
foreach my $test ( |
| 29 |
# match tests by group description |
| 30 |
{ todo_count => 3+3, skip_tests => [ 'true schema' ] }, |
| 31 |
{ todo_count => 2*(3+3), skip_tests => [ 'true schema', 'false schema' ] }, |
| 32 |
|
| 33 |
# match tests by regexp on test description |
| 34 |
{ todo_count => 2*(3+3), skip_tests => [ '(true|false) schema' ] }, |
| 35 |
|
| 36 |
# match tests on both descriptions |
| 37 |
{ todo_count => 2*(1+3+1) + 1, skip_tests => [ 'false' ] }, |
| 38 |
|
| 39 |
# match tests on group description and test description |
| 40 |
{ todo_count => 3*2, skip_tests => [ 'empty schema.*boolean' ] }, |
| 41 |
) { |
| 42 |
my $todo_count = delete $test->{todo_count}; |
| 43 |
my @warnings; |
| 44 |
my $events = intercept( |
| 45 |
sub { |
| 46 |
@warnings = warnings { |
| 47 |
$accepter->acceptance( |
| 48 |
validate_data => sub ($schema, $data) { |
| 49 |
return $parser->validate_data($data, $schema); |
| 50 |
}, |
| 51 |
%$test, |
| 52 |
); |
| 53 |
} |
| 54 |
} |
| 55 |
); |
| 56 |
|
| 57 |
is(scalar(grep $_->isa('Test2::Event::Skip'), @$events), 0, 'skipped and todo_skipped no tests'); |
| 58 |
is( |
| 59 |
scalar( |
| 60 |
grep exists $_->{assert} && (grep $_->{tag} eq 'TODO', @{$_->{amnesty} // []}), |
| 61 |
map $_->facet_data, @$events |
| 62 |
), |
| 63 |
$todo_count, |
| 64 |
$todo_count.' tests are marked TODO', |
| 65 |
); |
| 66 |
|
| 67 |
cmp_result( |
| 68 |
\@warnings, |
| 69 |
[ re(qr/'skip_tests' option is deprecated at /) ], |
| 70 |
'got deprecation warnings for old skip_tests feature', |
| 71 |
); |
| 72 |
} |
| 73 |
|
| 74 |
had_no_warnings() if $ENV{AUTHOR_TESTING}; |
| 75 |
done_testing; |