| 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), -no_pragmas => 1; |
| 17 |
use if $ENV{AUTHOR_TESTING}, 'Test2::Warnings'; |
| 18 |
|
| 19 |
use Test::File::ShareDir -share => { -dist => { 'Test-JSON-Schema-Acceptance' => 'share' } }; |
| 20 |
use Test::JSON::Schema::Acceptance; |
| 21 |
use lib 't/lib'; |
| 22 |
use SchemaParser; |
| 23 |
use Helper; |
| 24 |
|
| 25 |
my $accepter = Test::JSON::Schema::Acceptance->new( |
| 26 |
test_dir => 't/tests/skip_dir', |
| 27 |
include_optional => 1, |
| 28 |
skip_dir => ['optional/beta'], |
| 29 |
); |
| 30 |
|
| 31 |
my $parser = SchemaParser->new; |
| 32 |
my $events = intercept( |
| 33 |
sub { |
| 34 |
$accepter->acceptance(sub ($schema, $input_data) { |
| 35 |
return $parser->validate_data($input_data, $schema); |
| 36 |
}); |
| 37 |
} |
| 38 |
); |
| 39 |
|
| 40 |
my @bool_tests = grep $_->isa('Test2::Event::Ok'), @$events; |
| 41 |
is(@bool_tests, 4, 'correct number of tests ran'); |
| 42 |
|
| 43 |
cmp_result( |
| 44 |
[ map $_->name, @bool_tests ], |
| 45 |
[ |
| 46 |
'main.json: "test group" - "test"', |
| 47 |
'optional/alpha/test.json: "test group" - "test"', |
| 48 |
'optional/betadyne/test.json: "test group" - "test"', |
| 49 |
'optional/gamma/test.json: "test group" - "test"', |
| 50 |
], |
| 51 |
'correct test files ran', |
| 52 |
); |
| 53 |
|
| 54 |
done_testing; |