File: schema-as-attr.t

package info (click to toggle)
libjson-validator-perl 4.14%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 828 kB
  • sloc: perl: 2,816; makefile: 14
file content (14 lines) | stat: -rw-r--r-- 375 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use Mojo::Base -strict;
use JSON::Validator;
use Test::More;

my $json = JSON::Validator->new;
my $schema;

no warnings 'redefine';
*JSON::Validator::_validate = sub { $schema = shift->schema };
$json->validate({data => 1}, {type => 'object'});
is_deeply $schema->data, {type => 'object'}, 'schema() localized';
is $json->schema, undef, 'schema() is not set';

done_testing;