-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!perl | ||
|
||
use 5.010; | ||
use strict; | ||
use warnings; | ||
|
||
use Data::Sah::JS qw(gen_validator); | ||
use Test::More 0.98; | ||
|
||
my $node_path = Data::Sah::JS::get_nodejs_path(); | ||
unless ($node_path) { | ||
plan skip_all => 'node.js is not available'; | ||
} | ||
|
||
# check double popping of _sahv_dpath, fixed in 0.42+ | ||
|
||
my @tests = ( | ||
{ | ||
schema => ["array", {of=>["hash", keys=>{a=>[array=>of=>"any"]}]}], | ||
input => [{a=>[]}, {a=>[]}], | ||
valid => 1, | ||
}, | ||
); | ||
#test_sah_cases(\@tests, {gen_validator_opts=>{return_type=>"str"}}); | ||
|
||
# XXX use test_sah_cases() when it supports js | ||
for my $test (@tests) { | ||
my $v = gen_validator($test->{schema}, {return_type=>"str"}); | ||
my $res = $v->($test->{input}); | ||
if ($test->{valid}) { | ||
is($res, "", $test->{name}) or diag $res; | ||
} else { | ||
isnt($res, "", $test->{name}); | ||
} | ||
} | ||
done_testing(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters