Debian Codegraph @

t/05-test-descriptions.t

raw
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 use Test::Deep qw(!array !hash);;
19 use Test::JSON::Schema::Acceptance;
20 use Test::File::ShareDir -share => { -dist => { 'Test-JSON-Schema-Acceptance' => 'share' } };
21
22 use lib 't/lib';
23 use SchemaParser;
24 use Helper;
25
26 my $accepter = Test::JSON::Schema::Acceptance->new(test_dir => 't/tests/simple-booleans');
27 my $parser = SchemaParser->new;
28
29 my $events = intercept(
30 sub {
31 $accepter->acceptance(sub ($schema, $input_data) {
32 return $parser->validate_data($input_data, $schema);
33 });
34 }
35 );
36
37 my @bool_tests = grep $_->isa('Test2::Event::Ok'), @$events;
38 is(@bool_tests, 18, 'found all the tests');
39
40 cmp_deeply(
41 \@bool_tests,
42 array_each(methods(
43 pass => 1,
44 effective_pass => 1,
45 )),
46 'all tests pass',
47 );
48
49 cmp_result(
50 [ map $_->name, @bool_tests ],
51 [
52 map do {
53 my $file = $_;
54 map do {
55 my $group = $_;
56 map $file.'.json: "'.$group.'" - "'.$_.'"', 'integer', 'boolean false', 'boolean true'
57 }, 'empty schema', 'false schema', 'true schema'
58 }, qw(bar foo)
59 ],
60 'test names are shown correctly',
61 );
62
63 done_testing;