zigorou / perl-JSV

JSON Schema implementation for Perl
Other
25 stars 17 forks source link

Feature/perl db #40

Closed zigorou closed 9 years ago

zigorou commented 9 years ago

Added feature that Test::JSV::Suite passes each test case to callback as forth argument. Because callback can handle testing by test case. For example,

my $validator = JSV::Validator->new;

Test::JSV::Suite->run(
  base_dir => "/path/to/dir",
  suite       => "/path/to/suite.json",
  cb           => sub {
    my ($schema, $instance, $expect, $test_case) = @_;

    ## for backward compatibility, testing forth argument
    if (defined $test_case && $test_case->{db}) {
      $DB::single = 1;
    }

    return $validator->validate($schema, $instance);
  }
);